Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException thrown by SimpleNoder when geometry covers but does not overlap #1009

Open
ChicagoRaccoon opened this issue Oct 19, 2023 · 1 comment
Labels

Comments

@ChicagoRaccoon
Copy link

ChicagoRaccoon commented Oct 19, 2023

Using SimpleNoder with OverlayNG generates a null pointer exception when geometry covers, but does not overlap.
NPE occurs with double floating point precision and fixed decimal precision.

Fixed decimal precision definition:

double precisionScale = 1e6;
PrecisionModel  PM = new PrecisionModel(precisionScale);

Double floating point precision definition:

PrecisionModel  PM = new PrecisionModel();

Differencing call:

SimpleNoder src = new SimpleNoder();
Geometry newGeometry = OverlayNG.overlay(baseGeometry, subtractionGeometry, OverlayNG.DIFFERENCE, PM, src);

Console output:

Base Geometry
POLYGON ((-100 39.99, -100.01 40, -100.01 40.1, -100 40.11, -99.9 40.11, -99.89 40.1, -99.89 40, -99.9 39.99, -100 39.99))

Subtraction Geometry
MULTIPOLYGON (((-100 40, -100 40.1, -99.9 40, -100 40)))

[ERROR] 2023-10-19 14:11:10:147
java.lang.NullPointerException: null
	at org.locationtech.jts.noding.SimpleNoder.computeIntersects(SimpleNoder.java:59) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.noding.SimpleNoder.computeNodes(SimpleNoder.java:48) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.EdgeNodingBuilder.node(EdgeNodingBuilder.java:186) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.EdgeNodingBuilder.build(EdgeNodingBuilder.java:165) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.OverlayNG.nodeEdges(OverlayNG.java:541) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.OverlayNG.computeEdgeOverlay(OverlayNG.java:495) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.OverlayNG.getResult(OverlayNG.java:483) ~[jts-core-1.19.0.jar:?]
	at org.locationtech.jts.operation.overlayng.OverlayNG.overlay(OverlayNG.java:229) ~[jts-core-1.19.0.jar:?]

JTS TestBuilder Screenshot of the Geometries:
NPE with SimpleNoder

@ChicagoRaccoon ChicagoRaccoon changed the title NullPointerException thrown by SimpleNoder when geometries intersect but do not overlap NullPointerException thrown by SimpleNoder when geometry covers but does not overlap Oct 19, 2023
@dr-jts
Copy link
Contributor

dr-jts commented Oct 20, 2023

You need to specify a SegmentIntersector using the setSegmentIntersector method.

I grant that this is not obvious. Probably this should be enforced by requiring it in the constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants