Search in sources :

Example 61 with Point

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

the class RightmostEdgeFinder method getRightmostSideOfSegment.

private int getRightmostSideOfSegment(final DirectedEdge de, final int i) {
    final Edge edge = de.getEdge();
    if (i < 0 || i + 1 >= edge.getVertexCount()) {
        return -1;
    }
    final Point p1 = edge.getPoint(i);
    final Point p2 = edge.getPoint(i + 1);
    if (p1.getY() == p2.getY()) {
        // indicates edge is parallel to x-axis
        return -1;
    }
    int pos = Position.LEFT;
    if (p1.getY() < p2.getY()) {
        pos = Position.RIGHT;
    }
    return pos;
}
Also used : Point(com.revolsys.geometry.model.Point) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Edge(com.revolsys.geometry.geomgraph.Edge) Point(com.revolsys.geometry.model.Point)

Example 62 with Point

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

the class RightmostEdgeFinder method checkForRightmostCoordinate.

private void checkForRightmostCoordinate(final DirectedEdge de) {
    final Edge edge = de.getEdge();
    for (int i = 0; i < edge.getVertexCount() - 1; i++) {
        // only check vertices which are the start or end point of a
        // non-horizontal segment
        // <FIX> MD 19 Sep 03 - NO! we can test all vertices, since the rightmost
        // must have a non-horiz segment adjacent to it
        final int i1 = i;
        final Point point = edge.getPoint(i1);
        if (this.minCoord == null || point.getX() > this.minCoord.getX()) {
            this.minDe = de;
            this.minIndex = i;
            this.minCoord = point;
        }
    // }
    }
}
Also used : Point(com.revolsys.geometry.model.Point) DirectedEdge(com.revolsys.geometry.geomgraph.DirectedEdge) Edge(com.revolsys.geometry.geomgraph.Edge) Point(com.revolsys.geometry.model.Point)

Example 63 with Point

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

the class BufferDistanceValidator method checkMaximumDistance.

/**
 * Checks that the furthest distance from the buffer curve to the input
 * is less than the given maximum distance.
 * This uses the Oriented Hausdorff distance metric.
 * It corresponds to finding
 * the point on the buffer curve which is furthest from <i>some</i> point on the input.
 *
 * @param input a geometry
 * @param bufCurve a geometry
 * @param maxDist the maximum distance that a buffer result can be from the input
 */
private void checkMaximumDistance(final Geometry input, final Geometry bufCurve, final double maxDist) {
    // BufferCurveMaximumDistanceFinder maxDistFinder = new
    // BufferCurveMaximumDistanceFinder(input);
    // maxDistanceFound = maxDistFinder.findDistance(bufCurve);
    final DiscreteHausdorffDistance haus = new DiscreteHausdorffDistance(bufCurve, input);
    haus.setDensifyFraction(0.25);
    this.maxDistanceFound = haus.orientedDistance();
    if (this.maxDistanceFound > maxDist) {
        this.isValid = false;
        final Point[] pts = haus.getCoordinates();
        this.errorLocation = pts[1];
        this.errorIndicator = input.getGeometryFactory().lineString(pts);
        this.errMsg = "Distance between buffer curve and input is too large " + "(" + this.maxDistanceFound + " at " + EWktWriter.lineString(pts[0], pts[1]) + ")";
    }
}
Also used : DiscreteHausdorffDistance(com.revolsys.geometry.algorithm.distance.DiscreteHausdorffDistance) Point(com.revolsys.geometry.model.Point)

Example 64 with Point

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

the class BufferDistanceValidator method checkMinimumDistance.

/**
 * Checks that two geometries are at least a minumum distance apart.
 *
 * @param g1 a geometry
 * @param g2 a geometry
 * @param minDist the minimum distance the geometries should be separated by
 */
private void checkMinimumDistance(final Geometry g1, final Geometry g2, final double minDist) {
    final DistanceWithPoints distOp = new DistanceWithPoints(g1, g2, minDist);
    this.minDistanceFound = distOp.distance();
    if (this.minDistanceFound < minDist) {
        this.isValid = false;
        final List<Point> pts = distOp.nearestPoints();
        this.errorLocation = pts.get(1);
        this.errorIndicator = g1.getGeometryFactory().lineString(pts);
        this.errMsg = "Distance between buffer curve and input is too small " + "(" + this.minDistanceFound + " at " + EWktWriter.lineString(pts.get(0), this.errorLocation) + " )";
    }
}
Also used : DistanceWithPoints(com.revolsys.geometry.operation.distance.DistanceWithPoints) Point(com.revolsys.geometry.model.Point)

Example 65 with Point

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

the class DistanceToPointFinder method computeDistance.

public static void computeDistance(final LineSegment segment, final Point pt, final PointPairDistance ptDist) {
    final Point closestPt = segment.closestPoint(pt);
    ptDist.setMinimum(closestPt, pt);
}
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