Search in sources :

Example 31 with PointDoubleXY

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

the class RectanglePredicateSyntheticTest method newAngle.

public Geometry newAngle(final Point base, final double size, final int quadrant) {
    final int[][] factor = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
    final int xFac = factor[quadrant][0];
    final int yFac = factor[quadrant][1];
    final Point p0 = new PointDoubleXY(base.getX() + xFac * size, base.getY() + yFac * size);
    final Point p2 = new PointDoubleXY(base.getX() + yFac * size, base.getY() + -xFac * size);
    return this.fact.lineString(new Point[] { p0, base, p2 });
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Point(com.revolsys.geometry.model.Point)

Example 32 with PointDoubleXY

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

the class RectanglePredicateSyntheticTest method newTestGeometries.

public List<Geometry> newTestGeometries(final BoundingBox env, final double inc, final double size) {
    final List<Geometry> testGeoms = new ArrayList<>();
    for (double y = env.getMinY(); y <= env.getMaxY(); y += inc) {
        for (double x = env.getMinX(); x <= env.getMaxX(); x += inc) {
            final Point base = new PointDoubleXY(x, y);
            testGeoms.add(newAngle(base, size, 0));
            testGeoms.add(newAngle(base, size, 1));
            testGeoms.add(newAngle(base, size, 2));
            testGeoms.add(newAngle(base, size, 3));
        }
    }
    return testGeoms;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 33 with PointDoubleXY

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

the class STRtreeTest method testQuery.

public void testQuery() throws Throwable {
    final ArrayList geometries = new ArrayList();
    geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(0, 0), new PointDoubleXY(10, 10) }));
    geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
    geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
    final STRtreeDemo.TestTree t = new STRtreeDemo.TestTree(4);
    for (final Iterator i = geometries.iterator(); i.hasNext(); ) {
        final Geometry g = (Geometry) i.next();
        t.insertItem(g.getBoundingBox(), new Object());
    }
    t.build();
    try {
        assertEquals(1, t.getItems(new BoundingBoxDoubleXY(5, 5, 6, 6)).size());
        assertEquals(0, t.getItems(new BoundingBoxDoubleXY(20, 0, 30, 10)).size());
        assertEquals(2, t.getItems(new BoundingBoxDoubleXY(25, 25, 26, 26)).size());
        assertEquals(3, t.getItems(new BoundingBoxDoubleXY(0, 0, 100, 100)).size());
    } catch (final Throwable x) {
        STRtreeDemo.printSourceData(geometries, System.out);
        STRtreeDemo.printLevels(t, System.out);
        throw x;
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 34 with PointDoubleXY

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

the class SegmentPointComparatorFullTest method computePoint.

private Point computePoint(final LineSegment seg, final double dist) {
    final double dx = seg.getP1().getX() - seg.getP0().getX();
    final double dy = seg.getP1().getY() - seg.getP0().getY();
    final double len = seg.getLength();
    final Point pt = new PointDoubleXY(Doubles.makePrecise(1.0, dist * dx / len), Doubles.makePrecise(1.0, dist * dy / len));
    return pt;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 35 with PointDoubleXY

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

the class IsValidTest method testNaNCoordinate.

public void testNaNCoordinate() throws Exception {
    final Point badCoord = new PointDoubleXY(1.0, Double.NaN);
    final Point[] pts = { new PointDoubleXY(0.0, 0.0), badCoord };
    final Geometry line = this.geometryFactory.lineString(pts);
    final IsValidOp isValidOp = new IsValidOp(line);
    final boolean valid = isValidOp.isValid();
    final GeometryValidationError err = isValidOp.getValidationError();
    final Point errCoord = err.getErrorPoint();
    assertTrue(err instanceof CoordinateNaNError);
    assertTrue(Double.isNaN(errCoord.getY()));
    assertEquals(false, valid);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryValidationError(com.revolsys.geometry.operation.valid.GeometryValidationError) CoordinateNaNError(com.revolsys.geometry.operation.valid.CoordinateNaNError) IsValidOp(com.revolsys.geometry.operation.valid.IsValidOp) 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