Skip to content

PackedCoordinateSequenceFactory does not work correctly when dealing with CoordinateXY. #434

@pascalriquier

Description

@pascalriquier

PackedCoordinateSequence$Double calls getOrdinate(2) or getOrdinate(3) on the coordinates and that throws an exception in CoordinateXY.

Polygon polygonA = new GeometryFactory(
	new PackedCoordinateSequenceFactory()).createPolygon(
		new Coordinate[] {
			new CoordinateXY(0, 0),
			new CoordinateXY(10, 0),
			new CoordinateXY(10, 10),
			new CoordinateXY(0, 10),
			new CoordinateXY(0, 0)
		}
	);
Polygon polygonB = new GeometryFactory().createPolygon(
		new Coordinate[] {
			new CoordinateXY(5, 5),
			new CoordinateXY(15, 5),
			new CoordinateXY(15, 15),
			new CoordinateXY(5, 15),
			new CoordinateXY(5, 5)
		}
	);
polygonB.intersection(polygonA);
polygonA.intersection(polygonB);

In the above example, the first intersection does not throw an exception while the second does.
PackedCoordinateSequence$Float does this differently by calling getZ() on the coordinates. So possibly the solution is to call getZ() from getOrdinate() in CoordinateXY.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions