Search in sources :

Example 16 with PointDoubleXY

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

the class RobustLineIntersectorTest method testIsProper2.

public void testIsProper2() {
    this.i.computeIntersectionPoints(new PointDoubleXY(10, 30), new PointDoubleXY(10, 0), new PointDoubleXY(11, 90), new PointDoubleXY(10, 10));
    assertTrue(this.i.hasIntersection());
    assertEquals(1, this.i.getIntersectionCount());
    assertTrue(!this.i.isProper());
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 17 with PointDoubleXY

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

the class EdgeGraphTest method testNode.

public void testNode() throws Exception {
    final EdgeGraph graph = build("MULTILINESTRING((0 0, 1 0), (0 0, 0 1), (0 0, -1 0))");
    checkEdgeRing(graph, new PointDoubleXY(0, 0), new Point[] { new PointDoubleXY(1, 0), new PointDoubleXY(0, 1), new PointDoubleXY(-1, 0) });
    checkEdge(graph, new PointDoubleXY(0, 0), new PointDoubleXY(1, 0));
}
Also used : EdgeGraph(com.revolsys.geometry.edgegraph.EdgeGraph) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 18 with PointDoubleXY

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

the class JTSFunctions method newS.

private static Geometry newS(final Geometry g) {
    final GeometryFactory gf = FunctionsUtil.getFactoryOrDefault(g);
    final double centreX = WIDTH - S_RADIUS;
    final Point[] top = new Point[] { new PointDoubleXY(WIDTH, HEIGHT), new PointDoubleXY(centreX, HEIGHT) };
    final Point[] bottom = new Point[] { new PointDoubleXY(centreX, 0), new PointDoubleXY(WIDTH - 2 * S_RADIUS, 0) };
    final GeometricShapeFactory gsf = new GeometricShapeFactory(gf);
    gsf.setCentre(new PointDoubleXY(centreX, HEIGHT - S_RADIUS));
    gsf.setSize(2 * S_RADIUS);
    gsf.setNumPoints(10);
    final LineString arcTop = gsf.newArc(0.5 * Math.PI, Math.PI);
    final GeometricShapeFactory gsf2 = new GeometricShapeFactory(gf);
    gsf2.setCentre(new PointDoubleXY(centreX, S_RADIUS));
    gsf2.setSize(2 * S_RADIUS);
    gsf2.setNumPoints(10);
    final LineString arcBottom = gsf2.newArc(1.5 * Math.PI, Math.PI).reverse();
    final PointList coordList = new PointList();
    coordList.add(top, false);
    coordList.add(CoordinatesListUtil.getPointArray(arcTop), false, 1, arcTop.getVertexCount() - 1);
    coordList.add(new PointDoubleXY(centreX, HEIGHT / 2));
    coordList.add(CoordinatesListUtil.getPointArray(arcBottom), false, 1, arcBottom.getVertexCount() - 1);
    coordList.add(bottom, false);
    return gf.lineString(coordList.toPointArray());
}
Also used : PointList(com.revolsys.geometry.model.PointList) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeometricShapeFactory(com.revolsys.geometry.util.GeometricShapeFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 19 with PointDoubleXY

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

the class PreparedPolygonIntersectsStressTest method run.

public void run(final int nPts) {
    // Geometry poly = newCircle(new BaseLasPoint((double)0, 0), 100, nPts);
    final Geometry poly = newSineStar(new PointDoubleXY(0, 0), 100, nPts);
    // System.out.println(poly);
    // 
    // System.out.println();
    // System.out.println("Running with " + nPts + " points");
    test(poly);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 20 with PointDoubleXY

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

the class PolygonGenerator method newBox.

private static LinearRing newBox(final double x, final double dx, final double y, final double dy, final int npoints, final GeometryFactory gf) {
    // figure out the number of points per side
    final int ptsPerSide = npoints / 4;
    int rPtsPerSide = npoints % 4;
    final Point[] coords = new Point[npoints + 1];
    // start
    coords[0] = new PointDoubleXY(gf.makePrecise(0, x), gf.makePrecise(1, y));
    final int cindex = 1;
    for (int i = 0; i < 4; i++) {
        // sides
        final int npts = ptsPerSide + (rPtsPerSide-- > 0 ? 1 : 0);
        if (i % 2 == 1) {
            // odd vert
            double cy = dy / npts;
            if (i > 1) {
                cy *= -1;
            }
            final double tx = coords[cindex - 1].getX();
            final double sy = coords[cindex - 1].getY();
            for (int j = 0; j < npts; j++) {
                coords[cindex] = new PointDoubleXY(gf.makePrecise(0, tx), gf.makePrecise(1, sy + (j + 1) * cy));
            }
        } else {
            // even horz
            double cx = dx / npts;
            if (i > 1) {
                cx *= -1;
            }
            final double ty = coords[cindex - 1].getY();
            final double sx = coords[cindex - 1].getX();
            for (int j = 0; j < npts; j++) {
                coords[cindex] = new PointDoubleXY(gf.makePrecise(0, sx + (j + 1) * cx), gf.makePrecise(1, ty));
            }
        }
    }
    // end
    coords[npoints] = new PointDoubleXY(gf.makePrecise(0, x), gf.makePrecise(1, y));
    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)

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