spring-data-mongodb
spring-data-mongodb copied to clipboard
The GeoJsonModule deserialize creates an invalid GeoJsonMultiPolygon
The GeoJson deseralizer creates an invalid GeoJsonMultiPolygon that contain holes.
For example, while using a valid GeoJson MultiPolygon: Dallas, Texas GeoJson
invoking the method
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(GeoJsonModule.serializers());
mapper.registerModule(GeoJsonModule.deserializers());
String dallas = FileUtils.readFileToString(new File("src/test/resources/raw_dallas.geojson"));
GeoJsonMultiPolygon geoJsonMultiPolygon = mapper.readValue(dallas, GeoJsonMultiPolygon.class);
String json = getObjectMapper().writeValueAsString(geoJsonMultiPolygon);
Assert.assertEquals(dallas,json);//fails
The JSON is incorrect, the 'holes' that make up the original Multipolygon are being created incorrectly.
Invalid Dallas, Texas GeoJson
-Jeryl Cook
Thank you for reporting. It would be great if you have the time to help us work on this issue by providing a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.
Ok, I will create today
created a project with the failed test case: https://github.com/boundaries-io/spring-data-mongodb-4586
thank you for the reproducer, any chance to reduce the amount of json data to reproduce the issue? Something that does not necessarily hold hundreds of points but rather a minimal amount to show what's wrong.
Hi, The original geoJson is valid and comforms to the GeoJson Spec.( you can test via geojsonlint, or the JTS library, etc.)
I've added another unit test that uses a working Geojson serializer/deserializer from A Working GeoJson Serializer library