Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryCollection


            return null;
        if (clip == null)
            return null;

        // its a GC
        GeometryCollection gc = (GeometryCollection) clip;
        List<Polygon> polys = new ArrayList<Polygon>();
        Geometry g;
        for (int t = 0; t < gc.getNumGeometries(); t++) {
            g = gc.getGeometryN(t);
            if (g instanceof Polygon)
                polys.add((Polygon) g);
            // dont think multiPolygon is possible, but not sure
        }
View Full Code Here


                        if (intersection instanceof LineString) {
                            LineString ils = ((LineString) intersection);
                            double d = getGeodeticSegmentLength(ils);
                            distance += d;
                        } else if (intersection instanceof GeometryCollection) {
                            GeometryCollection igc = ((GeometryCollection) intersection);
                            for (int k = 0; k < igc.getNumGeometries(); k++) {
                                Geometry child = igc.getGeometryN(k);
                                if (child instanceof LineString) {
                                    double d = getGeodeticSegmentLength((LineString) child);
                                    distance += d;
                                }
                            }
View Full Code Here

     */
    public static Geometry getCentroid(Geometry g) {
        if(g instanceof Point || g instanceof MultiPoint) {
            return g;
        } else if (g instanceof GeometryCollection) {
            final GeometryCollection gc = (GeometryCollection) g;
            final Coordinate[] pts = new Coordinate[gc.getNumGeometries()];
            final int length = gc.getNumGeometries();
            for (int t = 0; t < length; t++) {
                pts[t] = pointInGeometry(gc.getGeometryN(t)).getCoordinate();
            }
            return g.getFactory().createMultiPoint(pts);
        } else if (g != null) {
            return pointInGeometry(g);
        }
View Full Code Here

   
    protected <T> void accumulateGeometries(List<T> collection, Geometry g, Class<? extends T> target) {
        if(target.isInstance(g)) {
            collection.add((T) g);
        } else if(g instanceof GeometryCollection) {
            GeometryCollection coll = (GeometryCollection) g;
            for (int i = 0; i < coll.getNumGeometries(); i++) {
                accumulateGeometries(collection, coll.getGeometryN(i), target);
            }
        }
    }
View Full Code Here

    private void validateOGCUnitUsage(double distance, String unit) throws Exception {
        Coordinate coordinate = new Coordinate(-110, 30);
        GeometryFactory factory = new GeometryFactory();
        Point point = factory.createPoint(coordinate);
        Geometry[] geometries = {point};
        GeometryCollection geometry = new GeometryCollection(geometries, factory );

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);

        PropertyName geomName = ff.property(aname("geo"));
        Literal lit = ff.literal(geometry);
View Full Code Here

            union[i] = firstArrayGeometry[i];
        }
        for (int i = 0; i < secondArrayGeometry.length; i++) {
            union[i + 5] = secondArrayGeometry[i];
        }
        GeometryCollection unionCollection = new GeometryCollection(union, new GeometryFactory());
        SimpleFeatureIterator iterator = output.features();

        for (int h = 0; h < unionCollection.getNumGeometries(); h++) {
            Geometry expected = (Geometry) unionCollection.getGeometryN(h);
            SimpleFeature sf = iterator.next();
            assertTrue(expected.equals((Geometry) sf.getDefaultGeometry()));
        }
    }
View Full Code Here

    private void flattenCollection(List<Geometry> result) {
    for (int i = 0; i < result.size();) {
      Geometry g = result.get(i);
      if(g instanceof GeometryCollection) {
        GeometryCollection gc = (GeometryCollection) g;
        for (int j = 0; j < gc.getNumGeometries(); j++) {
          result.add(gc.getGeometryN(j));
        }
        result.remove(i);
      } else {
        i++;
      }
View Full Code Here

            return EmptyIterator.INSTANCE;
        if (g instanceof Polygon) {
            Polygon p = (Polygon) g;
            pi = new PolygonIterator(p, at, generalize, maxDistance);
        } else if (g instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection) g;
            pi = new GeomCollectionIterator(gc, at, generalize, maxDistance);
        } else if (g instanceof LineString || g instanceof LinearRing) {
            LineString ls = (LineString) g;
            pi = new LineIterator(ls, at, generalize, (float) maxDistance);
        } else if (g instanceof Point) {
View Full Code Here

              !(att.value instanceof MultiLineString) &&
              !(att.value instanceof MultiPolygon) ) {
           
            if ( value instanceof GeometryCollection ) {
                //compare the two collections
                GeometryCollection c1 = (GeometryCollection) value;
                GeometryCollection c2 = (GeometryCollection) att.value;
               
                if ( c1.getNumGeometries() !=  c2.getNumGeometries() ) {
                    return false;
                }
               
                for ( int i = 0; i < c1.getNumGeometries(); i++ ) {
                    Geometry g1 = c1.getGeometryN(i);
                    Geometry g2 = c2.getGeometryN(i);
                   
                    if ( !g1.equalsExact(g2) ) {
                        return false;
                    }
                }
View Full Code Here

    if (mathTransform == null || mathTransform.isIdentity())
      return;

    if (geometry instanceof GeometryCollection) {
      GeometryCollection collection = (GeometryCollection) geometry;
      for (int i = 0; i < collection.getNumGeometries(); i++) {
        transformGeometry(collection.getGeometryN(i));
      }
    } else if (geometry instanceof Point) {
      LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry)
          .getCoordinateSequence();
      double[] coords = seq.getArray();
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.GeometryCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.