achiang / openmotion

1 stars 1 forks source link

mode object should always be returned #5

Closed knitzsche closed 10 years ago

knitzsche commented 10 years ago

Currently, the server only returns a mode object when the query is of type all.

Please consider always returning the mode in each result object. This would simplify parsing by allowing the same code path on every result based on the confidence that every result states its mode.

Also, always returning the mode makes the returned data complete, whereas now its type (mode) is unstated (unless you use all).

Examples from the README.md: curl -i "http://localhost:3000/v1/metros?lat=41.4304&lng=2.222"

[{"dis":0.000011878864177520727,"obj":{"city":"Barcelona","loc":{"type":"Point","coordinates":[2.22290444983689,41.4304584678793]},"name":"Encants de Sant Adrià","_id":"53a4df430e6b8a5afd2ad819"}}]

curl -i "http://localhost:3000/v1/all?lat=36.713&lng=-4.434"

[{"dis":0.000015034127618083719,"obj":{"city":"Malaga","station_id":"14","name":"Estación de Autobuses","mode":"bike","loc":{"coordinates":[-4.432968,36.71276],"type":"Point"},"_id":"53b2e641e543ca467c0cae57"}},{"dis":0.0000030872115924425577,"obj":{"city":"Malaga","name":"Paseo de los Tilos","mode":"bus","loc":{"coordinates":[-4.4342172937,36.7130306843],"type":"Point"},"_id":"53b2e69ee543ca467c0ce214"}}]
achiang commented 10 years ago

'mode' is already returned in every result object. Running the metros example from the README with master:

[{"dis":0.000011879338863382652,"obj":{"name":"Encants de Sant Adrià","loc":{"type":"Point","coordinates":[2.22290444983689,41.4304584678793]},"mode":"metro","city":"Barcelona","_id":"53b89d5df3ff750b732120c1"}}]

But feel free to submit a PR to update the docs to match the actual code.

Thanks.