openjump-gis / openjump

OpenJUMP, the Open Source GIS with more than one trick in its kangaroo pocket, takes the leap from svn to git. join the effort!
http://openjump.org
GNU General Public License v2.0
28 stars 14 forks source link

OJ2 cannot run QA for these data #46

Closed jratike80 closed 2 years ago

jratike80 commented 2 years ago

When I tried to validate the attached dataset with OJ2 it throws an error

java.lang.IllegalArgumentException: Cannot compute the quadrant for point ( 0.0, 0.0 )
    at org.locationtech.jts.geom.Quadrant.quadrant(Quadrant.java:42)
    at org.locationtech.jts.operation.valid.PolygonNode.quadrant(PolygonNode.java:132)
    at org.locationtech.jts.operation.valid.PolygonNode.isAngleGreater(PolygonNode.java:113)
    at org.locationtech.jts.operation.valid.PolygonNode.isInteriorSegment(PolygonNode.java:72)
    at org.locationtech.jts.operation.valid.PolygonTopologyAnalyzer.isIncidentSegmentInRing(PolygonTopologyAnalyzer.java:123)
    at org.locationtech.jts.operation.valid.PolygonTopologyAnalyzer.isSegmentInRing(PolygonTopologyAnalyzer.java:84)
    at org.locationtech.jts.operation.valid.IsValidOp.findHoleOutsideShellPoint(IsValidOp.java:481)
    at org.locationtech.jts.operation.valid.IsValidOp.checkHolesOutsideShell(IsValidOp.java:451)
    at org.locationtech.jts.operation.valid.IsValidOp.isValid(IsValidOp.java:281)
    at org.locationtech.jts.operation.valid.IsValidOp.isValidGeometry(IsValidOp.java:165)
    at org.locationtech.jts.operation.valid.IsValidOp.getValidationError(IsValidOp.java:140)
    at com.vividsolutions.jump.qa.Validator.validateBasicTopology(Validator.java:287)
    at com.vividsolutions.jump.qa.Validator.validate(Validator.java:239)
    at com.vividsolutions.jump.qa.Validator.validate(Validator.java:214)
    at com.vividsolutions.jump.workbench.ui.plugin.ValidateSelectedLayersPlugIn.validate(ValidateSelectedLayersPlugIn.java:224)
    at com.vividsolutions.jump.workbench.ui.plugin.ValidateSelectedLayersPlugIn.run(ValidateSelectedLayersPlugIn.java:145)
    at com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:151)

Old OpenJUMP (Version 20220216 snapshot rev.5074(d439096)) runs Validate Selected Layers fine and finds some topology errors. The OJ2 error "Cannot compute the quadrant for point ( 0.0, 0.0 )" feels odd, layer does not contain such vertex.

OJ2_cannot_run_QA.zip

mukoki commented 2 years ago

Thanks Jukka. Seems to be a JTS bug. I isolated the culprit polygon by dichotomy and will fill a bug report on JTS project. Your layer has plenty of duplicated points and auto-intersections, but this is typical use case for using validation tool. Fortunately, the makevalid tool does its job.

mukoki commented 2 years ago

Solved with the inroduction of JTS 1.19 in https://github.com/openjump-gis/openjump/commit/0288cedf02fb9bd329f2a86223e52013e4765dfc