Skip to content

Commit

Permalink
More details about self-intersected lines error
Browse files Browse the repository at this point in the history
  • Loading branch information
alex73 committed Apr 10, 2015
1 parent bf70ed6 commit a361f5a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/org/alex73/osmemory/geometry/ExtendedRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@
import org.alex73.osmemory.IOsmWay;
import org.alex73.osmemory.MemoryStorage;

import com.vividsolutions.jts.algorithm.LineIntersector;
import com.vividsolutions.jts.algorithm.RobustLineIntersector;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.geomgraph.GeometryGraph;
import com.vividsolutions.jts.geomgraph.index.SegmentIntersector;

/**
* Class for cache some extended information about relation, like boundary, geometry, etc.
Expand Down Expand Up @@ -195,7 +199,15 @@ LineString fullClosedLine(List<LineString> lines) {
+ tail.get(tail.size() - 1));
}
if (!s.isSimple()) {
throw new RuntimeException("Self-intersected line: " + s);
GeometryGraph graph = new GeometryGraph(0, s);
LineIntersector li = new RobustLineIntersector();
SegmentIntersector si = graph.computeSelfNodes(li, true);
if (si.hasProperInteriorIntersection()) {
throw new RuntimeException("Self-intersection for " + relation.getObjectCode()
+ " near point " + si.getProperIntersectionPoint());
}else {
throw new RuntimeException("Self-intersected line: " + s);
}
}
return s;
}
Expand Down

0 comments on commit a361f5a

Please sign in to comment.