Search in sources :

Example 76 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class DistanceWithLocation method computePointsPoints.

private boolean computePointsPoints(final List<Point> points1, final List<Point> points2) {
    for (final Point point1 : points1) {
        for (final Point point2 : points2) {
            final double dist = point1.distancePoint(point2);
            if (dist < this.minDistance) {
                this.minDistance = dist;
                this.minDistanceLocation1 = new GeometryLocation(point1, 0, point1);
                this.minDistanceLocation2 = new GeometryLocation(point2, 0, point2);
                if (this.minDistance <= this.terminateDistance) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Point(com.revolsys.geometry.model.Point)

Example 77 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class DistanceWithLocation method nearestPoints.

/**
 * Report the coordinates of the nearest points in the input geometries.
 * The points are presented in the same order as the input Geometries.
 *
 * @return a pair of {@link Coordinates}s of the nearest points
 */
public List<Point> nearestPoints() {
    distance();
    if (this.minDistanceLocation1 == null) {
        return Collections.emptyList();
    } else {
        final Point point1 = this.minDistanceLocation1.getPoint();
        final Point point2 = this.minDistanceLocation2.getPoint();
        return Arrays.asList(point1, point2);
    }
}
Also used : Point(com.revolsys.geometry.model.Point)

Example 78 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class DistanceWithLocation method computeLinePoint.

private boolean computeLinePoint(final LineString line, final Point point) {
    if (this.minDistance == Double.MAX_VALUE || line.getBoundingBox().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);
                final int segmentIndex = segment.getSegmentIndex();
                this.minDistanceLocation1 = new GeometryLocation(line, segmentIndex, closestPoint);
                this.minDistanceLocation2 = new GeometryLocation(point, 0, point);
                if (this.minDistance <= this.terminateDistance) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment) Point(com.revolsys.geometry.model.Point)

Example 79 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class MCIndexSnapRounder method computeVertexSnaps.

/**
 * Snaps segments to the vertices of a Segment String.
 */
private void computeVertexSnaps(final NodedSegmentString segment) {
    final LineString points = segment.getLineString();
    for (int i = 0; i < points.getVertexCount(); i++) {
        final Point point = points.getPoint(i);
        final HotPixel hotPixel = new HotPixel(point, this.scaleFactor, this.li);
        final boolean isNodeAdded = this.pointSnapper.snap(hotPixel, segment, i);
        // if a node is created for a vertex, that vertex must be noded too
        if (isNodeAdded) {
            segment.addIntersection(point, i);
        }
    }
}
Also used : LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 80 with Point

use of com.revolsys.geometry.model.Point in project com.revolsys.open by revolsys.

the class MCIndexSnapRounder method computeIntersectionSnaps.

/**
 * Snaps segments to nodes created by segment intersections.
 */
private void computeIntersectionSnaps(final Collection<Point> snapPts) {
    for (final Point snapPt : snapPts) {
        final HotPixel hotPixel = new HotPixel(snapPt, this.scaleFactor, this.li);
        this.pointSnapper.snap(hotPixel);
    }
}
Also used : Point(com.revolsys.geometry.model.Point)

Aggregations

Point (com.revolsys.geometry.model.Point)669 LineString (com.revolsys.geometry.model.LineString)130 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)103 Geometry (com.revolsys.geometry.model.Geometry)95 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)90 ArrayList (java.util.ArrayList)79 BoundingBox (com.revolsys.geometry.model.BoundingBox)51 Polygon (com.revolsys.geometry.model.Polygon)42 LineSegment (com.revolsys.geometry.model.segment.LineSegment)34 List (java.util.List)28 LinearRing (com.revolsys.geometry.model.LinearRing)26 PointDouble (com.revolsys.geometry.model.impl.PointDouble)22 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)19 Edge (com.revolsys.geometry.graph.Edge)18 Test (org.junit.Test)17 Punctual (com.revolsys.geometry.model.Punctual)16 Segment (com.revolsys.geometry.model.segment.Segment)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)15 Record (com.revolsys.record.Record)15 Lineal (com.revolsys.geometry.model.Lineal)14