Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

_geojson method of Directions class #250

Closed
critical-path opened this issue Jun 23, 2018 · 0 comments
Closed

_geojson method of Directions class #250

critical-path opened this issue Jun 23, 2018 · 0 comments

Comments

@critical-path
Copy link
Contributor

The _geojson method of the Directions class creates a GeoJSON FeatureCollection from the data in the body of a response object.

If the geometry of the FeatureCollection is "LineString", then _geojson calls polyline.decode.

polyline.decode returns coordinates as latitude, longitude tuples, where the GeoJSON standard requires longitude, latitude arrays.

This can make it difficult for a user to create a static map with the FeatureCollection returned by _geojson. (It can, for example, result in validation errors.)

Unless it would have unintended consequences, I propose to make a small change to _geojson.

Current:

'coordinates': polyline.decode(route['geometry'])

Proposed (where "pair" is shorthand for "coordinate pair"):

'coordinates': [
  list(reversed(pair)) for pair in polyline.decode(route['geometry'])
]

Incidentally, this also has implications for the Optimization class (/pull/241).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant