use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class LinearLocationTest method testGetSegmentMultiLineString.
public void testGetSegmentMultiLineString() throws Exception {
final Geometry line = this.geometryFactory.geometry("MULTILINESTRING ((0 0, 10 0, 20 0), (20 0, 30 0))");
final LocationIndexedLine indexedLine = new LocationIndexedLine(line);
final LinearLocation loc0 = indexedLine.indexOf(new PointDoubleXY(0, 0));
final LinearLocation loc0_5 = indexedLine.indexOf(new PointDoubleXY(5, 0));
final LinearLocation loc1 = indexedLine.indexOf(new PointDoubleXY(10, 0));
final LinearLocation loc2 = indexedLine.indexOf(new PointDoubleXY(20, 0));
final LinearLocation loc2B = new LinearLocation(1, 0, 0.0);
final LinearLocation loc2_5 = indexedLine.indexOf(new PointDoubleXY(25, 0));
final LinearLocation loc3 = indexedLine.indexOf(new PointDoubleXY(30, 0));
final LineSegment seg0 = new LineSegmentDouble(new PointDoubleXY(0, 0), new PointDoubleXY(10, 0));
final LineSegment seg1 = new LineSegmentDouble(new PointDoubleXY(10, 0), new PointDoubleXY(20, 0));
final LineSegment seg2 = new LineSegmentDouble(new PointDoubleXY(20, 0), new PointDoubleXY(30, 0));
assertTrue(loc0.getSegment(line).equals(seg0));
assertTrue(loc0_5.getSegment(line).equals(seg0));
assertTrue(loc1.getSegment(line).equals(seg1));
assertTrue(loc2.getSegment(line).equals(seg1));
assertTrue(loc2_5.getSegment(line).equals(seg2));
assertTrue(loc3.getSegment(line).equals(seg2));
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class TestUtil method doTestGeometry.
public static void doTestGeometry(final Class<?> clazz, final String file) {
boolean valid = true;
final Resource resource = new ClassPathResource(file, clazz);
try (Reader<Record> reader = RecordReader.newRecordReader(resource)) {
int i = 0;
for (final Record object : reader) {
final int srid = object.getInteger("srid");
final int axisCount = object.getInteger("axisCount");
final double scaleXy = object.getInteger("scaleXy");
final double scaleZ = object.getInteger("scaleZ");
final double[] scales = { scaleXy, scaleXy, scaleZ };
final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scales);
final String wkt = object.getValue("wkt");
final Geometry geometry = geometryFactory.geometry(wkt);
valid &= equalsExpectedWkt(i, object, geometry);
final CoordinateSystem coordinateSystem = geometry.getCoordinateSystem();
GeometryFactory otherGeometryFactory;
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
final ProjectedCoordinateSystem projectedCoordinateSystem = (ProjectedCoordinateSystem) coordinateSystem;
otherGeometryFactory = GeometryFactory.fixed(projectedCoordinateSystem.getCoordinateSystemId(), axisCount, scales);
} else {
otherGeometryFactory = GeometryFactory.fixed(3005, axisCount, scales);
}
final Geometry convertedGeometry = geometry.convertGeometry(otherGeometryFactory);
final Geometry convertedBackGeometry = convertedGeometry.convertGeometry(geometryFactory);
valid &= equalsExpectedGeometry(i, convertedBackGeometry, geometry);
i++;
}
}
if (!valid) {
Assert.fail("Has Errors");
}
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class ConvexHullTest method test6.
public void test6() throws Exception {
final Punctual inputGeometry = GEOMETRY_FACTORY_1M.punctual(2, 0, 0, 5, 1, 10, 0);
final Geometry actualGeometry = inputGeometry.convexHull();
final Geometry expectedGeometry = GEOMETRY_FACTORY_1M.geometry("POLYGON((0 0,5 1,10 0,0 0))");
assertEquals(expectedGeometry.toString(), actualGeometry.toString());
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class ConvexHullTest method test5.
public void test5() throws Exception {
final Geometry geometry = GEOMETRY_FACTORY_1M.punctual(2, 0, 0, 5, 0, 10, 0);
final LineString convexHull = (LineString) GEOMETRY_FACTORY_1M.geometry("LINESTRING(0 0,10 0)");
assertTrue(convexHull.equals(2, geometry.convexHull()));
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class ConvexHullTest method testAllIdenticalPoints.
public void testAllIdenticalPoints() throws Exception {
final List<Point> points = new ArrayList<>();
for (int i = 0; i < 100; i++) {
points.add(new PointDoubleXY(0.0, 0));
}
final Geometry actualGeometry = ConvexHull.convexHull(this.geometryFactory, points);
final Geometry expectedGeometry = this.geometryFactory.geometry("POINT(0 0)");
assertTrue(expectedGeometry.equals(2, actualGeometry));
}
Aggregations