Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryCollection


         */
        Coordinate geometryCentroid(Geometry g) {
            // TODO: should the collection case return the centroid of the
            // multi point?
            if (g instanceof GeometryCollection) {
                GeometryCollection gc = (GeometryCollection) g;

                // check for case of single geometry
                if (gc.getNumGeometries() == 1) {
                    g = gc.getGeometryN(0);
                } else {
                    double maxAreaSoFar = gc.getGeometryN(0).getArea();
                    Coordinate centroidToReturn = gc.getGeometryN(0).getCentroid().getCoordinate();

                    for (int t = 0; t < gc.getNumGeometries(); t++) {
                        double area = gc.getGeometryN(t).getArea();
                        if (area > maxAreaSoFar) {
                            maxAreaSoFar = area;
                            centroidToReturn = gc.getGeometryN(t).getCentroid().getCoordinate();
                        }
                    }

                    return centroidToReturn;
                }
View Full Code Here


         * @param styles
         */
        protected void encodeGeometry(Geometry geometry, List<Symbolizer> symbolizers) {
            if (geometry instanceof GeometryCollection) {
                // unwrap the collection
                GeometryCollection collection = (GeometryCollection) geometry;

                for (int i = 0; i < collection.getNumGeometries(); i++) {
                    encodeGeometry(collection.getGeometryN(i), symbolizers);
                }
            } else if(geometry instanceof Point) {
                Coordinate centroid = ((Point) geometry).getCoordinate();
                start("Point");
               
View Full Code Here

  }

  public final void decimateTransformGeneralize(Geometry geometry,
      MathTransform transform) throws TransformException {
    if (geometry instanceof GeometryCollection) {
      GeometryCollection collection = (GeometryCollection) geometry;
      final int length = collection.getNumGeometries();
      for (int i = 0; i < length; i++) {
        decimateTransformGeneralize(collection.getGeometryN(i),
            transform);
      }
    } else if (geometry instanceof Point) {
      LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry)
          .getCoordinateSequence();
View Full Code Here

    if (geom instanceof GeometryCollection) {
      // TODO check geometry and if its bbox is too small turn it into a
      // 1-2 point geom
      // takes a bit of work because the geometry will need to be
      // recreated.
      GeometryCollection collection = (GeometryCollection) geom;
      Geometry[] result=new Geometry[collection.getDimension()];
      final int numGeometries = collection.getNumGeometries();
      for (int i = 0; i < numGeometries; i++) {
        result[i]=decimate(collection.getGeometryN(i));
      }
      return gFac.createGeometryCollection(result);
     
    } else if (geom instanceof LineString) {
      LineString line = (LineString) geom;
View Full Code Here

     * @param g
     * @return
     */
    public Geometry getCentroid(Geometry g) {
        if (g instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection) g;
            Coordinate[] pts = new Coordinate[gc.getNumGeometries()];

            for (int t = 0; t < gc.getNumGeometries(); t++) {
                pts[t] = gc.getGeometryN(t).getCentroid().getCoordinate();
            }

            return g.getFactory().createMultiPoint(pts);
        } else {
            return g.getCentroid();
View Full Code Here

            start("description");
            cdata(AtomUtils.getFeatureDescription(feature));
            end("description");
           
            GeometryCollection col = feature.getDefaultGeometry() instanceof GeometryCollection
                ? (GeometryCollection) feature.getDefaultGeometry()
                : null;

            if (geometryEncoding == GeometryEncoding.LATLONG
                || (col == null && feature.getDefaultGeometry() != null)) {
                geometryEncoding.encode((Geometry)feature.getDefaultGeometry(), this);
                end("item");
            } else {
                geometryEncoding.encode(col.getGeometryN(0), this);
                end("item");

                for (int i = 1; i < col.getNumGeometries(); i++){
                    encodeRelatedGeometryItem(col.getGeometryN(i), title, link, i);
                }
            }
        }
View Full Code Here

            if (feature.getDefaultGeometry() != null) {
                Geometry g = (Geometry) feature.getDefaultGeometry();

                //handle case of multi geometry with a single geometry in it
                if (g instanceof GeometryCollection) {
                    GeometryCollection mg = (GeometryCollection) g;

                    if (mg.getNumGeometries() == 1) {
                        g = mg.getGeometryN(0);
                    }
                }

                geometryEncoding.encode(g, this);
            }
View Full Code Here

                start("georss:where");
                geometryEncoding.encode((Geometry)feature.getDefaultGeometry(), this);
                end("georss:where");
                end("entry");
            } else {
                GeometryCollection col = (GeometryCollection)feature.getDefaultGeometry();
                start("georss:where");
                geometryEncoding.encode(col.getGeometryN(0), this);
                end("georss:where");
                end("entry");

                for (int i = 1; i < col.getNumGeometries(); i++){
                    encodeRelatedGeometryEntry(col.getGeometryN(i), feature.getID(), link, link + "#" + i);
                }
            }
        }
View Full Code Here

     */
    Coordinate geometryCentroid(Geometry g) {
        // TODO: should the collection case return the centroid of the
        // multi point?
        if (g instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection) g;

            // check for case of single geometry
            if (gc.getNumGeometries() == 1) {
                g = gc.getGeometryN(0);
            } else {
                double maxAreaSoFar = gc.getGeometryN(0).getArea();
                Coordinate centroidToReturn =
                    gc.getGeometryN(0).getCentroid().getCoordinate();

                for (int t = 0; t < gc.getNumGeometries(); t++) {
                    double area = gc.getGeometryN(t).getArea();
                    if (area > maxAreaSoFar) {
                        maxAreaSoFar = area;
                        centroidToReturn =
                            gc.getGeometryN(t).getCentroid().getCoordinate();
                    }
                }

                return centroidToReturn;
            }
View Full Code Here

       * @throws IOException if an error occurs during encoding
       */
      protected void writeMultiFeature(SimpleFeature ft,Style style,FeatureTypeStyle[] fts) throws IOException {
        reset(ft);
        if(processStyle(ft,style,fts)) {
          GeometryCollection geomCollection = (GeometryCollection) ft.getDefaultGeometry();
          for (int i = 0; i < geomCollection.getNumGeometries(); i++) {
            try {
                  startElement(ft,"."+i);       
                  startGeometry(geomCollection.getGeometryN(i));
                  writeGeometry(geomCollection.getGeometryN(i),buffer);
                  endGeometry(geomCollection.getGeometryN(i));       
                  endElement(ft);
                  commitBuffer();
            } catch(IOException e) {
              buffer=new StringBuffer();
              if(LOGGER.isLoggable(Level.WARNING))
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.