intersector.computeIntersection(c1, c2, c3, c4); if (intersector.hasIntersection()) { Coordinate intersection = intersector.getIntersection(0); c2.x = intersection.x; c2.y = intersection.y;
protected void setComputationPrecision(PrecisionModel pm) { resultPrecisionModel = pm; li.setPrecisionModel(resultPrecisionModel); } }
/** *@return true if there is an intersection point which is not an endpoint of the segment p0-p1 */ private boolean hasInteriorIntersection(LineIntersector li, Coordinate p0, Coordinate p1) { for (int i = 0; i < li.getIntersectionNum(); i++) { Coordinate intPt = li.getIntersection(i); if (! (intPt.equals(p0) || intPt.equals(p1))) return true; } return false; }
private boolean hasInteriorIntersection(LineSegment seg0, LineSegment seg1) { li.computeIntersection(seg0.p0, seg0.p1, seg1.p0, seg1.p1); return li.isInteriorIntersection(); }
/** * 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; }
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { boolean isProper = li.isProper(); if (isProper) hasProperIntersection = true; intPt = li.getIntersection(0);
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { if (li.isInteriorIntersection()) { for (int intIndex = 0; intIndex < li.getIntersectionNum(); intIndex++) { interiorIntersections.add(li.getIntersection(intIndex));
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;
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { if (li.isInteriorIntersection()) { numInteriorIntersections++; hasInterior = true; ((NodedSegmentString) e0).addIntersections(li, segIndex0, 0); ((NodedSegmentString) e1).addIntersections(li, segIndex1, 1); if (li.isProper()) { numProperIntersections++;
li.computeIntersection(pt[0], pt[1], pt[2], pt[3]); int intNum = li.getIntersectionNum(); assertEquals("Number of intersections not as expected", expectedIntersectionNum, intNum); checkIntPoints(expectedIntPt[0], li.getIntersection(0), distanceTolerance); checkIntPoints(expectedIntPt[1], li.getIntersection(0), distanceTolerance); checkIntPoints(expectedIntPt[1], li.getIntersection(0), distanceTolerance); if (! (equals(expectedIntPt[0],li.getIntersection(0), distanceTolerance) || equals(expectedIntPt[0],li.getIntersection(1), distanceTolerance) )) { checkIntPoints(expectedIntPt[0], li.getIntersection(0), distanceTolerance); checkIntPoints(expectedIntPt[0], li.getIntersection(1), distanceTolerance); else if (! (equals(expectedIntPt[1],li.getIntersection(0), distanceTolerance) || equals(expectedIntPt[1],li.getIntersection(1), distanceTolerance) )) { checkIntPoints(expectedIntPt[1], li.getIntersection(0), distanceTolerance); checkIntPoints(expectedIntPt[1], li.getIntersection(1), distanceTolerance);
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]); } }
li.computeIntersection(s0, s1, s1, s2); int numInt = li.getIntersectionNum();
protected boolean isEndPoint() { return hasIntersection() && !isProper; }
Coordinate intPt = new Coordinate(li.getIntersection(intIndex)); int normalizedSegmentIndex = segmentIndex; double dist = li.getEdgeDistance(geomIndex, intIndex);
/** * Add an SegmentNode for intersection intIndex. * An intersection that falls exactly on a vertex * of the SegmentString is normalized * to use the higher of the two possible segmentIndexes */ public void addIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex) { Coordinate intPt = new Coordinate(li.getIntersection(intIndex)); addIntersection(intPt, segmentIndex); }
/** * Adds EdgeIntersections for one or both * intersections found for a segment of an edge to the edge intersection list. */ public void addIntersections(LineIntersector li, int segmentIndex, int geomIndex) { for (int i = 0; i < li.getIntersectionNum(); i++) { addIntersection(li, segmentIndex, geomIndex, i); } } /**
/** * Computes the "edge distance" of an intersection point along the specified input line segment. * * @param segmentIndex is 0 or 1 * @param intIndex is 0 or 1 * * @return the edge distance of the intersection point */ public double getEdgeDistance(int segmentIndex, int intIndex) { double dist = computeEdgeDistance(intPt[intIndex], inputLines[segmentIndex][0], inputLines[segmentIndex][1]); return dist; } }
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { if (recordIsolated) { e0.setIsolated(false); if (includeProper || ! li.isProper() ) { if (li.isProper()) { properIntersectionPoint = li.getIntersection(0).copy(); hasProper = true; if (isDoneWhenProperInt) {
Coordinate p11 = e1.getCoordinates()[segIndex1 + 1]; li.computeIntersection(p00, p01, p10, p11); if (li.hasIntersection()) { if (li.isInteriorIntersection()) { for (int intIndex = 0; intIndex < li.getIntersectionNum(); intIndex++) { interiorIntersections.add(li.getIntersection(intIndex));
/** * 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; }