Going from GeoJson to GeoJsonPolygon works with the GeoJsonModule. however I cannot transform the GeoJsonPolygon back to GeoJson(String)
@Test
void shouldSerializeGeoJsonPolygonCorrectly() throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new GeoJsonModule());
List<Point> points = Arrays.asList(new Point(100, 0), new Point(101, 0), new Point(101, 1), new Point(100, 1),
new Point(100, 0));
GeoJsonPolygon polygon = new GeoJsonPolygon(points);
Assert.assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]}",mapper.writeValueAsString(polygon));
}
the below is being value is being returned instead of GeoJson.
{"points":[{"x":100.0,"y":0.0},{"x":101.0,"y":0.0},{"x":101.0,"y":1.0},{"x":100.0,"y":1.0},{"x":100.0,"y":0.0}],"coordinates":[{"type":"LineString","coordinates":[{"x":100.0,"y":0.0},{"x":101.0,"y":0.0},{"x":101.0,"y":1.0},{"x":100.0,"y":1.0},{"x":100.0,"y":0.0}]}],"type":"Polygon"}