Search in sources :

Example 36 with PointDoubleXY

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

the class PreparedGeometryThreadSafeTest method setup.

@Override
public void setup() {
    final Geometry sinePoly = newSineStar(new PointDoubleXY(0, 0), 100000.0, this.nPts);
    this.pg = sinePoly.prepare();
    this.g = newSineStar(new PointDoubleXY(10, 10), 100000.0, 100);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 37 with PointDoubleXY

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

the class LineStringGenerator method fillArc.

private static void fillArc(final double x, final double dx, final double y, final double dy, final Point[] coords, final GeometryFactory gf) {
    if (coords.length == 2) {
        throw new IllegalStateException("Too few points for Arc");
    }
    final double theta = 360 / coords.length;
    final double start = theta / 2;
    final double radius = dx < dy ? dx / 3 : dy / 3;
    // center
    final double cx = x + dx / 2;
    // center
    final double cy = y + dy / 2;
    for (int i = 0; i < coords.length; i++) {
        final double angle = Math.toRadians(start + theta * i);
        // may be neg.
        final double fx = Math.sin(angle) * radius;
        // may be neg.
        final double fy = Math.cos(angle) * radius;
        coords[i] = new PointDoubleXY(gf.makePrecise(0, cx + fx), gf.makePrecise(1, cy + fy));
    }
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 38 with PointDoubleXY

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

the class LineStringGenerator method fillHorz.

private static void fillHorz(final double x, final double dx, final double y, final double dy, final Point[] coords, final GeometryFactory gf) {
    final double fy = y + Math.random() * dy;
    // remainder of x distance
    double rx = dx;
    coords[0] = new PointDoubleXY(gf.makePrecise(0, x), gf.makePrecise(1, fy));
    for (int i = 1; i < coords.length - 1; i++) {
        rx -= Math.random() * rx;
        coords[i] = new PointDoubleXY(gf.makePrecise(0, x + dx - rx), gf.makePrecise(1, fy));
    }
    coords[coords.length - 1] = new PointDoubleXY(gf.makePrecise(0, x + dx), gf.makePrecise(1, fy));
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 39 with PointDoubleXY

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

the class LineStringGenerator method fillVert.

private static void fillVert(final double x, final double dx, final double y, final double dy, final Point[] coords, final GeometryFactory gf) {
    final double fx = x + Math.random() * dx;
    // remainder of y distance
    double ry = dy;
    coords[0] = new PointDoubleXY(gf.makePrecise(0, fx), gf.makePrecise(1, y));
    for (int i = 1; i < coords.length - 1; i++) {
        ry -= Math.random() * ry;
        coords[i] = new PointDoubleXY(gf.makePrecise(0, fx), gf.makePrecise(1, y + dy - ry));
    }
    coords[coords.length - 1] = new PointDoubleXY(gf.makePrecise(0, fx), gf.makePrecise(1, y + dy));
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 40 with PointDoubleXY

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

the class DiscreteHausdorffDistance method computeOrientedDistance.

private void computeOrientedDistance(final Geometry discreteGeom, final Geometry geom, final PointPairDistance ptDist) {
    final PointPairDistance maxPtDist = new PointPairDistance();
    final PointPairDistance minPtDist = new PointPairDistance();
    for (final Vertex vertex : discreteGeom.vertices()) {
        minPtDist.initialize();
        DistanceToPoint.computeDistance(geom, vertex, minPtDist);
        maxPtDist.setMaximum(minPtDist);
    }
    ptDist.setMaximum(maxPtDist);
    if (this.densifyFrac > 0) {
        maxPtDist.initialize();
        final int numSubSegs = 0;
        for (final Segment segment : discreteGeom.segments()) {
            final double x1 = segment.getX(0);
            final double y1 = segment.getY(0);
            final double x2 = segment.getX(1);
            final double y2 = segment.getY(1);
            final double delx = (x2 - x1) / numSubSegs;
            final double dely = (y2 - y1) / numSubSegs;
            for (int i = 0; i < numSubSegs; i++) {
                final double x = x1 + i * delx;
                final double y = y1 + i * dely;
                final Point pt = new PointDoubleXY(x, y);
                minPtDist.initialize();
                DistanceToPoint.computeDistance(geom, pt, minPtDist);
                maxPtDist.setMaximum(minPtDist);
            }
        }
        ptDist.setMaximum(maxPtDist);
    }
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point) Segment(com.revolsys.geometry.model.segment.Segment)

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