spring-projects / spring-projects/spring-data-mongodb

The GeoJsonModule deserialize creates an invalid GeoJsonMultiPolygon

Open
#4,586 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: feedback-provided status: waiting-for-triage
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

The GeoJson deseralizer creates an invalid GeoJsonMultiPolygon that contain holes.

For example, while using a valid GeoJson MultiPolygon: Dallas, Texas GeoJson
image

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
image

-Jeryl Cook

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GeoJsonModule.deserializers() and the round-trip example using src/test/resources/raw_dallas.geojson. Compare the deserialized and reserialized GeoJsonMultiPolygon, focusing on how holes are represented in the Dallas fixture. Done means the original valid GeoJSON round-trips unchanged and the resulting multipolygon remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, json
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.