use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class TriangleTest method checkCentroid.
public void checkCentroid(final String wkt, final Point expectedValue) throws Exception {
final Geometry g = this.geometryFactory.geometry(wkt);
final TriangleImpl t = newTriangle(g);
Point centroid = Triangles.centroid(t.p0, t.p1, t.p2);
// System.out.println("(Static) centroid = " + centroid);
assertEquals(expectedValue.toString(), centroid.toString());
// Test Instance version
//
centroid = t.centroid();
// System.out.println("(Instance) centroid = " + centroid.toString());
assertEquals(expectedValue.toString(), centroid.toString());
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class PreparedPolygonPredicateStressTest method checkContains.
public boolean checkContains(final Geometry target, final Geometry test) {
final boolean expectedResult = target.contains(test);
final Geometry prepGeom = target.prepare();
final boolean prepResult = prepGeom.contains(test);
if (prepResult != expectedResult) {
return false;
}
return true;
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class STRtreeTest method testQuery.
public void testQuery() throws Throwable {
final ArrayList geometries = new ArrayList();
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(0, 0), new PointDoubleXY(10, 10) }));
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
final STRtreeDemo.TestTree t = new STRtreeDemo.TestTree(4);
for (final Iterator i = geometries.iterator(); i.hasNext(); ) {
final Geometry g = (Geometry) i.next();
t.insertItem(g.getBoundingBox(), new Object());
}
t.build();
try {
assertEquals(1, t.getItems(new BoundingBoxDoubleXY(5, 5, 6, 6)).size());
assertEquals(0, t.getItems(new BoundingBoxDoubleXY(20, 0, 30, 10)).size());
assertEquals(2, t.getItems(new BoundingBoxDoubleXY(25, 25, 26, 26)).size());
assertEquals(3, t.getItems(new BoundingBoxDoubleXY(0, 0, 100, 100)).size());
} catch (final Throwable x) {
STRtreeDemo.printSourceData(geometries, System.out);
STRtreeDemo.printLevels(t, System.out);
throw x;
}
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class CascadedPolygonUnionTester method unionIterated.
public Geometry unionIterated(final Collection<? extends Polygon> polygons) {
Geometry unionAll = null;
int count = 0;
for (final Polygon polygon : polygons) {
if (unionAll == null) {
unionAll = polygon.clone();
} else {
unionAll = unionAll.union(polygon);
}
count++;
if (count % 100 == 0) {
System.out.print(".");
}
}
return unionAll;
}
use of com.revolsys.geometry.model.Geometry in project com.revolsys.open by revolsys.
the class IsValidTest method testNaNCoordinate.
public void testNaNCoordinate() throws Exception {
final Point badCoord = new PointDoubleXY(1.0, Double.NaN);
final Point[] pts = { new PointDoubleXY(0.0, 0.0), badCoord };
final Geometry line = this.geometryFactory.lineString(pts);
final IsValidOp isValidOp = new IsValidOp(line);
final boolean valid = isValidOp.isValid();
final GeometryValidationError err = isValidOp.getValidationError();
final Point errCoord = err.getErrorPoint();
assertTrue(err instanceof CoordinateNaNError);
assertTrue(Double.isNaN(errCoord.getY()));
assertEquals(false, valid);
}
Aggregations