Search in sources :

Example 6 with Location

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Label(com.revolsys.geometry.geomgraph.Label) Location(com.revolsys.geometry.model.Location)

Example 7 with 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());
}
Also used : Location(com.revolsys.geometry.model.Location)

Example 8 with Location

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());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Location(com.revolsys.geometry.model.Location)

Example 9 with Location

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) PointLocator(com.revolsys.geometry.algorithm.PointLocator) Location(com.revolsys.geometry.model.Location)

Example 10 with Location

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);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) PointLocator(com.revolsys.geometry.algorithm.PointLocator) Point(com.revolsys.geometry.model.Point) Location(com.revolsys.geometry.model.Location)

Aggregations

Location (com.revolsys.geometry.model.Location)26 Point (com.revolsys.geometry.model.Point)7 Geometry (com.revolsys.geometry.model.Geometry)5 PointLocator (com.revolsys.geometry.algorithm.PointLocator)2 Edge (com.revolsys.geometry.geomgraph.Edge)2 EdgeIntersection (com.revolsys.geometry.geomgraph.EdgeIntersection)2 LineString (com.revolsys.geometry.model.LineString)2 PointOnGeometryLocator (com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)1 EdgeEnd (com.revolsys.geometry.geomgraph.EdgeEnd)1 Label (com.revolsys.geometry.geomgraph.Label)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 TopologyException (com.revolsys.geometry.model.TopologyException)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 Stopwatch (com.revolsys.geometry.util.Stopwatch)1 Iterator (java.util.Iterator)1