gpt4 book ai didi

java - Geotools com.vividsolutions.jts.geom.TopologyException : side location conflict

转载 作者:搜寻专家 更新时间:2023-11-01 03:07:28 27 4
gpt4 key购买 nike

我收到此异常,但不知道我做错了什么。我使用线性环创建了两个多边形。然后我尝试找到是否相交。我得到这个异常(exception):

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)

请告诉我我的错误。我在谷歌上看到了几篇有同样异常(exception)的帖子。有时我确实得到这个异常(exception),有时却没有。当然取决于图形形状:)

我在 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);

我不知道我做错了什么。

最佳答案

  1. 将 jts 从 1.12 更新到 1.13
  2. 将 getools 从 9.0 更新到 10-SNAPSHOT

然后验证操作返回 false。描述说某些位置的点彼此太靠近,geotools 认为线性环与自身相交。我在点后将坐标截断为 5 位数字,这很有帮助。精度太高。

问题解决了。

关于java - Geotools com.vividsolutions.jts.geom.TopologyException : side location conflict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17565121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com