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);
}
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));
}
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());
}
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;
}
}
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;
}
}
Aggregations