Java 类com.vividsolutions.jts.geom.GeometryCollectionIterator 实例源码

项目:Earth    文件:SimplePointInAreaLocator.java   
private static boolean containsPoint(Coordinate p, Geometry geom) {
    if (geom instanceof Polygon) {
        return containsPointInPolygon(p, (Polygon) geom);
    } else if (geom instanceof GeometryCollection) {
        Iterator geomi = new GeometryCollectionIterator(geom);
        while (geomi.hasNext()) {
            Geometry g2 = (Geometry) geomi.next();
            if (g2 != geom) {
                if (containsPoint(p, g2)) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:Flox    文件:Model.java   
/**
 * Finds an OGC simple feature that contains a point.
 *
 * @param geometry A geometry or geometry collection to search through.
 * @param point The point for which a containing geometry is to be searched.
 * @param f A JTS GeometryFactory
 * @return The found containing geometry or null if none is found.
 */
private Geometry findContainingGeometry(Geometry geometry,
        Point point, GeometryFactory f) {
    if (geometry == null) {
        return null;
    }

    Coordinate coordinate = new Coordinate(point.x, point.y);
    com.vividsolutions.jts.geom.Point p = f.createPoint(coordinate);

    Iterator geomi = new GeometryCollectionIterator(geometry);
    while (geomi.hasNext()) {
        Geometry g = (Geometry) geomi.next();
        if (g instanceof GeometryCollection == false && p.within(g)) {
            return g;
        }
    }

    return null;
}
项目:Earth    文件:PointLocator.java   
private void computeLocation(Coordinate p, Geometry geom) {
    if (geom instanceof Point) {
        this.updateLocationInfo(this.locate(p, (Point) geom));
    }
    if (geom instanceof LineString) {
        this.updateLocationInfo(this.locate(p, (LineString) geom));
    } else if (geom instanceof Polygon) {
        this.updateLocationInfo(this.locate(p, (Polygon) geom));
    } else if (geom instanceof MultiLineString) {
        MultiLineString ml = (MultiLineString) geom;
        for (int i = 0; i < ml.getNumGeometries(); i++) {
            LineString l = (LineString) ml.getGeometryN(i);
            this.updateLocationInfo(this.locate(p, l));
        }
    } else if (geom instanceof MultiPolygon) {
        MultiPolygon mpoly = (MultiPolygon) geom;
        for (int i = 0; i < mpoly.getNumGeometries(); i++) {
            Polygon poly = (Polygon) mpoly.getGeometryN(i);
            this.updateLocationInfo(this.locate(p, poly));
        }
    } else if (geom instanceof GeometryCollection) {
        Iterator geomi = new GeometryCollectionIterator(geom);
        while (geomi.hasNext()) {
            Geometry g2 = (Geometry) geomi.next();
            if (g2 != geom) {
                this.computeLocation(p, g2);
            }
        }
    }
}
项目:jeql    文件:GeomFunction.java   
public static int numInteriorRings(Geometry geom) 
{ 
  int intRingCount = 0;
  GeometryCollectionIterator it = new GeometryCollectionIterator(geom);
  while (it.hasNext()) {
    Geometry g = (Geometry) it.next();
    if (g instanceof Polygon) {
      intRingCount += ((Polygon) g).getNumInteriorRing();
    }
  }
  return intRingCount; 
}