-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GeoConverters
does not convert inner rings of GeoJsonPolygon
#4104
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
Comments
Which version are you using? It would be great if you could please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hi @christophstrobl , Sorry for the delay. This is version 2.7.2. Attached is a zip that should show the problem. it inserts a polygon correctly with a donut hole in the center: outer ring is a box with bounds: 0,0 -> 10,10 . Inner ring is a box 4,4 -> 6,6 It is stored correctly in the database. But when querying it clearly has only the outer ring: Thank you for your help. |
Sorry for long silence - good catch! Thank you for the reproducer! |
GeoConverters
does not convert inner rings
GeoConverters
does not convert inner ringsGeoConverters
does not convert inner rings of GeoJsonPolygon
@mp911de Thank you in advance for the help! Unfortunately this will only fix the issue if it has only one donut hole. A lot of polygons have multiple, for example, if you have a layer for all countries in the world, Italy would have holes for San Marino and Vatican city. For an example on a full fix, you can reference the deserializer I added in the original post. Otherwise I'll try to make my own PR this weekend. Kind regards and again thank you for your time, Lennert |
Thanks for reviewing. We have a release planned for Monday, so the earlier we get a patch the more likely we can include it.
Am 14. Sept. 2022, 14:24 +0200 schrieb lennertdefeyter ***@***.***>:
… @mp911de
Hi,
Thank you in advance for the help! Unfortunately this will only fix the issue if it has only one donut hole. A lot of polygons have multiple, for example, if you have a layer for all countries in the world, Italy would have holes for San Marino and Vatican city.
For an example on a full fix, you can reference the deserializer I added in the original post. Otherwise I'll try to make my own PR this weekend.
Kind regards and again thank you for your time,
Lennert
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi,
I noticed that the GeojsonPolygonconvertor does not convert the inner rings. If you want to convert a polygon with holes. It only looks at the outer ring.
This is very apparent in the code in line 759 of GeoConverters.java.
static GeoJsonPolygon toGeoJsonPolygon(List dbList) { return new GeoJsonPolygon(toListOfPoint((List) dbList.get(0))); }
As you can see, it only looks at the first item in the list of rings (e.g. the outer ring).
I've already fixed it with a custom convertor (see attachment, although this is for multipolygons), but it might be nice to have this in the core.
I think that in order to fix it, the toGeoJsonPolygon(List dbList) function in GeoConverters.java needs to change to:
static GeoJsonPolygon toGeoJsonPolygon(List dbList) { Iterator<GeoJsonLineString> it = ((List) dbList).iterator(); GeoJsonPolygon g = new GeoJsonPolygon(toListOfPoint((List) it.next())); while (it.hasNext()) g = g.withInnerRing(toListOfPoint((List) it.next())); return g; }
GeoJsonMultiPolygonDeserializer.java.txt
.
The text was updated successfully, but these errors were encountered: