拓扑错误:自交。jts.geom.TopologyException: found non-noded intersection between LINESTRING

发布时间 2023-06-06 14:38:25作者: 2086nmj

That being said, you will want to ensure the geometries are valid before computing the intersection, using polygon1.isValid() and polygon2.isValid(). The sample data for polygon2 is self-intersecting, so the intersection operation fails with

com.vividsolutions.jts.geom.TopologyException: found non-noded intersection between LINESTRING ( 2.0 0.0, 2.0 2.0 ) and LINESTRING ( 1.0 1.0, 2.5 1.5 ) [ (2.0, 1.3333333333333333, NaN) ]

参考:https://stackoverflow.com/questions/51322693/geotools-calculate-intersection-area-between-two-geometries-needed