use of com.revolsys.geometry.model.metrics.PointLineStringMetrics in project com.revolsys.open by revolsys.
the class LineStringTest method assertDistanceAlong.
private static void assertDistanceAlong(final double distanceAlong, final double distance, final double x, final double y, final Side side, final double... coordinates) {
final GeometryFactory geometryFactory = GeometryFactory.worldMercator().convertAxisCount(2);
final Point point = geometryFactory.point(x, y);
final LineString line = geometryFactory.lineString(2, coordinates);
final double actual = line.distanceAlong(point);
Assert.assertEquals("Distance Along", distanceAlong, actual, 0.0000001);
final PointLineStringMetrics metrics = line.getMetrics(point);
Assert.assertEquals("Metrics Distance Along", distanceAlong, metrics.getDistanceAlong(), 0.0000001);
Assert.assertEquals("Metrics Distance", distance, metrics.getDistance(), 0.0000001);
Assert.assertEquals("Metrics Side", side, metrics.getSide());
Assert.assertEquals("Metrics Length", line.getLength(), metrics.getLineLength(), 0.0000001);
Assert.assertEquals("Distance Along -> Metrics", distanceAlong, metrics.getDistanceAlong(), 0.0000001);
if (side != null) {
final Side reverseSide = Side.opposite(side);
final LineString reverseLine = line.reverse();
final PointLineStringMetrics reverseMetrics = reverseLine.getMetrics(point);
Assert.assertEquals("Reverse Metrics Side", reverseSide, reverseMetrics.getSide());
}
}
Aggregations