Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geojson compliant decoding parameter #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jtbaker
Copy link

@jtbaker jtbaker commented Feb 3, 2021

Resolves #33

GeoJSON spec specifies that coordinates be ordered as x, y coordinate pairs. This PR adds a params object argument with a geojson value that defaults to false (having no effect on the default function call).

If decode(<polyline>, {geojson: true}) is passed, however, the points will come back ordered according to the spec. This provides a similar interface to Uber's H3 Bindings in JS. This is useful because it prevents clients needing polyline coordinates to interface with GeoJSON from needing to loop/map through the array again to flip the coordinates around.

@jtbaker jtbaker mentioned this pull request Feb 3, 2021
Signed-off-by: Jason Baker <jbaker@freightwaves.com>
let point

if (geojson) {
point = [lastLng, lastLat]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(L31,54,56)
Hey may want to toss a ; on these I've got caught doing that too

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

Successfully merging this pull request may close these issues.

GeoJson Compliant Decoding
2 participants