RayCrossingCounter throws a NullPointerException:
java.lang.NullPointerException
at com.vividsolutions.jts.algorithm.RayCrossingCounter.countSegment(RayCrossingCounter.java:134)
at com.vividsolutions.jts.algorithm.RayCrossingCounter.locatePointInRing(RayCrossingCounter.java:80)
at com.vividsolutions.jts.algorithm.CGAlgorithms.locatePointInRing(CGAlgorithms.java:167)
at com.vividsolutions.jts.algorithm.CGAlgorithms.isPointInRing(CGAlgorithms.java:148)
at com.vividsolutions.jts.operation.polygonize.EdgeRing.findEdgeRingContaining(EdgeRing.java:89)
at com.vividsolutions.jts.operation.polygonize.Polygonizer.assignHoleToShell(Polygonizer.java:321)
at com.vividsolutions.jts.operation.polygonize.Polygonizer.assignHolesToShells(Polygonizer.java:310)
at com.vividsolutions.jts.operation.polygonize.Polygonizer.polygonize(Polygonizer.java:267)
at com.vividsolutions.jts.operation.polygonize.Polygonizer.getPolygons(Polygonizer.java:187)
Reason is that in EdgeRing#findEdgeRingContaining there is no null check after this line:
testPt = CoordinateArrays.ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates());
Perhaps a valid fix would be to add:
if (testPt == null) continue;
Hi there!
I have a same problem with NPE in RayCrossingCounter when use Polygonizer.getPolygons().
Manfred was right, to fix this problem add checking for null value of
testPt
in EdgeRing.java at line 87.Can you provide a test case which will cause this error?
Unfortunately no. I had this issue some time ago in a rather complex scenario in a project I no longer have access to the code... Well, I think adding that null check I proposed would fix at least the NPE issue without adding any other problem. If a null value for that testPt variable is rather a symptom than the cause I cannot judge with my current knowledge, sorry.