arthur-e / Wicket

A modest library for moving between Well-Known Text (WKT) and various framework geometries
https://arthur-e.github.io/Wicket/
Other
586 stars 226 forks source link

MultiPolygon not nested correctly #161

Open bsaid97 opened 2 years ago

bsaid97 commented 2 years ago

Hi Arthur, thank you for this awesome library.

I'm trying to convert a Google Maps MultiPolygon back to GeoJSON using Wicket but noticed that the conversion isn't nesting the first index of the shape correctly.

image

It seems that the shape at index 0 needs to be nested into another array to be completely correct. I'm not sure if this is to do with the ring problem I've seen over and over, but as far as I can tell, there is no ring within this shape, just two different polygons in the same multi polygon.

Here's a gist of the GeoJSON generated by Wicket

If you go on geojson.io and make index 0 and level deeper, it works.

arthur-e commented 2 years ago

Hi @bsaid97, could you provide some more information on the geometry? Was this hand-drawn in Google Maps or loaded into Google Maps some way other than Wicket? What code did you use to generate the GeoJSON? Could you share a gist of the "correct" WKT or GeoJSON or a screenshot of what it should look like, correctly plotted?

I don't do Javascript development anymore but hopefully these details will point to an obvious solution or help someone else find a fix.

bsaid97 commented 2 years ago

Hi @bsaid97, could you provide some more information on the geometry? Was this hand-drawn in Google Maps or loaded into Google Maps some way other than Wicket? What code did you use to generate the GeoJSON? Could you share a gist of the "correct" WKT or GeoJSON or a screenshot of what it should look like, correctly plotted?

I don't do Javascript development anymore but hopefully these details will point to an obvious solution or help someone else find a fix.

They aren't hand drawn, I'm loading up various polygons through an API which I then draw on the map. I then try to get the GeoJSON object using Wicket from the google maps polygon object.

Here's a correct gist, you should be able to see that the first polygon in the MultiPolygon is just nested one level deeper.