/** * Creates an intersection finder using a {@link RobustLineIntersector}. */ public SegmentIntersectionDetector() { this(new RobustLineIntersector()); }
public IteratedNoder(PrecisionModel pm) { li = new RobustLineIntersector(); this.pm = pm; li.setPrecisionModel(pm); }
Coordinate c3 = new Coordinate(); Coordinate c4 = new Coordinate(); LineIntersector intersector = new RobustLineIntersector(); c1.x = data[0]; c1.y = data[1];
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(); }
public static Geometry MCIndexNoding(Geometry geom) { Noder noder = new MCIndexNoder(new IntersectionAdder(new RobustLineIntersector())); noder.computeNodes( SegmentStringUtil.extractNodedSegmentStrings(geom) ); return SegmentStringUtil.toGeometry(noder.getNodedSubstrings(), FunctionsUtil.getFactoryOrDefault(geom)); }
public static boolean segmentIntersects(Geometry g1, Geometry g2) { Coordinate[] pt1 = g1.getCoordinates(); Coordinate[] pt2 = g2.getCoordinates(); RobustLineIntersector ri = new RobustLineIntersector(); ri.computeIntersection(pt1[0], pt1[1], pt2[0], pt2[1]); return ri.hasIntersection(); }
Coordinate o2 = csOrig.getCoordinate(1); int origIdx = 0; RobustLineIntersector intersector = new RobustLineIntersector(); int matched = 0; boolean flipped = false;
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()); }
public static int interiorIntersectionCount(Geometry geom) { NodingIntersectionFinder intCounter = NodingIntersectionFinder .createIntersectionCounter( new RobustLineIntersector() ); Noder noder = new MCIndexNoder( intCounter ); noder.computeNodes( SegmentStringUtil.extractNodedSegmentStrings(geom) ); return intCounter.count(); }
public void run() { exercise(new NonRobustLineIntersector()); exercise(new RobustLineIntersector()); }
/** * 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, true); checkNoSelfIntersectingRings(graph); }
public static Geometry MCIndexNodingWithPrecision(Geometry geom, double scaleFactor) { PrecisionModel fixedPM = new PrecisionModel(scaleFactor); LineIntersector li = new RobustLineIntersector(); li.setPrecisionModel(fixedPM); Noder noder = new MCIndexNoder(new IntersectionAdder(li)); noder.computeNodes( SegmentStringUtil.extractNodedSegmentStrings(geom) ); return SegmentStringUtil.toGeometry( noder.getNodedSubstrings(), FunctionsUtil.getFactoryOrDefault(geom) ); }
public static Geometry segmentIntersectionDD(Geometry g1, Geometry g2) { Coordinate[] pt1 = g1.getCoordinates(); Coordinate[] pt2 = g2.getCoordinates(); // first check if there actually is an intersection RobustLineIntersector ri = new RobustLineIntersector(); ri.computeIntersection(pt1[0], pt1[1], pt2[0], pt2[1]); if (! ri.hasIntersection()) { // no intersection => return empty point return g1.getFactory().createPoint((Coordinate) null); } Coordinate intPt = CGAlgorithmsDD.intersection(pt1[0], pt1[1], pt2[0], pt2[1]); return g1.getFactory().createPoint(intPt); } }
public void checkInputNotAltered(Coordinate[] pt, int scaleFactor) { // save input points Coordinate[] savePt = new Coordinate[4]; for (int i = 0; i < 4; i++) { savePt[i] = new Coordinate(pt[i]); } LineIntersector li = new RobustLineIntersector(); li.setPrecisionModel(new PrecisionModel(scaleFactor)); li.computeIntersection(pt[0], pt[1], pt[2], pt[3]); // check that input points are unchanged for (int i = 0; i < 4; i++) { assertEquals("Input point " + i + " was altered - ", savePt[i], pt[i]); } }
public void testCollinear4() { RobustLineIntersector i = new RobustLineIntersector(); Coordinate p1 = new Coordinate(30, 10); Coordinate p2 = new Coordinate(20, 10); Coordinate q1 = new Coordinate(10, 10); Coordinate q2 = new Coordinate(30, 10); i.computeIntersection(p1, p2, q1, q2); assertEquals(RobustLineIntersector.COLLINEAR_INTERSECTION, i.getIntersectionNum()); assertTrue(i.hasIntersection()); }
public void testCollinear1() { RobustLineIntersector i = new RobustLineIntersector(); Coordinate p1 = new Coordinate(10, 10); Coordinate p2 = new Coordinate(20, 10); Coordinate q1 = new Coordinate(22, 10); Coordinate q2 = new Coordinate(30, 10); i.computeIntersection(p1, p2, q1, q2); assertEquals(RobustLineIntersector.NO_INTERSECTION, i.getIntersectionNum()); assertTrue(!i.isProper()); assertTrue(!i.hasIntersection()); }
public void testCollinear2() { RobustLineIntersector i = new RobustLineIntersector(); Coordinate p1 = new Coordinate(10, 10); Coordinate p2 = new Coordinate(20, 10); Coordinate q1 = new Coordinate(20, 10); Coordinate q2 = new Coordinate(30, 10); i.computeIntersection(p1, p2, q1, q2); assertEquals(RobustLineIntersector.POINT_INTERSECTION, i.getIntersectionNum()); assertTrue(!i.isProper()); assertTrue(i.hasIntersection()); }
public void testCollinear3() { RobustLineIntersector i = new RobustLineIntersector(); Coordinate p1 = new Coordinate(10, 10); Coordinate p2 = new Coordinate(20, 10); Coordinate q1 = new Coordinate(15, 10); Coordinate q2 = new Coordinate(30, 10); i.computeIntersection(p1, p2, q1, q2); assertEquals(RobustLineIntersector.COLLINEAR_INTERSECTION, i.getIntersectionNum()); assertTrue(!i.isProper()); assertTrue(i.hasIntersection()); }
public void test2Lines() { RobustLineIntersector i = new RobustLineIntersector(); Coordinate p1 = new Coordinate(10, 10); Coordinate p2 = new Coordinate(20, 20); Coordinate q1 = new Coordinate(20, 10); Coordinate q2 = new Coordinate(10, 20); Coordinate x = new Coordinate(15, 15); i.computeIntersection(p1, p2, q1, q2); assertEquals(RobustLineIntersector.POINT_INTERSECTION, i.getIntersectionNum()); assertEquals(1, i.getIntersectionNum()); assertEquals(x, i.getIntersection(0)); assertTrue(i.isProper()); assertTrue(i.hasIntersection()); }