private boolean hasInteriorIntersection(LineSegment seg0, LineSegment seg1) { li.computeIntersection(seg0.p0, seg0.p1, seg1.p0, seg1.p1); return li.isInteriorIntersection(); }
intersector.computeIntersection(c1, c2, c3, c4); if (intersector.hasIntersection()) { Coordinate intersection = intersector.getIntersection(0);
/** * Test whether the given segment intersects * the closure of this hot pixel. * This is NOT the test used in the standard snap-rounding * algorithm, which uses the partially closed tolerance square * instead. * This routine is provided for testing purposes only. * * @param p0 the start point of a line segment * @param p1 the end point of a line segment * @return <code>true</code> if the segment intersects the closure of the pixel's tolerance square */ private boolean intersectsPixelClosure(Coordinate p0, Coordinate p1) { li.computeIntersection(p0, p1, corner[0], corner[1]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[1], corner[2]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[2], corner[3]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[3], corner[0]); if (li.hasIntersection()) return true; return false; }
/** * 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; }
/** * Tests whether a point lies on the line defined by a list of * coordinates. * * @param p the point to test * @param line the line coordinates * @return true if the point is a vertex of the line or lies in the interior * of a line segment in the line */ public static boolean isOnLine(Coordinate p, Coordinate[] line) { LineIntersector lineIntersector = new RobustLineIntersector(); for (int i = 1; i < line.length; i++) { Coordinate p0 = line[i - 1]; Coordinate p1 = line[i]; lineIntersector.computeIntersection(p, p0, p1); if (lineIntersector.hasIntersection()) { return true; } } return false; }
li.computeIntersection(p0, p1, corner[0], corner[1]); if (li.isProper()) return true; li.computeIntersection(p0, p1, corner[1], corner[2]); if (li.isProper()) return true; if (li.hasIntersection()) intersectsLeft = true; li.computeIntersection(p0, p1, corner[2], corner[3]); if (li.isProper()) return true; if (li.hasIntersection()) intersectsBottom = true; li.computeIntersection(p0, p1, corner[3], corner[0]); if (li.isProper()) return true;
/** * 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 boolean intersects(Coordinate p0, Coordinate p1) { Envelope segEnv = new Envelope(p0, p1); if (! rectEnv.intersects(segEnv)) return false; li.computeIntersection(p0, p1, corner[0], corner[1]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[1], corner[2]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[2], corner[3]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[3], corner[0]); if (li.hasIntersection()) return true; return false; }
public boolean intersects(Coordinate p0, Coordinate p1) { Envelope segEnv = new Envelope(p0, p1); if (! rectEnv.intersects(segEnv)) return false; li.computeIntersection(p0, p1, corner[0], corner[1]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[1], corner[2]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[2], corner[3]); if (li.hasIntersection()) return true; li.computeIntersection(p0, p1, corner[3], corner[0]); if (li.hasIntersection()) return true; return false; }
private void checkInteriorIntersections(SegmentString e0, int segIndex0, SegmentString e1, int segIndex1) { if (e0 == e1 && segIndex0 == segIndex1) return; //numTests++; Coordinate p00 = e0.getCoordinates()[segIndex0]; Coordinate p01 = e0.getCoordinates()[segIndex0 + 1]; Coordinate p10 = e1.getCoordinates()[segIndex1]; Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { if (li.isProper() || hasInteriorIntersection(li, p00, p01) || hasInteriorIntersection(li, p10, p11)) { throw new RuntimeException("found non-noded intersection at " + p00 + "-" + p01 + " and " + p10 + "-" + p11); } } } /**
li.computeIntersection(s0, s1, s1, s2); int numInt = li.getIntersectionNum();
/** * Tests whether a point lies on the line defined by a * {@link CoordinateSequence}. * * @param p the point to test * @param line the line coordinates * @return true if the point is a vertex of the line or lies in the interior * of a line segment in the line */ public static boolean isOnLine(Coordinate p, CoordinateSequence line) { LineIntersector lineIntersector = new RobustLineIntersector(); Coordinate p0 = new Coordinate(); Coordinate p1 = new Coordinate(); int n = line.size(); for (int i = 1; i < n; i++) { line.getCoordinate(i-1, p0); line.getCoordinate(i, p1); lineIntersector.computeIntersection(p, p0, p1); if (lineIntersector.hasIntersection()) { return true; } } return false; }
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11);
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11);
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]); } }
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11);
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11);
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11);
li.computeIntersection(a0, a1, b0, b1); if (li.hasIntersection()) { isIntersected0[i] = true;
li.computeIntersection(pt[0], pt[1], pt[2], pt[3]);