Search in sources :

Example 11 with PointDouble

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

the class CoordinateTest method testCopyConstructor3D.

public void testCopyConstructor3D() {
    final Point orig = new PointDouble(350.2, 4566.8, 5266.3);
    final Point c = orig;
    assertEquals(c, 350.2, 4566.8, 5266.3);
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) Point(com.revolsys.geometry.model.Point)

Example 12 with PointDouble

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

the class CoordinateTest method testEquals2DWithinTolerance.

public void testEquals2DWithinTolerance() {
    final Point c = new PointDouble(100.0, 200.0, 50.0);
    final Point aBitOff = new PointDouble(100.1, 200.1, 50.0);
    assertTrue(c.equalsVertex2d(aBitOff, 0.2));
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) Point(com.revolsys.geometry.model.Point)

Example 13 with PointDouble

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

the class KdTreeTest method testSinglePoint.

public void testSinglePoint() {
    final KdTree index = new KdTree(GeometryFactory.fixed2d(0, 1000, 1000));
    final KdNode node1 = index.insertPoint(new PointDouble(1, 1));
    final KdNode node2 = index.insertPoint(new PointDouble(1, 1));
    assertTrue("Inserting 2 identical points should create one node", node1 == node2);
    final BoundingBox queryEnv = new BoundingBoxDoubleXY(0, 0, 10, 10);
    final List result = index.getItems(queryEnv);
    assertTrue(result.size() == 1);
    final KdNode node = (KdNode) result.get(0);
    assertTrue(node.getCount() == 2);
    assertTrue(node.isRepeated());
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) KdTree(com.revolsys.geometry.index.kdtree.KdTree) BoundingBox(com.revolsys.geometry.model.BoundingBox) KdNode(com.revolsys.geometry.index.kdtree.KdNode) List(java.util.List) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 14 with PointDouble

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

the class KmlGeometryReader method parseCoordinates.

private LineString parseCoordinates() throws XMLStreamException {
    this.in.requireLocalName(COORDINATES);
    final String coordinatesListString = this.in.getElementText();
    if (Property.hasValue(coordinatesListString)) {
        int axisCount = 2;
        final String[] coordinatesListArray = coordinatesListString.trim().split("\\s+");
        final List<Point> points = new ArrayList<>();
        for (final String coordinatesString : coordinatesListArray) {
            final String[] coordinatesArray = coordinatesString.split(",");
            final double[] coordinates = new double[coordinatesArray.length];
            for (int axisIndex = 0; axisIndex < coordinatesArray.length; axisIndex++) {
                final String coordinate = coordinatesArray[axisIndex];
                coordinates[axisIndex] = Double.valueOf(coordinate);
            }
            axisCount = Math.max(axisCount, coordinates.length);
            points.add(new PointDouble(coordinates));
        }
        this.in.skipToEndElement();
        return new LineStringDouble(axisCount, points);
    } else {
        return null;
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) ArrayList(java.util.ArrayList) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble)

Example 15 with PointDouble

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

the class CoordinatesUtil method setElevation.

static Point setElevation(final Point newLocation, final Point originalLocation) {
    if (originalLocation.getAxisCount() > 2) {
        final double z = originalLocation.getZ();
        if (Double.isNaN(z)) {
            return newLocation;
        } else {
            final double[] points = originalLocation.getCoordinates();
            points[2] = z;
            final Point newCoordinates = new PointDouble(points);
            return newCoordinates;
        }
    } else {
        return newLocation;
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) Point(com.revolsys.geometry.model.Point)

Aggregations

PointDouble (com.revolsys.geometry.model.impl.PointDouble)24 Point (com.revolsys.geometry.model.Point)22 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 Test (org.junit.Test)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 ArrayList (java.util.ArrayList)2 KdNode (com.revolsys.geometry.index.kdtree.KdNode)1 KdTree (com.revolsys.geometry.index.kdtree.KdTree)1 LineString (com.revolsys.geometry.model.LineString)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)1 List (java.util.List)1