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

项目:Earth    文件:CascadedPolygonUnion.java   
private Geometry unionOptimized(Geometry g0, Geometry g1) {
        Envelope g0Env = g0.getEnvelopeInternal();
        Envelope g1Env = g1.getEnvelopeInternal();
        //*
        if (!g0Env.intersects(g1Env)) {
            Geometry combo = GeometryCombiner.combine(g0, g1);
//          System.out.println("Combined");
//          System.out.println(combo);
            return combo;
        }
        //*/
//      System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries());

        if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) {
            return this.unionActual(g0, g1);
        }

        // for testing...
//      if (true) return g0.union(g1);

        Envelope commonEnv = g0Env.intersection(g1Env);
        return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv);

//      return UnionInteracting.union(g0, g1);
    }
项目:jts    文件:CascadedPolygonUnion.java   
private Geometry unionOptimized(Geometry g0, Geometry g1) {
        Envelope g0Env = g0.getEnvelopeInternal();
        Envelope g1Env = g1.getEnvelopeInternal();
        //*
        if (!g0Env.intersects(g1Env)) {
            Geometry combo = GeometryCombiner.combine(g0, g1);
//          System.out.println("Combined");
//          System.out.println(combo);
            return combo;
        }
        //*/
//      System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries());

        if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1)
            return unionActual(g0, g1);

        // for testing...
//      if (true) return g0.union(g1);

        Envelope commonEnv = g0Env.intersection(g1Env);
        return unionUsingEnvelopeIntersection(g0, g1, commonEnv);

//      return UnionInteracting.union(g0, g1);
    }
项目:Earth    文件:PointGeometryUnion.java   
public Geometry union() {
    PointLocator locater = new PointLocator();
    // use a set to eliminate duplicates, as required for union
    Set exteriorCoords = new TreeSet();

    for (int i = 0; i < this.pointGeom.getNumGeometries(); i++) {
        Point point = (Point) this.pointGeom.getGeometryN(i);
        Coordinate coord = point.getCoordinate();
        int loc = locater.locate(coord, this.otherGeom);
        if (loc == Location.EXTERIOR) {
            exteriorCoords.add(coord);
        }
    }

    // if no points are in exterior, return the other geom
    if (exteriorCoords.size() == 0) {
        return this.otherGeom;
    }

    // make a puntal geometry of appropriate size
    Geometry ptComp = null;
    Coordinate[] coords = CoordinateArrays.toCoordinateArray(exteriorCoords);
    if (coords.length == 1) {
        ptComp = this.geomFact.createPoint(coords[0]);
    } else {
        ptComp = this.geomFact.createMultiPoint(coords);
    }

    // add point component to the other geometry
    return GeometryCombiner.combine(ptComp, this.otherGeom);
}
项目:jts    文件:PointGeometryUnion.java   
public Geometry union() {
    PointLocator locater = new PointLocator();
    // use a set to eliminate duplicates, as required for union
    Set exteriorCoords = new TreeSet();

    for (int i = 0; i < pointGeom.getNumGeometries(); i++) {
        Point point = (Point) pointGeom.getGeometryN(i);
        Coordinate coord = point.getCoordinate();
        int loc = locater.locate(coord, otherGeom);
        if (loc == Location.EXTERIOR)
            exteriorCoords.add(coord);
    }

    // if no points are in exterior, return the other geom
    if (exteriorCoords.size() == 0)
        return otherGeom;

    // make a puntal geometry of appropriate size
    Geometry ptComp = null;
    Coordinate[] coords = CoordinateArrays.toCoordinateArray(exteriorCoords);
    if (coords.length == 1) {
        ptComp = geomFact.createPoint(coords[0]);
    } else {
        ptComp = geomFact.createMultiPoint(coords);
    }

    // add point component to the other geometry
    return GeometryCombiner.combine(ptComp, otherGeom);
}
项目:sig-seguimiento-vehiculos    文件:AbstractJTSService.java   
protected List<String> getOverlay(final List<String> wktLayer1,
        final List<String> wktLayer2, final int op) {
    final Geometry layer1 = GeometryCombiner.combine(getList(wktLayer1));
    final Geometry layer2 = GeometryCombiner.combine(getList(wktLayer2));
    return topologicalOverlay.getOverlay(layer1, layer2, op);
}
项目:geowe-core    文件:AbstractJTSService.java   
protected List<String> getOverlay(final List<String> wktLayer1,
        final List<String> wktLayer2, final int op) {
    final Geometry layer1 = GeometryCombiner.combine(getList(wktLayer1));
    final Geometry layer2 = GeometryCombiner.combine(getList(wktLayer2));
    return topologicalOverlay.getOverlay(layer1, layer2, op);
}
项目:Earth    文件:CascadedPolygonUnion.java   
/**
     * Unions two polygonal geometries, restricting computation
     * to the envelope intersection where possible.
     * The case of MultiPolygons is optimized to union only
     * the polygons which lie in the intersection of the two geometry's envelopes.
     * Polygons outside this region can simply be combined with the union result,
     * which is potentially much faster.
     * This case is likely to occur often during cascaded union, and may also
     * occur in real world data (such as unioning data for parcels on different street blocks).
     *
     * @param g0 a polygonal geometry
     * @param g1 a polygonal geometry
     * @param common the intersection of the envelopes of the inputs
     * @return the union of the inputs
     */
    private Geometry unionUsingEnvelopeIntersection(Geometry g0, Geometry g1, Envelope common) {
        List disjointPolys = new ArrayList();

        Geometry g0Int = this.extractByEnvelope(common, g0, disjointPolys);
        Geometry g1Int = this.extractByEnvelope(common, g1, disjointPolys);

//      System.out.println("# geoms in common: " + intersectingPolys.size());
        Geometry union = this.unionActual(g0Int, g1Int);

        disjointPolys.add(union);
        Geometry overallUnion = GeometryCombiner.combine(disjointPolys);

        return overallUnion;
    }
项目:jts    文件:CascadedPolygonUnion.java   
/**
     * Unions two polygonal geometries, restricting computation
     * to the envelope intersection where possible.
     * The case of MultiPolygons is optimized to union only
     * the polygons which lie in the intersection of the two geometry's envelopes.
     * Polygons outside this region can simply be combined with the union result,
     * which is potentially much faster.
     * This case is likely to occur often during cascaded union, and may also
     * occur in real world data (such as unioning data for parcels on different street blocks).
     *
     * @param g0     a polygonal geometry
     * @param g1     a polygonal geometry
     * @param common the intersection of the envelopes of the inputs
     * @return the union of the inputs
     */
    private Geometry unionUsingEnvelopeIntersection(Geometry g0, Geometry g1, Envelope common) {
        List disjointPolys = new ArrayList();

        Geometry g0Int = extractByEnvelope(common, g0, disjointPolys);
        Geometry g1Int = extractByEnvelope(common, g1, disjointPolys);

//      System.out.println("# geoms in common: " + intersectingPolys.size());
        Geometry union = unionActual(g0Int, g1Int);

        disjointPolys.add(union);
        Geometry overallUnion = GeometryCombiner.combine(disjointPolys);

        return overallUnion;
    }