private boolean isShallow(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) { double dist = CGAlgorithms.distancePointLine(p1, p0, p2); return dist < distanceTol; }
/** * Computes the distance between this line segment and a given point. * * @return the distance from this segment to the given point */ public double distance(Coordinate p) { return CGAlgorithms.distancePointLine(p, p0, p1); }
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) { int orientation = CGAlgorithms.computeOrientation(p0, p1, p2); boolean isAngleToSimplify = (orientation == angleOrientation); if (! isAngleToSimplify) return false; double dist = CGAlgorithms.distancePointLine(p1, p0, p2); return dist < distanceTol; }
/** * Computes the distance from a point to a sequence of line segments. * * @param p * a point * @param line * a sequence of contiguous line segments defined by their vertices * @return the minimum distance between the point and the line segments */ public static double distancePointLine(Coordinate p, Coordinate[] line) { if (line.length == 0) throw new IllegalArgumentException( "Line array must contain at least one vertex"); // this handles the case of length = 1 double minDistance = p.distance(line[0]); for (int i = 0; i < line.length - 1; i++) { double dist = CGAlgorithms.distancePointLine(p, line[i], line[i + 1]); if (dist < minDistance) { minDistance = dist; } } return minDistance; }
private void checkSegmentDistance(Coordinate seg0, Coordinate seg1) { if (queryPt.equals2D(seg0) || queryPt.equals2D(seg1)) return; double segDist = CGAlgorithms.distancePointLine(queryPt, seg1, seg0); if (segDist > 0) updateClearance(segDist, queryPt, seg1, seg0); }
return distancePointLine(A, C, D); if (C.equals(D)) return distancePointLine(D, A, B); distancePointLine(A, C, D), distancePointLine(B, C, D), distancePointLine(C, A, B), distancePointLine(D, A, B));
private double computePointLineDistance(Coordinate pt, FacetSequence facetSeq) { double minDistance = Double.MAX_VALUE; for (int i = facetSeq.start; i < facetSeq.end - 1; i++) { facetSeq.pts.getCoordinate(i, q0); facetSeq.pts.getCoordinate(i + 1, q1); double dist = CGAlgorithms.distancePointLine(pt, q0, q1); if (dist == 0.0) return 0.0; if (dist < minDistance) { minDistance = dist; } } return minDistance; }
/** * Tests whether a triangular ring would be eroded completely by the given * buffer distance. * This is a precise test. It uses the fact that the inner buffer of a * triangle converges on the inCentre of the triangle (the point * equidistant from all sides). If the buffer distance is greater than the * distance of the inCentre from a side, the triangle will be eroded completely. * * This test is important, since it removes a problematic case where * the buffer distance is slightly larger than the inCentre distance. * In this case the triangle buffer curve "inverts" with incorrect topology, * producing an incorrect hole in the buffer. * * @param triangleCoord * @param bufferDistance * @return */ private boolean isTriangleErodedCompletely( Coordinate[] triangleCoord, double bufferDistance) { Triangle tri = new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]); Coordinate inCentre = tri.inCentre(); double distToCentre = CGAlgorithms.distancePointLine(inCentre, tri.p0, tri.p1); return distToCentre < Math.abs(bufferDistance); }
private boolean isShallow(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) { double dist = CGAlgorithms.distancePointLine(p1, p0, p2); return dist < distanceTol; }
/** * Computes the distance between this line segment and a given point. * * @return the distance from this segment to the given point */ public double distance(Coordinate p) { return CGAlgorithms.distancePointLine(p, p0, p1); }
private void tryDist(Coordinate p, Coordinate p0, Coordinate p1) { double dist = CGAlgorithms.distancePointLine(p, p0, p1); if (dist < minDist) { minDist = dist; intPt = p; } }
private double segmentDistance(FacetSequence fs1, FacetSequence fs2) { for (int i1 = 0; i1 < fs1.size(); i1++) { for (int i2 = 1; i2 < fs2.size(); i2++) { Coordinate p = fs1.getCoordinate(i1); Coordinate seg0 = fs2.getCoordinate(i2-1); Coordinate seg1 = fs2.getCoordinate(i2); if (! (p.equals2D(seg0) || p.equals2D(seg1))) { double d = CGAlgorithms.distancePointLine(p, seg0, seg1); if (d < minDist) { minDist = d; updatePts(p, seg0, seg1); if (d == 0.0) return d; } } } } return minDist; }
private void computeMinDistance(LineString line, Point pt, GeometryLocation[] locGeom) { if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal()) > minDistance) return; Coordinate[] coord0 = line.getCoordinates(); Coordinate coord = pt.getCoordinate(); // brute force approach! for (int i = 0; i < coord0.length - 1; i++) { double dist = CGAlgorithms.distancePointLine( coord, coord0[i], coord0[i + 1] ); if (dist < minDistance) { minDistance = dist; LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]); Coordinate segClosestPoint = seg.closestPoint(coord); locGeom[0] = new GeometryLocation(line, i, segClosestPoint); locGeom[1] = new GeometryLocation(pt, 0, coord); } if (minDistance <= terminateDistance) return; } }
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) { int orientation = CGAlgorithms.computeOrientation(p0, p1, p2); boolean isAngleToSimplify = (orientation == angleOrientation); if (! isAngleToSimplify) return false; double dist = CGAlgorithms.distancePointLine(p1, p0, p2); return dist < distanceTol; }
/** * Computes the distance from a point to a sequence of line segments. * * @param p * a point * @param line * a sequence of contiguous line segments defined by their vertices * @return the minimum distance between the point and the line segments */ public static double distancePointLine(Coordinate p, Coordinate[] line) { if (line.length == 0) throw new IllegalArgumentException( "Line array must contain at least one vertex"); // this handles the case of length = 1 double minDistance = p.distance(line[0]); for (int i = 0; i < line.length - 1; i++) { double dist = CGAlgorithms.distancePointLine(p, line[i], line[i + 1]); if (dist < minDistance) { minDistance = dist; } } return minDistance; }
private void checkSegmentDistance(Coordinate seg0, Coordinate seg1) { if (queryPt.equals2D(seg0) || queryPt.equals2D(seg1)) return; double segDist = CGAlgorithms.distancePointLine(queryPt, seg1, seg0); if (segDist > 0) updateClearance(segDist, queryPt, seg1, seg0); }
private double computePointLineDistance(Coordinate pt, FacetSequence facetSeq) { double minDistance = Double.MAX_VALUE; for (int i = facetSeq.start; i < facetSeq.end - 1; i++) { facetSeq.pts.getCoordinate(i, q0); facetSeq.pts.getCoordinate(i + 1, q1); double dist = CGAlgorithms.distancePointLine(pt, q0, q1); if (dist == 0.0) return 0.0; if (dist < minDistance) { minDistance = dist; } } return minDistance; }
/** * @param _seq la sequence de coordonnes * @param _coord les coordonnes du point a tester * @param _tmp1 une coordonne temporaire peut etre nulle * @param _tmp2 une coordonne temporaire peut etre nulle * @return la plus petite distance entre la ligne _seq et x,y */ public static double getDistanceFromFrontier(final CoordinateSequence _seq, final Coordinate _coord, final Coordinate _tmp1, final Coordinate _tmp2) { double minDistance = Double.MAX_VALUE; final Coordinate tmp1 = _tmp1 == null ? new Coordinate() : _tmp1; final Coordinate tmp2 = _tmp2 == null ? new Coordinate() : _tmp2; // brute force approach! for (int i = _seq.size() - 1; i > 0; i--) { _seq.getCoordinate(i, tmp1); _seq.getCoordinate(i - 1, tmp2); final double dist = CGAlgorithms.distancePointLine(_coord, tmp1, tmp2); if (dist < minDistance) { minDistance = dist; } if (minDistance <= 0.0) { return 0; } } return minDistance; }
private double segmentDistance(FacetSequence fs1, FacetSequence fs2) { for (int i1 = 0; i1 < fs1.size(); i1++) { for (int i2 = 1; i2 < fs2.size(); i2++) { Coordinate p = fs1.getCoordinate(i1); Coordinate seg0 = fs2.getCoordinate(i2-1); Coordinate seg1 = fs2.getCoordinate(i2); if (! (p.equals2D(seg0) || p.equals2D(seg1))) { double d = CGAlgorithms.distancePointLine(p, seg0, seg1); if (d < minDist) { minDist = d; updatePts(p, seg0, seg1); if (d == 0.0) return d; } } } } return minDist; }
private void computeMinDistance(LineString line, Point pt, GeometryLocation[] locGeom) { if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal()) > minDistance) return; Coordinate[] coord0 = line.getCoordinates(); Coordinate coord = pt.getCoordinate(); // brute force approach! for (int i = 0; i < coord0.length - 1; i++) { double dist = CGAlgorithms.distancePointLine( coord, coord0[i], coord0[i + 1] ); if (dist < minDistance) { minDistance = dist; LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]); Coordinate segClosestPoint = seg.closestPoint(coord); locGeom[0] = new GeometryLocation(line, i, segClosestPoint); locGeom[1] = new GeometryLocation(pt, 0, coord); } if (minDistance <= terminateDistance) return; } }