-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
GeoJSON right-hand rule #16
Comments
Hi, could you please provide a sample code and expected/actual output? |
Thanks! Here is a quick example ...
NOTE: The dpm() function is just a quick way to output on screen in Drupal. The first example outputs:
If you put these into the validator at: http://geojsonlint.com, the first output comes up with the message: "Polygons and MultiPolygons should follow the right-hand rule" |
Good point, I don't think this is enforced at the moment. I don't have this on top of my head, but I'm not even sure we enforce the clockwise/counterclockwise for polygons at all in this library. I'm surprised though, that MySQL does not output a valid geometry following the right-hand rule, could you please check the raw output of |
Sorry, I've never worked with ST_Union in MySQL like that ... took me a minute to figure out. But I think I did it right with the example info above. I ran:
And it generated:
That looks to me to match the first output above. I had initially that other library above to "rewind" it, but that still left me with a "MultiPolygon" object that wasn't playing well with my Google Maps. I ended up just taking the output of the union and calling array_reverse on the first item in each array and building my own object to then re-serialize with json_encode...
Each "shape" in that "shapes" array is a PHP object like:
There's probably still some refactoring to do there, but it's working so far. In my case, I'm dealing with county and zip code shapes from the US Census which appear to consist of one or more polygons for the outside and then zero or more for any holes. Only the outermost (first one) seems to need reversed so far as I've seen. I did find this information for MS SQL which may or may not be helpful... |
I'm trying to use the union function to combine some shapes. The GeoJSONReader outputs each shape individually correct, but if I run union on them, the output doesn't follow the 'right-hand rule' (https://mapster.me/right-hand-rule-geojson-fixer/).
EDIT: I'm using MySQL for the GeometryEngine
Am I missing something or does this not support that yet? Thanks!
The text was updated successfully, but these errors were encountered: