Geotools com.vividsolutions.jts.geom.TopologyException:边位置冲突

时间:2013-07-10 07:48:31

标签: java geometry geospatial geotools

我得到了这个例外,并且不知道我做错了什么。 我用线性环创建了两个多边形。 然后我试着找到交叉与否。 我得到了这个例外:

com.vividsolutions.jts.geom.TopologyException:side location conflict [(-1.7542192568359292E-100,1.7542192568359284E-100,0.0)]

这是stackTrace:

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

我不知道我做错了什么。

1 个答案:

答案 0 :(得分:3)

  1. 从1.12
  2. 将jts更新为1.13
  3. 从9.0
  4. 将getools更新为10-SNAPSHOT

    然后验证操作返回false。 描述说某些位置的点太靠近了,geotools认为线性环本身相交。 我已经将coodinates截断为5位数后点,它有所帮助。精度太高了。

    问题解决了。