use of com.revolsys.geometry.algorithm.PointLocator in project com.revolsys.open by revolsys.
the class PointLocatorTest method runPtLocator.
private void runPtLocator(final Location expected, final Point pt, final String wkt) throws Exception {
final Geometry geom = this.geometryFactory.geometry(wkt);
final PointLocator pointLocator = new PointLocator();
final double x = pt.getX();
final double y = pt.getY();
final Location loc = pointLocator.locate(geom, x, y);
assertEquals(expected, loc);
}
use of com.revolsys.geometry.algorithm.PointLocator in project com.revolsys.open by revolsys.
the class UnaryUnionOp method union.
public static Geometry union(final Punctual punctual, final Geometry otherGeom) {
final PointLocator locater = new PointLocator();
Set<Geometry> exteriorGeometries = null;
for (final Point point : punctual.points()) {
final Location loc = locater.locate(otherGeom, point);
if (loc == Location.EXTERIOR) {
if (exteriorGeometries == null) {
exteriorGeometries = new TreeSet<>();
}
exteriorGeometries.add(point);
}
}
if (exteriorGeometries == null) {
return otherGeom;
} else {
for (final Geometry geometry : otherGeom.geometries()) {
exteriorGeometries.add(geometry);
}
final GeometryFactory geomFactory = otherGeom.getGeometryFactory();
return geomFactory.geometry(exteriorGeometries);
}
}
use of com.revolsys.geometry.algorithm.PointLocator in project com.revolsys.open by revolsys.
the class MiscellaneousTest2 method testPointLocator.
public void testPointLocator() throws Exception {
final PointLocator pointLocator = new PointLocator();
final Geometry polygon = this.geometryFactory.geometry("POLYGON ((70 340, 430 50, 70 50, 70 340))");
assertEquals(Location.EXTERIOR, pointLocator.locate(polygon, 420, 340));
assertEquals(Location.BOUNDARY, pointLocator.locate(polygon, 350, 50));
assertEquals(Location.BOUNDARY, pointLocator.locate(polygon, 410, 50));
assertEquals(Location.INTERIOR, pointLocator.locate(polygon, 190, 150));
}
use of com.revolsys.geometry.algorithm.PointLocator in project com.revolsys.open by revolsys.
the class MiscellaneousTest2 method testPointLocatorLinearRingLineString.
public void testPointLocatorLinearRingLineString() throws Exception {
final PointLocator pointLocator = new PointLocator();
final Geometry gc = this.geometryFactory.geometry("GEOMETRYCOLLECTION( LINESTRING(0 0, 10 10), LINEARRING(10 10, 10 20, 20 10, 10 10))");
assertEquals(Location.BOUNDARY, pointLocator.locate(gc, 10.0, 10.0));
}
Aggregations