Search in sources :

Example 41 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class PointQuadTreeNode method findEntriesWithin.

public void findEntriesWithin(final List<Entry<Point, T>> results, final BoundingBox envelope) {
    final double minX = envelope.getMinX();
    final double maxX = envelope.getMaxX();
    final double minY = envelope.getMinY();
    final double maxY = envelope.getMaxY();
    if (envelope.covers(this.x, this.y)) {
        final Point point = new PointDoubleXY(this.x, this.y);
        results.add(new SimpleImmutableEntry<>(point, this.value));
    }
    final boolean minXLess = isLessThanX(minX);
    final boolean maxXLess = isLessThanX(maxX);
    final boolean minYLess = isLessThanY(minY);
    final boolean maxYLess = isLessThanY(maxY);
    if (this.southWest != null && minXLess && minYLess) {
        this.southWest.findEntriesWithin(results, envelope);
    }
    if (this.northWest != null && minXLess && !maxYLess) {
        this.northWest.findEntriesWithin(results, envelope);
    }
    if (this.southEast != null && !maxXLess && minYLess) {
        this.southEast.findEntriesWithin(results, envelope);
    }
    if (this.northEast != null && !maxXLess && !maxYLess) {
        this.northEast.findEntriesWithin(results, envelope);
    }
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 42 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class CentralEndpointIntersector method getIntersection.

public static Point getIntersection(final double... coordinates) {
    final double averageX = average(0, coordinates);
    final double averageY = average(1, coordinates);
    double intersectionX = Double.NaN;
    double intersectionY = Double.NaN;
    double minDistance = Double.POSITIVE_INFINITY;
    final int vertexCount = coordinates.length / 2;
    int coordinateIndex = 0;
    for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
        final double x = coordinates[coordinateIndex++];
        final double y = coordinates[coordinateIndex++];
        final double distance = MathUtil.distance(averageX, averageY, x, y);
        if (distance < minDistance) {
            minDistance = distance;
            intersectionX = x;
            intersectionY = y;
        }
    }
    return new PointDoubleXY(intersectionX, intersectionY);
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 43 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class CoordinatesUtil method translate.

static Point translate(final Point point, final double angle, final double length) {
    final double x = point.getX();
    final double y = point.getY();
    final double newX = Trig.adjacent(x, angle, length);
    final double newY = Trig.opposite(y, angle, length);
    final Point newPoint = new PointDoubleXY(newX, newY);
    return newPoint;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 44 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class CoordinatesUtil method offset.

static Point offset(final Point coordinate, final double angle, final double distance) {
    final double newX = coordinate.getX() + distance * Math.cos(angle);
    final double newY = coordinate.getY() + distance * Math.sin(angle);
    final Point newCoordinate = new PointDoubleXY(newX, newY);
    return newCoordinate;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 45 with PointDoubleXY

use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.

the class IsValidOp method findPtNotNode.

/**
 * Find a point from the list of testCoords
 * that is NOT a node in the edge for the list of searchCoords
 *
 * @return the point found, or <code>null</code> if none found
 */
public static Point findPtNotNode(final LineString testLine, final LinearRing searchRing, final GeometryGraph graph) {
    // find edge corresponding to searchRing.
    final Edge searchEdge = graph.findEdge(searchRing);
    // find a point in the testCoords which is not a node of the searchRing
    final EdgeIntersectionList eiList = searchEdge.getEdgeIntersectionList();
    // somewhat inefficient - is there a better way? (Use a node map, for
    // instance?)
    final int vertexCount = testLine.getVertexCount();
    for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
        final double x = testLine.getX(vertexIndex);
        final double y = testLine.getY(vertexIndex);
        if (!eiList.isIntersection(x, y)) {
            return new PointDoubleXY(x, y);
        }
    }
    return null;
}
Also used : EdgeIntersectionList(com.revolsys.geometry.geomgraph.EdgeIntersectionList) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Edge(com.revolsys.geometry.geomgraph.Edge) Point(com.revolsys.geometry.model.Point)

Aggregations

PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)138 Point (com.revolsys.geometry.model.Point)91 Geometry (com.revolsys.geometry.model.Geometry)36 ArrayList (java.util.ArrayList)19 BoundingBox (com.revolsys.geometry.model.BoundingBox)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)10 List (java.util.List)9 LineString (com.revolsys.geometry.model.LineString)8 Polygon (com.revolsys.geometry.model.Polygon)6 RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)5 LengthIndexedLine (com.revolsys.geometry.linearref.LengthIndexedLine)5 LinearLocation (com.revolsys.geometry.linearref.LinearLocation)5 LocationIndexedLine (com.revolsys.geometry.linearref.LocationIndexedLine)5 LineSegmentDouble (com.revolsys.geometry.model.segment.LineSegmentDouble)5 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)4 LineSegment (com.revolsys.geometry.model.segment.LineSegment)4 AffineTransformation (com.revolsys.geometry.model.util.AffineTransformation)4 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)4 Vertex (com.revolsys.geometry.model.vertex.Vertex)3 KdNode (com.revolsys.geometry.index.kdtree.KdNode)2