Search in sources :

Example 16 with Segment

use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.

the class Distance3DOp method computeMinDistanceLinePoint.

private void computeMinDistanceLinePoint(final LineString line, final Point point, final boolean flip) {
    final Point coord = point.getPoint();
    // brute force approach!
    int i = 0;
    for (final Segment segment : line.segments()) {
        final double dist = CGAlgorithms3D.distancePointSegment(coord, segment.getPoint(0), segment.getPoint(1));
        if (dist < this.minDistance) {
            final Point segClosestPoint = segment.closestPoint(coord);
            updateDistance(dist, new GeometryLocation(line, i, segClosestPoint.newPoint2D()), new GeometryLocation(point, 0, coord), flip);
        }
        if (this.isDone) {
            return;
        }
        i++;
    }
}
Also used : GeometryLocation(com.revolsys.geometry.operation.distance.GeometryLocation) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

Example 17 with Segment

use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.

the class DistanceWithPoints method computeLineLine.

private boolean computeLineLine(final LineString line1, final LineString line2) {
    if (this.minDistance == Double.MAX_VALUE || line1.getBoundingBox().distance(line2.getBoundingBox()) <= this.minDistance) {
        for (final Segment segment1 : line1.segments()) {
            for (final Segment segment2 : line2.segments()) {
                final double dist = segment1.distance(segment2);
                if (dist < this.minDistance) {
                    this.minDistance = dist;
                    final Point[] closestPt = segment1.closestPoints(segment2);
                    this.minDistancePoint1 = closestPt[0];
                    this.minDistancePoint2 = closestPt[1];
                    if (this.minDistance <= this.terminateDistance) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

Example 18 with Segment

use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.

the class DistanceWithPoints method computePointLine.

private boolean computePointLine(final Point point, final LineString line) {
    final BoundingBox boundingBox = line.getBoundingBox();
    if (this.minDistance == Double.MAX_VALUE || boundingBox.distance(point) <= this.minDistance) {
        for (final Segment segment : line.segments()) {
            final double distance = segment.distancePoint(point);
            if (distance < this.minDistance) {
                this.minDistance = distance;
                final Point closestPoint = segment.closestPoint(point);
                this.minDistancePoint1 = point;
                this.minDistancePoint2 = closestPoint;
                if (this.minDistance <= this.terminateDistance) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

Example 19 with Segment

use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.

the class TaggedLineString method init.

private void init() {
    final int vertexCount = this.parentLine.getVertexCount();
    this.segs = new TaggedLineSegment[vertexCount - 1];
    int i = 0;
    for (final Segment segment : this.parentLine.segments()) {
        final TaggedLineSegment seg = new TaggedLineSegment(segment.getPoint(0), segment.getPoint(1), this.parentLine, i);
        this.segs[i] = seg;
        i++;
    }
}
Also used : Point(com.revolsys.geometry.model.Point) LineSegment(com.revolsys.geometry.model.segment.LineSegment) Segment(com.revolsys.geometry.model.segment.Segment)

Example 20 with Segment

use of com.revolsys.geometry.model.segment.Segment in project com.revolsys.open by revolsys.

the class BufferCurveMaximumDistanceFinder method computeMaxMidpointDistance.

private void computeMaxMidpointDistance(final Geometry curve) {
    final PointPairDistance maxPtDist = new PointPairDistance();
    final PointPairDistance minPtDist = new PointPairDistance();
    for (final Segment segment : curve.segments()) {
        final Point midPoint = segment.midPoint();
        minPtDist.initialize();
        DistanceToPointFinder.computeDistance(this.inputGeom, midPoint, minPtDist);
        maxPtDist.setMaximum(minPtDist);
    }
    this.maxPtDist.setMaximum(maxPtDist);
}
Also used : PointPairDistance(com.revolsys.geometry.algorithm.distance.PointPairDistance) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

Aggregations

Segment (com.revolsys.geometry.model.segment.Segment)22 Point (com.revolsys.geometry.model.Point)16 Vertex (com.revolsys.geometry.model.vertex.Vertex)6 LineSegment (com.revolsys.geometry.model.segment.LineSegment)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Geometry (com.revolsys.geometry.model.Geometry)2 LineString (com.revolsys.geometry.model.LineString)2 LineStringSegment (com.revolsys.geometry.model.segment.LineStringSegment)2 AbstractVertex (com.revolsys.geometry.model.vertex.AbstractVertex)2 LineStringVertex (com.revolsys.geometry.model.vertex.LineStringVertex)2 GeometryLocation (com.revolsys.geometry.operation.distance.GeometryLocation)2 Pair (com.revolsys.util.Pair)2 PointPairDistance (com.revolsys.geometry.algorithm.distance.PointPairDistance)1 LineSegmentIndex (com.revolsys.geometry.index.LineSegmentIndex)1 GeometryComponent (com.revolsys.geometry.model.GeometryComponent)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 PointDoubleXYOrientation (com.revolsys.geometry.model.impl.PointDoubleXYOrientation)1 PreparedLineString (com.revolsys.geometry.model.prep.PreparedLineString)1 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)1 DuplicateVertexError (com.revolsys.geometry.operation.simple.DuplicateVertexError)1