Search in sources :

Example 6 with PointDoubleXY

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

the class CoordinatesTest method testClone.

public void testClone() {
    for (final Point point : // 
    Arrays.asList(// 
    new PointDoubleXY(100.0, 200.0), // 
    new PointDoubleXYZ(100.0, 200.0, 50.0), new PointDouble(100.0, 200.0, 50.0, 4.0))) {
        final Point clone = point.newPoint();
        assertEquals3d(point, clone);
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 7 with PointDoubleXY

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

the class PolygonTest method testVertices.

@Test
public void testVertices() {
    final List<Point> allCoordinates = new ArrayList<>();
    allCoordinates.addAll(EXTERIOR_1);
    allCoordinates.addAll(INTERIOR_2);
    final Polygon polygon = WITH_HOLE;
    int i = 0;
    for (final Vertex vertex : polygon.vertices()) {
        final Point point = allCoordinates.get(i);
        Assert.assertEquals(point, vertex);
        i++;
    }
    Assert.assertEquals(new PointDoubleXY(0.0, 0.0), polygon.getVertex(0, 0));
    Assert.assertNull("VertexIndex out of range", polygon.getVertex(0, 6));
    Assert.assertNull("VertexIndex out of range", polygon.getVertex(1, 6));
    Assert.assertNull("RingIndex Negative", polygon.getVertex(-1, 0));
    Assert.assertNull("RingIndex out of range", polygon.getVertex(2, 0));
}
Also used : Vertex(com.revolsys.geometry.model.vertex.Vertex) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) Polygon(com.revolsys.geometry.model.Polygon) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Example 8 with PointDoubleXY

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

the class AbstractPointInRingTest method testRepeatedPts.

/**
 * Tests that repeated points are handled correctly
 * @throws Exception
 */
public void testRepeatedPts() throws Exception {
    runPtInRing(Location.BOUNDARY, new PointDoubleXY(0.0, 0), repeatedPts);
    runPtInRing(Location.BOUNDARY, new PointDoubleXY(0.0, 1), repeatedPts);
    // at vertex
    runPtInRing(Location.BOUNDARY, new PointDoubleXY(2.0, 5), repeatedPts);
    runPtInRing(Location.BOUNDARY, new PointDoubleXY(8.0, 5), repeatedPts);
    runPtInRing(Location.BOUNDARY, new PointDoubleXY(10.0, 5), repeatedPts);
    runPtInRing(Location.INTERIOR, new PointDoubleXY(1.0, 5), repeatedPts);
    runPtInRing(Location.INTERIOR, new PointDoubleXY(3.0, 5), repeatedPts);
}
Also used : PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 9 with PointDoubleXY

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

the class AffineTransformationTest method checkTransformation.

/**
 * Checks that a transformation produces the expected result
 * @param x the input pt x
 * @param y the input pt y
 * @param trans the transformation
 * @param xp the expected output x
 * @param yp the expected output y
 */
void checkTransformation(final double x, final double y, final AffineTransformation trans, final double xp, final double yp) {
    final Point p = new PointDoubleXY(x, y);
    final Point p2 = trans.transform(p);
    assertEquals(xp, p2.getX(), .00005);
    assertEquals(yp, p2.getY(), .00005);
    // if the transformation is invertible, test the inverse
    try {
        final AffineTransformation invTrans = trans.getInverse();
        final Point pInv = invTrans.transform(p2);
        assertEquals(x, pInv.getX(), .00005);
        assertEquals(y, pInv.getY(), .00005);
        final double det = trans.getDeterminant();
        final double detInv = invTrans.getDeterminant();
        assertEquals(det, 1.0 / detInv, .00005);
    } catch (final NoninvertibleTransformationException ex) {
    }
}
Also used : NoninvertibleTransformationException(com.revolsys.geometry.model.util.NoninvertibleTransformationException) AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 10 with PointDoubleXY

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

the class GeometryTestFactory method newCircle.

/**
 * Creates a circle
 * @param basex the centre x coord
 * @param basey the centre y coord
 * @param size the size of the envelope of the star
 * @param nPts the number of points in the star
 */
public static Point[] newCircle(final double basex, final double basey, final double size, final int nPts) {
    final Point[] pts = new Point[nPts + 1];
    int iPt = 0;
    final double len = size / 2.0;
    for (int i = 0; i < nPts; i++) {
        final double ang = i * (2 * Math.PI / nPts);
        final double x = len * Math.cos(ang) + basex;
        final double y = len * Math.sin(ang) + basey;
        final Point pt = new PointDoubleXY(x, y);
        pts[iPt++] = pt;
    }
    pts[iPt] = pts[0];
    return pts;
}
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