Skip to content

Allow adding hole to GeoJson Polygon [DATAMONGO-1399] #2312

Closed
@spring-projects-issues

Description

@spring-projects-issues

Paolo opened DATAMONGO-1399 and commented

GeoJsonPolygon cannot have holes.
The only accessor to private field "coordinates" is the following

@Override
	public List<GeoJsonLineString> getCoordinates() {
		return Collections.unmodifiableList(this.coordinates);
	}

So, after construction (below the constructor) there is no way to add other GeoJsonLineString for holes.

	public GeoJsonPolygon(List<Point> points) {

		super(points);
		this.coordinates.add(new GeoJsonLineString(points));
	}

WORKAROUND
Using Reflection...

Field f = result.getClass().getDeclaredField("coordinates");
f.setAccessible(true);
List<GeoJsonLineString> coordinates = (List<GeoJsonLineString>) f.get(result);
coordinates.add(new GeoJsonLineString(...));

This works, but it's an horrible workaround!!!


Affects: 1.8 GA (Gosling)

Referenced from: pull request #352

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions