Esempio n. 1
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;
  }
Esempio n. 2
0
  public Geometry combine(Geometry orig, Geometry geom) {
    List origList = extractElements(orig, true);
    List geomList = extractElements(geom, true);
    origList.addAll(geomList);

    if (origList.size() == 0) {
      // return a clone of the orig geometry
      return (Geometry) orig.clone();
    }
    // return the "simplest possible" geometry
    return geomFactory.buildGeometry(origList);
  }