Exemplo n.º 1
0
 private static Polygon findPolygonContaining(Geometry geom, Coordinate pt) {
   PointLocator locator = new PointLocator();
   for (int i = 0; i < geom.getNumGeometries(); i++) {
     Polygon poly = (Polygon) geom.getGeometryN(i);
     int loc = locator.locate(pt, poly);
     if (loc == Location.INTERIOR) return poly;
   }
   return null;
 }
  /**
   * Tests whether a geometry consists of a single polygon with no holes.
   *
   * @return true if the geometry is a single polygon with no holes
   */
  private boolean isSingleShell(Geometry geom) {
    // handles single-element MultiPolygons, as well as Polygons
    if (geom.getNumGeometries() != 1) return false;

    Polygon poly = (Polygon) geom.getGeometryN(0);
    int numHoles = poly.getNumInteriorRing();
    if (numHoles == 0) return true;
    return false;
  }
Exemplo n.º 3
0
  public static List extractElements(Geometry geom, boolean skipEmpty) {
    List elem = new ArrayList();
    if (geom == null) return elem;

    for (int i = 0; i < geom.getNumGeometries(); i++) {
      Geometry elemGeom = geom.getGeometryN(i);
      if (skipEmpty && elemGeom.isEmpty()) continue;
      elem.add(elemGeom);
    }
    return elem;
  }