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

Inverted coordinates #176

Closed
khamaileon opened this issue Apr 3, 2023 · 1 comment
Closed

Inverted coordinates #176

khamaileon opened this issue Apr 3, 2023 · 1 comment

Comments

@khamaileon
Copy link

khamaileon commented Apr 3, 2023

In h3 v4.1.0, when using the cellsToMultiPolygon or cellToBoundary functions, the lat and lng values are inverted. It should be (lat, lng) or (lng, lat) in GeoJSON (+ closed loop). Here some sample code that demonstrates the issue:

h3.cellToBoundary("897aa51638bffff", false);
[[2.3280407513160553,48.866418508809375],[2.329773332319682,48.8663663022913],[2.330738889182863,48.86486741339661],[2.329971873027045,48.8634206938187],[2.328239263114671,48.863472879713],[2.32727369826657,48.86497180580943]]
h3.cellsToMultiPolygon(["897aa51638bffff", "897aa51630fffff"], false);

[[[[2.32727369826657,48.86497180580943],[2.3280407513160553,48.866418508809375],[2.329773332319682,48.8663663022913],[2.330738889182863,48.86486741339661],[2.329971873027045,48.8634206938187],[2.328239263114671,48.863472879713]]],[[[2.3353681533087616,48.860318488859306],[2.336135095678257,48.86176524158633],[2.3378675867113197,48.86171306944098],[2.3388331642716147,48.860214165193305],[2.338066258794801,48.8587673958951],[2.3363337388653007,48.85881954741529]]]]

h3.cellToBoundary("897aa51638bffff", true);
[[48.866418508809375,2.3280407513160553],[48.8663663022913,2.329773332319682],[48.86486741339661,2.330738889182863],[48.8634206938187,2.329971873027045],[48.863472879713,2.328239263114671],[48.86497180580943,2.32727369826657],[48.866418508809375,2.3280407513160553]]

h3.cellsToMultiPolygon(["897aa51638bffff", "897aa51630fffff"], true);
[[[[48.86497180580943,2.32727369826657],[48.866418508809375,2.3280407513160553],[48.8663663022913,2.329773332319682],[48.86486741339661,2.330738889182863],[48.8634206938187,2.329971873027045],[48.863472879713,2.328239263114671],[48.86497180580943,2.32727369826657]]],[[[48.860318488859306,2.3353681533087616],[48.86176524158633,2.336135095678257],[48.86171306944098,2.3378675867113197],[48.860214165193305,2.3388331642716147],[48.8587673958951,2.338066258794801],[48.85881954741529,2.3363337388653007],[48.860318488859306,2.3353681533087616]]]]
@khamaileon
Copy link
Author

Ok my bad I didn't specify that polygonToCells should be also in geojson.

const cells = h3.polygonToCells(
  bboxPolygon.geometry.coordinates,
  maxResolution,
  true
);

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

No branches or pull requests

1 participant