Java 类com.vividsolutions.jts.geom.util.PolygonExtracter 实例源码

项目:Bread    文件:NativeInset.java   
public static ArrayList<ArrayList<Point2D>> jtsInset(double d, ArrayList<Loop> ls){
    MultiPolygon mp = ToMultiPoly(ls);
    BufferOp bf = new BufferOp(mp);
    bf.setQuadrantSegments(5);
    Geometry g = bf.getResultGeometry(d);
    @SuppressWarnings("unchecked")
    List<Polygon> polies = (List<Polygon>)PolygonExtracter.getPolygons(g);
    ArrayList<ArrayList<Point2D>> output = new  ArrayList<ArrayList<Point2D>>();
    for(Polygon p : polies){
        int num = p.getNumInteriorRing();
        output.add(conv(p.getExteriorRing()));
        for(int i=0;i<num;i++)output.add(conv(p.getInteriorRingN(i)));
    }
    if(output.size()==0) return null;
    for(ArrayList<Point2D> ps : output){
        if(ps.size()==0) continue;
        for(int i=0;i<ps.size()-1;i++){
            try{ while(Utils2D.equiv(ps.get(i), ps.get(i+1))) ps.remove(i);
            } catch(IndexOutOfBoundsException e){
                break;
            }
        }
    }
    return output;
}
项目:Earth    文件:BufferDistanceValidator.java   
private Geometry getPolygonLines(Geometry g) {
    List lines = new ArrayList();
    LinearComponentExtracter lineExtracter = new LinearComponentExtracter(lines);
    List polys = PolygonExtracter.getPolygons(g);
    for (Object poly1 : polys) {
        Polygon poly = (Polygon) poly1;
        poly.apply(lineExtracter);
    }
    return g.getFactory().buildGeometry(lines);
}
项目:Earth    文件:DistanceOp.java   
private void computeContainmentDistance(int polyGeomIndex, GeometryLocation[] locPtPoly) {
    int locationsIndex = 1 - polyGeomIndex;
    List polys = PolygonExtracter.getPolygons(this.geom[polyGeomIndex]);
    if (polys.size() > 0) {
        List insideLocs = ConnectedElementLocationFilter.getLocations(this.geom[locationsIndex]);
        this.computeContainmentDistance(insideLocs, polys, locPtPoly);
        if (this.minDistance <= this.terminateDistance) {
            // this assigment is determined by the order of the args in the computeInside call above
            this.minDistanceLocation[locationsIndex] = locPtPoly[0];
            this.minDistanceLocation[polyGeomIndex] = locPtPoly[1];
        }
    }
}
项目:jts    文件:BufferDistanceValidator.java   
private Geometry getPolygonLines(Geometry g) {
    List lines = new ArrayList();
    LinearComponentExtracter lineExtracter = new LinearComponentExtracter(lines);
    List polys = PolygonExtracter.getPolygons(g);
    for (Iterator i = polys.iterator(); i.hasNext(); ) {
        Polygon poly = (Polygon) i.next();
        poly.apply(lineExtracter);
    }
    return g.getFactory().buildGeometry(lines);
}
项目:jts    文件:DistanceOp.java   
private void computeContainmentDistance(int polyGeomIndex, GeometryLocation[] locPtPoly) {
    int locationsIndex = 1 - polyGeomIndex;
    List polys = PolygonExtracter.getPolygons(geom[polyGeomIndex]);
    if (polys.size() > 0) {
        List insideLocs = ConnectedElementLocationFilter.getLocations(geom[locationsIndex]);
        computeContainmentDistance(insideLocs, polys, locPtPoly);
        if (minDistance <= terminateDistance) {
            // this assigment is determined by the order of the args in the computeInside call above
            minDistanceLocation[locationsIndex] = locPtPoly[0];
            minDistanceLocation[polyGeomIndex] = locPtPoly[1];
            return;
        }
    }
}
项目:Earth    文件:CascadedPolygonUnion.java   
/**
 * Computes a {@link Geometry} containing only {@link Polygonal} components.
 * Extracts the {@link Polygon}s from the input
 * and returns them as an appropriate {@link Polygonal} geometry.
 * <p>
 * If the input is already <tt>Polygonal</tt>, it is returned unchanged.
 * <p>
 * A particular use case is to filter out non-polygonal components
 * returned from an overlay operation.
 *
 * @param g the geometry to filter
 * @return a Polygonal geometry
 */
private static Geometry restrictToPolygons(Geometry g) {
    if (g instanceof Polygonal) {
        return g;
    }
    List polygons = PolygonExtracter.getPolygons(g);
    if (polygons.size() == 1) {
        return (Polygon) polygons.get(0);
    }
    return g.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
}
项目:jts    文件:CascadedPolygonUnion.java   
/**
 * Computes a {@link Geometry} containing only {@link Polygonal} components.
 * Extracts the {@link Polygon}s from the input
 * and returns them as an appropriate {@link Polygonal} geometry.
 * <p/>
 * If the input is already <tt>Polygonal</tt>, it is returned unchanged.
 * <p/>
 * A particular use case is to filter out non-polygonal components
 * returned from an overlay operation.
 *
 * @param g the geometry to filter
 * @return a Polygonal geometry
 */
private static Geometry restrictToPolygons(Geometry g) {
    if (g instanceof Polygonal) {
        return g;
    }
    List polygons = PolygonExtracter.getPolygons(g);
    if (polygons.size() == 1)
        return (Polygon) polygons.get(0);
    return g.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
}