Search in sources :

Example 1 with PointLocator

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

Example 2 with PointLocator

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);
    }
}
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)

Example 3 with PointLocator

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

Example 4 with PointLocator

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

Aggregations

PointLocator (com.revolsys.geometry.algorithm.PointLocator)4 Geometry (com.revolsys.geometry.model.Geometry)4 Location (com.revolsys.geometry.model.Location)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Point (com.revolsys.geometry.model.Point)1