locationtech / locationtech/jts

NullPointerException thrown by SimpleNoder when geometry covers but does not overlap

Open
#1,009 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jts-core
Dominant language
Java
Stars
2.2k
Forks
475
Avg merge
14d 10h
Merged PRs (30d)
1

Description

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

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

Reproduce the failure with the supplied base and subtraction geometries, both PrecisionModel configurations, and OverlayNG.DIFFERENCE using SimpleNoder. Start at org.locationtech.jts.noding.SimpleNoder.computeIntersects and follow the OverlayNG EdgeNodingBuilder stack shown in the report. Done means the operation completes without a NullPointerException for both precision modes, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.