Search in sources :

Example 86 with PointDoubleXY

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

the class PointInAreaStressTester method run.

/**
 * @return true if all point locations were computed correctly
 */
public boolean run() {
    final Stopwatch sw = new Stopwatch();
    // default is to use the simple, non-indexed tester
    if (this.pia2 == null) {
        this.pia2 = new SimplePointInAreaLocator(this.area);
    }
    final int ptGridWidth = (int) Math.sqrt(this.numPts);
    final BoundingBox areaEnv = this.area.getBoundingBox();
    final double xStep = areaEnv.getWidth() / (ptGridWidth - 1);
    final double yStep = areaEnv.getHeight() / (ptGridWidth - 1);
    for (int i = 0; i < ptGridWidth; i++) {
        for (int j = 0; j < ptGridWidth; j++) {
            // compute test point
            final double x = this.geomFactory.makePrecise(0, areaEnv.getMinX() + i * xStep);
            final double y = this.geomFactory.makePrecise(1, areaEnv.getMinY() + j * yStep);
            final Point pt = new PointDoubleXY(x, y);
            final boolean isEqual = testPIA(pt);
            if (!isEqual) {
                return false;
            }
        }
    }
    // System.out.println("Test completed in " + sw.getTimeString());
    printStats();
    return true;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Stopwatch(com.revolsys.geometry.util.Stopwatch) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) SimplePointInAreaLocator(com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator) Point(com.revolsys.geometry.model.Point)

Example 87 with PointDoubleXY

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

the class WKBTest method testBigPolygon.

public void testBigPolygon() throws IOException, ParseException {
    final GeometricShapeFactory shapeFactory = new GeometricShapeFactory(this.geomFactory);
    shapeFactory.setBase(new PointDoubleXY(0, 0));
    shapeFactory.setSize(1000);
    shapeFactory.setNumPoints(1000);
    final Geometry geom = shapeFactory.newRectangle();
    runWKBTest(geom, 2, false);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometricShapeFactory(com.revolsys.geometry.util.GeometricShapeFactory) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 88 with PointDoubleXY

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

the class WKTReaderTest method testReadLargeNumbers.

public void testReadLargeNumbers() throws Exception {
    final GeometryFactory geometryFactory = GeometryFactory.fixed2d(0, 1E9, 1E9);
    final WKTReader reader = new WKTReader(geometryFactory);
    final Geometry point1 = reader.read("POINT(123456789.01234567890 10)");
    final Point point2 = geometryFactory.point(new PointDoubleXY(123456789.01234567890, 10));
    assertEquals(point1.getPoint().getX(), point2.getPoint().getX(), 1E-7);
    assertEquals(point1.getPoint().getY(), point2.getPoint().getY(), 1E-7);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) WKTReader(com.revolsys.geometry.wkb.WKTReader)

Example 89 with PointDoubleXY

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

the class MiscellaneousTest2 method testCoordinateHash.

public void testCoordinateHash() {
    doTestCoordinateHash(true, new PointDoubleXY(1, 2), new PointDoubleXY(1, 2));
    doTestCoordinateHash(false, new PointDoubleXY(1, 2), new PointDoubleXY(3, 4));
    doTestCoordinateHash(false, new PointDoubleXY(1, 2), new PointDoubleXY(1, 4));
    doTestCoordinateHash(false, new PointDoubleXY(1, 2), new PointDoubleXY(3, 2));
    doTestCoordinateHash(false, new PointDoubleXY(1, 2), new PointDoubleXY(2, 1));
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 90 with PointDoubleXY

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

the class MiscellaneousTest2 method testDirectedEdgeComparator.

public void testDirectedEdgeComparator() {
    final DirectedEdge d1 = new DirectedEdge(new Node(0, 0), new Node(10, 10), new PointDoubleXY(10, 10), true);
    final DirectedEdge d2 = new DirectedEdge(new Node(0, 0), new Node(20, 20), new PointDoubleXY(20, 20), false);
    assertEquals(0, d2.compareTo(d1));
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) Node(com.revolsys.geometry.planargraph.Node) 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