我得到了这个例外,不知道我做错了什么。我使用线性环创建了两个多边形。然后我尝试找到是否相交。我得到这个例外:
com.vividsolutions.jts.geom.TopologyException: 侧面位置冲突 [(-1.7542192568359292E-100, 1.7542192568359284E-100, 0.0)]
这是堆栈跟踪:
com.vividsolutions.jts.geom.TopologyException: side location conflict [ (-1.7542192568359292E-100, 1.7542192568359284E-100, 0.0) ]
at com.vividsolutions.jts.geomgraph.EdgeEndStar.propagateSideLabels(EdgeEndStar.java:300)
at com.vividsolutions.jts.geomgraph.EdgeEndStar.computeLabelling(EdgeEndStar.java:139)
at com.vividsolutions.jts.operation.relate.RelateComputer.labelNodeEdges(RelateComputer.java:297)
at com.vividsolutions.jts.operation.relate.RelateComputer.computeIM(RelateComputer.java:132)
at com.vividsolutions.jts.operation.relate.RelateOp.getIntersectionMatrix(RelateOp.java:130)
at com.vividsolutions.jts.operation.relate.RelateOp.relate(RelateOp.java:75)
at com.vividsolutions.jts.geom.Geometry.relate(Geometry.java:1017)
at com.vividsolutions.jts.geom.Geometry.intersects(Geometry.java:769)
异常发生在 EdgeEndStar 类中:
//Debug.print(rightLoc != currLoc, this);
if (rightLoc != currLoc)
throw new TopologyException("side location conflict", e.getCoordinate());
if (leftLoc == Location.NONE) {
Assert.shouldNeverReachHere("found single null side (at " + e.getCoordinate() + ")");
}
currLoc = leftLoc;
有坐标的边缘有问题:
//coordinate: (-262.9001323617947, 313.3121772356619, 0.0)
//coordinate: (-232.77552855071107, 332.43790711803985, 0.0)
请给我一个关于我的错误的想法。我在 google 上看过几篇文章,但有同样的例外。有时我确实得到了这个例外,有时没有。当然取决于图形形状:)
我在两个:linearRing 和 Polygon 上都调用了 isValid()。两个对象都是有效的。
System.out.println("=== === ===");
LinearRing linearRing = geometryFactory.createLinearRing(coordinates.toArray(new Coordinate[coordinates.size()]));
IsValidOp isValidOp = new IsValidOp(linearRing);
System.out.println("LinearRing: closed?" + linearRing.isClosed() + " valid?" + linearRing.isValid() + " isValidOp.isValid(); " + isValidOp.isValid());
Polygon polygon =geometryFactory.createPolygon(linearRing, null);
isValidOp = new IsValidOp(polygon);
System.out.println("Polygon valid? " + polygon.isValid() +" isValidOp" + isValidOp.isValid());
return new BaseGeometry(polygon);
我不知道我做错了什么。