Search in sources :

Example 21 with PointDoubleXY

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

the class PolygonGenerator method newArc.

private static LinearRing newArc(final double cx, final double cy, final double radius, final int npoints, final GeometryFactory gf) {
    final Point[] coords = new Point[npoints + 1];
    final double theta = 360 / npoints;
    for (int i = 0; i < npoints; i++) {
        final double angle = Math.toRadians(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));
    }
    coords[npoints] = coords[0];
    return gf.linearRing(coords);
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 22 with PointDoubleXY

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

the class LinearLocationTest method testRepeatedCoordsLineString.

public void testRepeatedCoordsLineString() throws Exception {
    final Geometry line = this.geometryFactory.geometry("LINESTRING (10 0, 10 0, 20 0)");
    final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
    final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(11, 0));
    assertTrue(loc0.compareTo(new LinearLocation(1, 0.1)) == 0);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LocationIndexedLine(com.revolsys.geometry.linearref.LocationIndexedLine) LinearLocation(com.revolsys.geometry.linearref.LinearLocation) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 23 with PointDoubleXY

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

the class LinearLocationTest method testSameSegmentLineString.

public void testSameSegmentLineString() throws Exception {
    final Geometry line = this.geometryFactory.geometry("LINESTRING (0 0, 10 0, 20 0, 30 0)");
    final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
    final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(0, 0));
    final LinearLocation loc0_5 = indexedLine.indexOf(new PointDoubleXY(5, 0));
    final LinearLocation loc1 = indexedLine.indexOf(new PointDoubleXY(10, 0));
    final LinearLocation loc2 = indexedLine.indexOf(new PointDoubleXY(20, 0));
    final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
    final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
    assertTrue(loc0.isOnSameSegment(loc0));
    assertTrue(loc0.isOnSameSegment(loc0_5));
    assertTrue(loc0.isOnSameSegment(loc1));
    assertTrue(!loc0.isOnSameSegment(loc2));
    assertTrue(!loc0.isOnSameSegment(loc2_5));
    assertTrue(!loc0.isOnSameSegment(loc3));
    assertTrue(loc0_5.isOnSameSegment(loc0));
    assertTrue(loc0_5.isOnSameSegment(loc1));
    assertTrue(!loc0_5.isOnSameSegment(loc2));
    assertTrue(!loc0_5.isOnSameSegment(loc3));
    assertTrue(!loc2.isOnSameSegment(loc0));
    assertTrue(loc2.isOnSameSegment(loc1));
    assertTrue(loc2.isOnSameSegment(loc2));
    assertTrue(loc2.isOnSameSegment(loc3));
    assertTrue(loc2_5.isOnSameSegment(loc3));
    assertTrue(!loc3.isOnSameSegment(loc0));
    assertTrue(loc3.isOnSameSegment(loc2));
    assertTrue(loc3.isOnSameSegment(loc2_5));
    assertTrue(loc3.isOnSameSegment(loc3));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LocationIndexedLine(com.revolsys.geometry.linearref.LocationIndexedLine) LinearLocation(com.revolsys.geometry.linearref.LinearLocation) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 24 with PointDoubleXY

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

the class LinearLocationTest method testGetSegmentMultiLineString.

public void testGetSegmentMultiLineString() throws Exception {
    final Geometry line = this.geometryFactory.geometry("MULTILINESTRING ((0 0, 10 0, 20 0), (20 0, 30 0))");
    final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
    final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(0, 0));
    final LinearLocation loc0_5 = indexedLine.indexOf(new PointDoubleXY(5, 0));
    final LinearLocation loc1 = indexedLine.indexOf(new PointDoubleXY(10, 0));
    final LinearLocation loc2 = indexedLine.indexOf(new PointDoubleXY(20, 0));
    final LinearLocation loc2B = new LinearLocation(1, 0, 0.0);
    final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
    final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
    final LineSegment seg0 = new LineSegmentDouble(new PointDoubleXY(0, 0), new PointDoubleXY(10, 0));
    final LineSegment seg1 = new LineSegmentDouble(new PointDoubleXY(10, 0), new PointDoubleXY(20, 0));
    final LineSegment seg2 = new LineSegmentDouble(new PointDoubleXY(20, 0), new PointDoubleXY(30, 0));
    assertTrue(loc0.getSegment(line).equals(seg0));
    assertTrue(loc0_5.getSegment(line).equals(seg0));
    assertTrue(loc1.getSegment(line).equals(seg1));
    assertTrue(loc2.getSegment(line).equals(seg1));
    assertTrue(loc2_5.getSegment(line).equals(seg2));
    assertTrue(loc3.getSegment(line).equals(seg2));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) LineSegmentDouble(com.revolsys.geometry.model.segment.LineSegmentDouble) LocationIndexedLine(com.revolsys.geometry.linearref.LocationIndexedLine) LinearLocation(com.revolsys.geometry.linearref.LinearLocation) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) LineSegment(com.revolsys.geometry.model.segment.LineSegment)

