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

项目:sumo    文件:JTSUtil.java   
/** */
public static Geometry flatten (GeometryCollection gc) {
    final List<Point> points = new LinkedList<Point>();
    final List<LineString> lines = new LinkedList<LineString>();
    final List<Polygon> polygons = new LinkedList<Polygon>();
    gc.apply(new GeometryFilter() {
            public void filter (Geometry geom) {
                if (geom instanceof Point) {
                    points.add((Point)geom);
                } else if (geom instanceof LineString) {
                    lines.add((LineString)geom);
                } else if (geom instanceof Polygon) {
                    polygons.add((Polygon)geom);
                }
            }
        });
    if (!polygons.isEmpty()) {
        return gc.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
    } else if (!lines.isEmpty()) {
        return gc.getFactory().createMultiLineString(GeometryFactory.toLineStringArray(lines));
    } else {
        return gc.getFactory().createMultiPoint(GeometryFactory.toPointArray(points));
    }
}
项目:modelingcommons    文件:JTSUtils.java   
/** */
public static Geometry flatten (GeometryCollection gc) {
    final List<Point> points = new LinkedList<Point>();
    final List<LineString> lines = new LinkedList<LineString>();
    final List<Polygon> polygons = new LinkedList<Polygon>();
    gc.apply(new GeometryFilter() {
            public void filter (Geometry geom) {
                if (geom instanceof Point) {
                    points.add((Point)geom);
                } else if (geom instanceof LineString) {
                    lines.add((LineString)geom);
                } else if (geom instanceof Polygon) {
                    polygons.add((Polygon)geom);
                }
            }
        });
    if (!polygons.isEmpty()) {
        return gc.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
    } else if (!lines.isEmpty()) {
        return gc.getFactory().createMultiLineString(GeometryFactory.toLineStringArray(lines));
    } else {
        return gc.getFactory().createMultiPoint(GeometryFactory.toPointArray(points));
    }
}
项目:gama    文件:GeometryUtils.java   
public static void applyToInnerGeometries(final Polygon g, final GeometryFilter f) {
    final int holes = g.getNumInteriorRing();
    if (holes == 0)
        return;
    for (int i = 0; i < holes; i++) {
        g.getInteriorRingN(i).apply(f);
    }
}
项目:gama    文件:GeometryUtils.java   
public static void applyToInnerGeometries(final GeometryCollection g, final GeometryFilter f) {
    final int geoms = g.getNumGeometries();
    if (geoms == 0)
        return;
    for (int i = 0; i < geoms; i++) {
        final Geometry sub = g.getGeometryN(i);
        sub.apply(f);
    }
}
项目:gama    文件:DynamicLineString.java   
@Override
public void apply(final GeometryFilter filter) {
    filter.filter(this);
}
项目:gama    文件:GeometryCache.java   
void drawSimpleGeometry(final OpenGL gl, final Geometry geom) throws ExecutionException {
    geom.apply((GeometryFilter) (g) -> drawer.accept(g));
}
项目:GeoSpark    文件:Circle.java   
@Override
public void apply(GeometryFilter filter) {
    // Do nothing. This circle is not expected to be a complete geometry.       
}
项目:gama    文件:GeometryUtils.java   
/**
 * Applies a GeometryComponentFilter to internal geometries. Concerns the geometries contained in multi-geometries,
 * and the holes in polygons. Limited to one level (i.e. holes in polygons in a MultiPolygon will not be visited)
 * 
 * @param g
 *            the geometry to visit
 * @param f
 *            the filter to apply
 */
public static void applyToInnerGeometries(final Geometry g, final GeometryFilter f) {
    if (g instanceof Polygon)
        applyToInnerGeometries((Polygon) g, f);
    else if (g instanceof GeometryCollection) {
        applyToInnerGeometries((GeometryCollection) g, f);
    }
}