Search in sources :

Example 11 with Point

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

the class ConformingDelaunayTriangulator method findNonGabrielPoint.

/**
 * Given a set of points stored in the kd-tree and a line segment defined by
 * two points in this set, finds a {@link Coordinates} in the circumcircle of
 * the line segment, if one exists. This is called the Gabriel point - if none
 * exists then the segment is said to have the Gabriel condition. Uses the
 * heuristic of finding the non-Gabriel point closest to the midpoint of the
 * segment.
 *
 * @param p
 *          start of the line segment
 * @param q
 *          end of the line segment
 * @return a point which is non-Gabriel
 * or null if no point is non-Gabriel
 */
private Point findNonGabrielPoint(final LineSegmentDoubleData seg) {
    final Point p = seg.getPoint(0);
    final Point q = seg.getPoint(1);
    // Find the mid point on the line and compute the radius of enclosing circle
    final Point midPt = new PointDoubleXY((p.getX() + q.getX()) / 2.0, (p.getY() + q.getY()) / 2.0);
    final double segRadius = p.distancePoint(midPt);
    // compute envelope of circumcircle
    final BoundingBox env = midPt.getBoundingBox().expand(segRadius);
    // Find all points in envelope
    final List result = this.pointIndex.getItems(env);
    // For each point found, test if it falls strictly in the circle
    // find closest point
    Point closestNonGabriel = null;
    double minDist = Double.MAX_VALUE;
    for (final Iterator i = result.iterator(); i.hasNext(); ) {
        final KdNode nextNode = (KdNode) i.next();
        final Point testPt = nextNode;
        // ignore segment endpoints
        if (testPt.equals(2, p) || testPt.equals(2, q)) {
            continue;
        }
        final double testRadius = midPt.distancePoint(testPt);
        if (testRadius < segRadius) {
            // double testDist = seg.distance(testPt);
            final double testDist = testRadius;
            if (closestNonGabriel == null || testDist < minDist) {
                closestNonGabriel = testPt;
                minDist = testDist;
            }
        }
    }
    return closestNonGabriel;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) KdNode(com.revolsys.geometry.index.kdtree.KdNode) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 12 with Point

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

the class ConvexHull method cleanRing.

/**
 *@param  vertices  the vertices of a linear ring, which may or may not be
 *      flattened (i.e. vertices collinear)
 *@return           the coordinates with unnecessary (collinear) vertices
 *      removed
 */
private static LineStringEditor cleanRing(final GeometryFactory geometryFactory, final List<Point> points) {
    final int count = points.size();
    final LineStringEditor cleanedRing = new LineStringEditor(geometryFactory, count);
    Point previousDistinctPoint = null;
    for (int i = 0; i <= count - 2; i++) {
        final Point currentPoint = points.get(i);
        final Point nextPoint = points.get(i + 1);
        if (currentPoint.equals(nextPoint)) {
        } else if (previousDistinctPoint != null && isBetween(previousDistinctPoint, currentPoint, nextPoint)) {
        } else {
            cleanedRing.appendVertex(currentPoint);
            previousDistinctPoint = currentPoint;
        }
    }
    cleanedRing.appendVertex(points.get(count - 1));
    return cleanedRing;
}
Also used : Point(com.revolsys.geometry.model.Point) LineStringEditor(com.revolsys.geometry.model.editor.LineStringEditor) Point(com.revolsys.geometry.model.Point)

Example 13 with Point

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

the class NonEncroachingSplitPointFinder method projectedSplitPoint.

/**
 * Computes a split point which is the projection of the encroaching point on the segment
 *
 * @param seg
 * @param encroachPt
 * @return a split point on the segment
 */
public static Point projectedSplitPoint(final LineSegmentDoubleData seg, final Point encroachPt) {
    final LineSegment lineSeg = seg;
    final Point projPt = lineSeg.project(encroachPt);
    return projPt;
}
Also used : Point(com.revolsys.geometry.model.Point) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 14 with Point

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

the class QuadEdgeConformingDelaunayTinBuilder method initVertices.

private void initVertices(final Geometry geom) {
    for (final Point point : geom.vertices()) {
        final ConstraintVertex vertex = new ConstraintVertex(point);
        this.constraintVertexMap.put(vertex, vertex);
    }
}
Also used : Point(com.revolsys.geometry.model.Point)

Example 15 with Point

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

the class QuadEdgeConformingDelaunayTinBuilder method unique.

public static PointList unique(final Iterable<? extends Point> points, final int vertexCount) {
    final Point[] pointArray = new Point[vertexCount];
    int vertexIndex = 0;
    for (final Point point : points) {
        pointArray[vertexIndex++] = point.newPoint();
    }
    Arrays.sort(pointArray);
    final PointList coordList = new PointList(pointArray, false);
    return coordList;
}
Also used : PointList(com.revolsys.geometry.model.PointList) Point(com.revolsys.geometry.model.Point) 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