4

I get this exception and have no idea what do I do wrong. I've created two polygons using linear ring. Then I try to find do the intersect or not. I get this exception:

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

Here is the 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)

Exception happens in class 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;

Something wrong with edge wich have coordinates:

  //coordinate: (-262.9001323617947, 313.3121772356619, 0.0)
    //coordinate: (-232.77552855071107, 332.43790711803985, 0.0)

Please give me an idea about my mistake. I've seen several posts in google with the same exception. Sometimes I do get this exception, sometimes not. Depends on the figure shape ofcourse :)

I called isValid() on both: linearRing and on Polygon. both objects are valid.

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

I have no idea what do I do wrong.

jrouquie
  • 4,315
  • 4
  • 27
  • 43
Capacytron
  • 3,425
  • 6
  • 47
  • 80

1 Answers1

3
  1. Update jts to 1.13 from 1.12
  2. update getools to 10-SNAPSHOT from 9.0

then validation operation returned false. Description said that the points in some locations were too close to each other and geotools thought that linear ring intersects itself. I've truncated coodinates to 5 digits after dot and it helped. The precision was too high.

The problem is solved.

Capacytron
  • 3,425
  • 6
  • 47
  • 80