use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class LineSegmentTest method testDistancePointLinePerpendicular.
public void testDistancePointLinePerpendicular() {
final LineSegmentDouble segment = new LineSegmentDouble(2, 0.0, 0, 1.0, 0);
Assert.assertEquals(0.5, segment.distancePerpendicular(new PointDoubleXY(0.5, 0.5)), 0.000001);
Assert.assertEquals(0.5, segment.distancePerpendicular(new PointDoubleXY(3.5, 0.5)), 0.000001);
Assert.assertEquals(0.707106, segment.distancePerpendicular(new PointDoubleXY(1.0, 0)), 0.000001);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class DelaunayPerfTest method randomPointsInGrid.
List<Point> randomPointsInGrid(final int nPts) {
final List<Point> pts = new ArrayList<>();
final int nSide = (int) Math.sqrt(nPts) + 1;
for (int i = 0; i < nSide; i++) {
for (int j = 0; j < nSide; j++) {
final double x = i * SIDE_LEN + SIDE_LEN * Math.random();
final double y = j * SIDE_LEN + SIDE_LEN * Math.random();
pts.add(new PointDoubleXY(x, y));
}
}
return pts;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class GeoNamesService method mapToObjects.
private List<Record> mapToObjects(final RecordDefinition recordDefinition, final Map<String, Object> result) {
final List<Record> results = new ArrayList<>();
final List<Map<String, Object>> names = (List<Map<String, Object>>) result.get("geonames");
for (final Map<String, Object> name : names) {
final Record record = recordDefinition.newRecord();
for (final String fieldName : recordDefinition.getFieldNames()) {
final Object value = name.get(fieldName);
if (value != null) {
record.setValue(fieldName, value);
}
}
final double lat = ((Number) name.get("lat")).doubleValue();
final double lon = ((Number) name.get("lng")).doubleValue();
Point coordinate = new PointDoubleXY(lon, lat);
final Number elevation = (Number) name.get("elevation");
if (elevation == null) {
coordinate = new PointDoubleXY(lon, lat);
} else {
coordinate = new PointDoubleXYZ(lon, lat, elevation.doubleValue());
}
record.setGeometryValue(GeometryFactory.DEFAULT_3D.point(coordinate));
results.add(record);
}
return results;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class SplitSegment method pointAlongReverse.
/**
* Computes the {@link Coordinates} that lies a given fraction along the line defined by the
* reverse of the given segment. A fraction of <code>0.0</code> returns the end point of the
* segment; a fraction of <code>1.0</code> returns the start point of the segment.
*
* @param seg the LineSegmentDouble
* @param segmentLengthFraction the fraction of the segment length along the line
* @return the point at that distance
*/
private static Point pointAlongReverse(final LineSegment seg, final double segmentLengthFraction) {
final double x = seg.getP1().getX() - segmentLengthFraction * (seg.getP1().getX() - seg.getP0().getX());
final double y = seg.getP1().getY() - segmentLengthFraction * (seg.getP1().getY() - seg.getP0().getY());
final Point coord = new PointDoubleXY(x, y);
return coord;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class ConvexHull method getUniquePoints.
private static Set<Point> getUniquePoints(final Iterable<? extends Point> points) {
final Set<Point> set = new HashSet<>();
for (final Point point : points) {
final Point point2d = new PointDoubleXY(point);
set.add(point2d);
}
return set;
}
Aggregations