Java Code Examples for org.locationtech.jts.geom.Geometry#within()

The following examples show how to use org.locationtech.jts.geom.Geometry#within() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VectorLayer.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Select a shape by point
 *
 * @param p The point
 * @return Selected shape
 */
public Shape selectShape(PointD p) {
    Coordinate c = new Coordinate(p.X, p.Y);
    Geometry point = new GeometryFactory().createPoint(c);
    for (Shape shape : _shapeList) {
        if (point.within(shape.toGeometry())) {
            return shape;
        }
    }
    return null;
}
 
Example 2
Source File: Shape.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * If this shape within another one
 * @param other Other shape
 * @return Within or not
 */
public boolean within(Shape other){
    Geometry g1 = this.toGeometry();
    Geometry g2 = other.toGeometry();
    return g1.within(g2);
}
 
Example 3
Source File: GeoWaveFunctions.java    From datawave with Apache License 2.0 4 votes vote down vote up
public static boolean within(Object fieldValue, String geoString) {
    Geometry otherGeom = AbstractGeometryNormalizer.parseGeometry(geoString);
    Geometry thisGeom = getGeometryFromFieldValue(fieldValue);
    return thisGeom.within(otherGeom);
}
 
Example 4
Source File: GeomWithin.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(final Geometry geom1, final Geometry geom2) {
  return geom1.within(geom2);
}