use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class OverlayOp method labelIncompleteNode.
/**
* Label an isolated node with its relationship to the target geometry.
*/
private void labelIncompleteNode(final Node node, final int targetIndex) {
final Geometry geometry = this.arg[targetIndex].getGeometry();
final double x = node.getX();
final double y = node.getY();
final Location location = this.ptLocator.locate(geometry, x, y);
final Label label = node.getLabel();
label.setLocation(targetIndex, location);
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class RelateComputer method labelIsolatedEdge.
/**
* Label an isolated edge of a graph with its relationship to the target geometry.
* If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
* If the target has dim 0, the edge must be in the exterior
*/
private void labelIsolatedEdge(final Edge edge, final int targetIndex, final Geometry target) {
// this won't work for GeometryCollections with both dim 2 and 1 geoms
if (target.getDimension() > 0) {
// since edge is not in boundary, may not need the full generality of
// PointLocator?
// Possibly should use ptInArea locator instead? We probably know here
// that the edge does not touch the bdy of the target Geometry
final double x = edge.getX(0);
final double y = edge.getY(0);
final Location loc = this.ptLocator.locate(target, x, y);
edge.getLabel().setAllLocations(targetIndex, loc);
} else {
edge.getLabel().setAllLocations(targetIndex, Location.EXTERIOR);
}
// System.out.println(e.getLabel());
}
use of com.revolsys.geometry.model.Location in project com.revolsys.open by revolsys.
the class RelateComputer method labelIsolatedNode.
/**
* Label an isolated node with its relationship to the target geometry.
*/
private void labelIsolatedNode(final Node n, final int targetIndex) {
final Geometry geometry = this.arg[targetIndex].getGeometry();
final double x = n.getX();
final double y = n.getY();
final Location loc = this.ptLocator.locate(geometry, x, y);
n.getLabel().setAllLocations(targetIndex, loc);
// debugPrintln(n.getLabel());
}
use of com.revolsys.geometry.model.Location 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.model.Location 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);
}
}
Aggregations