public IteratedNoder(PrecisionModel pm) { li = new RobustLineIntersector(); this.pm = pm; li.setPrecisionModel(pm); }
public MCIndexSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
public SimpleSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
/** * Tests whether a point lies on the line segments defined by a list of * coordinates. * * @return true if the point is a vertex of the line or lies in the interior * of a line segment in the linestring */ public static boolean isOnLine(Coordinate p, Coordinate[] pt) { LineIntersector lineIntersector = new RobustLineIntersector(); for (int i = 1; i < pt.length; i++) { Coordinate p0 = pt[i - 1]; Coordinate p1 = pt[i]; lineIntersector.computeIntersection(p, p0, p1); if (lineIntersector.hasIntersection()) { return true; } } return false; }
/** * Computes an intersection point between two line segments, if there is one. * There may be 0, 1 or many intersection points between two segments. * If there are 0, null is returned. If there is 1 or more, * exactly one of them is returned * (chosen at the discretion of the algorithm). * If more information is required about the details of the intersection, * the {@link RobustLineIntersector} class should be used. * * @param line a line segment * @return an intersection point, or <code>null</code> if there is none * * @see RobustLineIntersector */ public Coordinate intersection(LineSegment line) { LineIntersector li = new RobustLineIntersector(); li.computeIntersection(p0, p1, line.p0, line.p1); if (li.hasIntersection()) return li.getIntersection(0); return null; }
public OffsetSegmentGenerator(PrecisionModel precisionModel, BufferParameters bufParams, double distance) { this.precisionModel = precisionModel; this.bufParams = bufParams; // compute intersections in full precision, to provide accuracy // the points are rounded as they are inserted into the curve line li = new RobustLineIntersector(); filletAngleQuantum = Math.PI / 2.0 / bufParams.getQuadrantSegments(); /** * Non-round joins cause issues with short closing segments, so don't use * them. In any case, non-round joins only really make sense for relatively * small buffer distances. */ if (bufParams.getQuadrantSegments() >= 8 && bufParams.getJoinStyle() == BufferParameters.JOIN_ROUND) closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR; init(distance); }
private Noder getNoder(PrecisionModel precisionModel) { if (workingNoder != null) return workingNoder; // otherwise use a fast (but non-robust) noder MCIndexNoder noder = new MCIndexNoder(); LineIntersector li = new RobustLineIntersector(); li.setPrecisionModel(precisionModel); noder.setSegmentIntersector(new IntersectionAdder(li)); // Noder noder = new IteratedNoder(precisionModel); return noder; // Noder noder = new SimpleSnapRounder(precisionModel); // Noder noder = new MCIndexSnapRounder(precisionModel); // Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), // precisionModel.getScale()); }
private void findAndClassifyIntersections(Geometry geom) { List lineSegStr = SegmentStringUtil.extractSegmentStrings(geom); LineIntersector li = new RobustLineIntersector(); SegmentIntersectionDetector intDetector = new SegmentIntersectionDetector(li); intDetector.setFindAllIntersectionTypes(true); prepPoly.getIntersectionFinder().intersects(lineSegStr, intDetector); hasSegmentIntersection = intDetector.hasIntersection(); hasProperIntersection = intDetector.hasProperIntersection(); hasNonProperIntersection = intDetector.hasNonProperIntersection(); }
/** * Checks validity of a LinearRing. */ private void checkValid(LinearRing g) { checkInvalidCoordinates(g.getCoordinates()); if (validErr != null) return; checkClosedRing(g); if (validErr != null) return; GeometryGraph graph = new GeometryGraph(0, g); checkTooFewPoints(graph); if (validErr != null) return; LineIntersector li = new RobustLineIntersector(); graph.computeSelfNodes(li, true); checkNoSelfIntersectingRings(graph); }
/** * Creates an intersection finder using a {@link RobustLineIntersector}. */ public SegmentIntersectionDetector() { this(new RobustLineIntersector()); }
private boolean isSimpleLinearGeometry(Geometry geom) { if (geom.isEmpty()) return true; GeometryGraph graph = new GeometryGraph(0, geom); LineIntersector li = new RobustLineIntersector(); SegmentIntersector si = graph.computeSelfNodes(li, true); // if no self-intersection, must be simple if (! si.hasIntersection()) return true; if (si.hasProperIntersection()) { nonSimpleLocation = si.getProperIntersectionPoint(); return false; } if (hasNonEndpointIntersection(graph)) return false; if (isClosedEndpointsInInterior) { if (hasClosedEndpointIntersection(graph)) return false; } return true; }
public IteratedNoder(PrecisionModel pm) { li = new RobustLineIntersector(); this.pm = pm; li.setPrecisionModel(pm); }
public SimpleSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
public MCIndexSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
/** * Split a geometry at intersections and return a list of sublinestrings * * @param tobeNodes * */ public static Geometry geometryNoders(Geometry tobeNodes) { Noder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector())); noder.computeNodes(createNodedSegmentStrings(tobeNodes)); Collection<NodedSegmentString> nodedSegStrings = noder.getNodedSubstrings(); return fromSegmentStrings(nodedSegStrings); }
/** * Nodes a geometry using a monotone chain and a spatial index * @param geom * @return */ public static Geometry node(Geometry geom) { if (geom == null) { return null; } Noder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector())); noder.computeNodes(SegmentStringUtil.extractNodedSegmentStrings(geom)); return SegmentStringUtil.toGeometry(noder.getNodedSubstrings(), geom.getFactory()); } }
private Noder getNoder(PrecisionModel precisionModel) { if (workingNoder != null) return workingNoder; // otherwise use a fast (but non-robust) noder MCIndexNoder noder = new MCIndexNoder(); LineIntersector li = new RobustLineIntersector(); li.setPrecisionModel(precisionModel); noder.setSegmentIntersector(new IntersectionAdder(li)); // Noder noder = new IteratedNoder(precisionModel); return noder; // Noder noder = new SimpleSnapRounder(precisionModel); // Noder noder = new MCIndexSnapRounder(precisionModel); // Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), // precisionModel.getScale()); }
LineString firstPiece = findCrossingPair(LineStringA, LineStringB); LineString secondPiece = findCrossingPair(LineStringB, firstPiece); // Now we have two 2-point LineStrings which we can pass to the // LineIntersector LineIntersector lineIntersector = new RobustLineIntersector(); lineIntersector.computeIntersection( firstPiece.getStartPoint().getCoordinate(), firstPiece.getEndPoint().getCoordinate(), secondPiece.getStartPoint().getCoordinate(), secondPiece.getEndPoint().getCoordinate() ); Coordinate intersect = lineIntersector.getIntersection(0); System.out.println("Intersection at " + intersect);
/** * Checks validity of a LinearRing. */ private void checkValid(LinearRing g) { checkInvalidCoordinates(g.getCoordinates()); if (validErr != null) return; checkClosedRing(g); if (validErr != null) return; GeometryGraph graph = new GeometryGraph(0, g); checkTooFewPoints(graph); if (validErr != null) return; LineIntersector li = new RobustLineIntersector(); graph.computeSelfNodes(li, true); checkNoSelfIntersectingRings(graph); }
private boolean isSimpleLinearGeometry(Geometry geom) { if (geom.isEmpty()) return true; GeometryGraph graph = new GeometryGraph(0, geom); LineIntersector li = new RobustLineIntersector(); SegmentIntersector si = graph.computeSelfNodes(li, true); // if no self-intersection, must be simple if (! si.hasIntersection()) return true; if (si.hasProperIntersection()) { nonSimpleLocation = si.getProperIntersectionPoint(); return false; } if (hasNonEndpointIntersection(graph)) return false; if (isClosedEndpointsInInterior) { if (hasClosedEndpointIntersection(graph)) return false; } return true; }