Example 25 with PointDoubleXY

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

the class LineIntersectorBenchmark method exerciseOnce.

private void exerciseOnce(final LineIntersector lineIntersector) {
    Point p1 = new PointDoubleXY(10.0, 10);
    Point p2 = new PointDoubleXY(20.0, 20);
    Point q1 = new PointDoubleXY(20.0, 10);
    Point q2 = new PointDoubleXY(10.0, 20);
    final Point x = new PointDoubleXY(15.0, 15);
    lineIntersector.computeIntersectionPoints(p1, p2, q1, q2);
    lineIntersector.getIntersectionCount();
    lineIntersector.getIntersection(0);
    lineIntersector.isProper();
    lineIntersector.hasIntersection();
    p1 = new PointDoubleXY(10.0, 10);
    p2 = new PointDoubleXY(20.0, 10);
    q1 = new PointDoubleXY(22.0, 10);
    q2 = new PointDoubleXY(30.0, 10);
    lineIntersector.computeIntersectionPoints(p1, p2, q1, q2);
    lineIntersector.isProper();
    lineIntersector.hasIntersection();
    p1 = new PointDoubleXY(10.0, 10);
    p2 = new PointDoubleXY(20.0, 10);
    q1 = new PointDoubleXY(20.0, 10);
    q2 = new PointDoubleXY(30.0, 10);
    lineIntersector.computeIntersectionPoints(p1, p2, q1, q2);
    lineIntersector.isProper();
    lineIntersector.hasIntersection();
    p1 = new PointDoubleXY(10.0, 10);
    p2 = new PointDoubleXY(20.0, 10);
    q1 = new PointDoubleXY(15.0, 10);
    q2 = new PointDoubleXY(30.0, 10);
    lineIntersector.computeIntersectionPoints(p1, p2, q1, q2);
    lineIntersector.isProper();
    lineIntersector.hasIntersection();
    p1 = new PointDoubleXY(30.0, 10);
    p2 = new PointDoubleXY(20.0, 10);
    q1 = new PointDoubleXY(10.0, 10);
    q2 = new PointDoubleXY(30.0, 10);
    lineIntersector.computeIntersectionPoints(p1, p2, q1, q2);
    lineIntersector.hasIntersection();
    lineIntersector.computeIntersectionPoints(new PointDoubleXY(100.0, 100), new PointDoubleXY(10.0, 100), new PointDoubleXY(100.0, 10), new PointDoubleXY(100.0, 100));
    lineIntersector.hasIntersection();
    lineIntersector.getIntersectionCount();
    lineIntersector.computeIntersectionPoints(new PointDoubleXY(190.0, 50), new PointDoubleXY(120.0, 100), new PointDoubleXY(120.0, 100), new PointDoubleXY(50.0, 150));
    lineIntersector.hasIntersection();
    lineIntersector.getIntersectionCount();
    lineIntersector.getIntersection(1);
    lineIntersector.computeIntersectionPoints(new PointDoubleXY(180.0, 200), new PointDoubleXY(160.0, 180), new PointDoubleXY(220.0, 240), new PointDoubleXY(140.0, 160));
    lineIntersector.hasIntersection();
    lineIntersector.getIntersectionCount();
    lineIntersector.computeIntersectionPoints(new PointDoubleXY(30.0, 10), new PointDoubleXY(30.0, 30), new PointDoubleXY(10.0, 10), new PointDoubleXY(90.0, 11));
    lineIntersector.hasIntersection();
    lineIntersector.getIntersectionCount();
    lineIntersector.isProper();
    lineIntersector.computeIntersectionPoints(new PointDoubleXY(10.0, 30), new PointDoubleXY(10.0, 0), new PointDoubleXY(11.0, 90), new PointDoubleXY(10.0, 10));
    lineIntersector.hasIntersection();
    lineIntersector.getIntersectionCount();
    lineIntersector.isProper();
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

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