Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryCollection


     }

     static public int numGeometries(Geometry arg0)
     {
           if (!(arg0 instanceof GeometryCollection)) return 0;
           GeometryCollection _this = (GeometryCollection) arg0;

           return _this.getNumGeometries();
     }
View Full Code Here


     static public Geometry getGeometryN(Geometry arg0, Integer arg1)
     {
           if (!(arg0 instanceof GeometryCollection) || arg1 == null) return null;

           GeometryCollection _this = (GeometryCollection) arg0;

           if (arg1 < 0 || arg1 >= _this.getNumGeometries()) return null;

           return _this.getGeometryN(arg1);
     }
View Full Code Here

        g[0] = gf.createPoint(new Coordinate(0, 0));
        g[1] = gf.createPoint(new Coordinate(0, 10));
        g[2] = gf.createPoint(new Coordinate(10, 0));
        g[3] = gf.createPoint(new Coordinate(10, 10));

        GeometryCollection gc = gf.createGeometryCollection(g);

        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.setName("bounds");
        tb.setCRS(null);
        tb.add("p1", Point.class);

        SimpleFeatureType t = tb.buildFeatureType();

        TreeSetFeatureCollection fc = new TreeSetFeatureCollection( null, t );
        SimpleFeatureBuilder b = new SimpleFeatureBuilder(t);
        for (int i = 0; i < g.length; i++) {
            b.add(g[i]);
            fc.add(b.buildFeature(null));
        }
        assertEquals(gc.getEnvelopeInternal(), fc.getBounds());
    }
View Full Code Here

        // prepare united the geometry
        Geometry[] geomArray = new Geometry[ops.size()];
        for (int i = 0; i < geomArray.length; i++) {
            geomArray[i] = ops.get(i).geometry;
        }
        GeometryCollection collection = geomArray[0].getFactory().createGeometryCollection(geomArray);
        Geometry united = collection.union();
        Literal geometry = FF.literal(united);
       
        // rebuild the filter
        Class<?> operation = ops.get(0).operation;
        if(BBOX.class.isAssignableFrom(operation) || Intersects.class.isAssignableFrom(operation)) {
View Full Code Here

    private double[][][] geometryToSdeCoords(final Geometry jtsGeom,
            final SeCoordinateReference seCRS) throws SeException, IOException {
        int numParts;
        double[][][] sdeCoords;
        GeometryCollection gcol = null;

        if (jtsGeom instanceof GeometryCollection) {
            gcol = (GeometryCollection) jtsGeom;
        } else {
            Geometry[] geoms = { jtsGeom };
            gcol = new GeometryFactory().createGeometryCollection(geoms);
        }

        List<SDEPoint> allPoints = new ArrayList<SDEPoint>();
        numParts = gcol.getNumGeometries();

        int[] partOffsets = new int[numParts];
        Geometry geom;

        for (int currGeom = 0; currGeom < numParts; currGeom++) {
            partOffsets[currGeom] = allPoints.size();
            geom = gcol.getGeometryN(currGeom);

            Coordinate[] coords = geom.getCoordinates();

            for (int i = 0; i < coords.length; i++) {
                Coordinate c = coords[i];
View Full Code Here

     * @param g the Geometry (or GeometryCollection to unroll)
     * @param collector the Collection where the Geometries will be added into
     */
    private static void collect(Geometry g, List<Geometry> collector) {
        if(g instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection)g;
            for (int i = 0; i < gc.getNumGeometries(); i++) {
                Geometry loop = gc.getGeometryN(i);
                if(! loop.isEmpty())
                    collector.add(loop);
            }
        } else {
            if(! g.isEmpty())
View Full Code Here

            return geometry.getFactory().createGeometryCollection(unrollGeometries(mp).toArray(new Geometry[0]));

        } else if(geometry instanceof GeometryCollection) {
            List<com.vividsolutions.jts.geom.Polygon> ret = new ArrayList<Polygon>();

            GeometryCollection gc = (GeometryCollection)geometry;
            for (int i = 0; i < gc.getNumGeometries(); i++) {
                Geometry g = gc.getGeometryN(i);
                if(g instanceof com.vividsolutions.jts.geom.Polygon) {
                    ret.add((com.vividsolutions.jts.geom.Polygon) g );
                } else if(g instanceof MultiPolygon) {
                    ret.addAll(unrollGeometries((MultiPolygon)g));
                } else {
View Full Code Here

        return geometryFactory.createGeometryCollection((Geometry[]) geometries.toArray(
                new Geometry[geometries.size()]));
    }
   
    public Object getProperty(Object object, QName name) throws Exception {
        GeometryCollection gc = (GeometryCollection) object;
        if ( KML.Geometry.equals( name ) ) {
            Geometry[] g = new Geometry[gc.getNumGeometries()];
            for ( int i = 0; i < g.length; i++ ) {
                g[i] = gc.getGeometryN(i);
            }
            return g;
        }
       
        return null;
View Full Code Here

        Geometry[] geoms = new Geometry[3];
        geoms[0] = factory.createPoint(new Coordinate());
        geoms[1] = factory.createLineString(getLineCoords());
        geoms[2] = factory.createPolygon(factory.createLinearRing(getPolyCoords()), null);
       
        GeometryCollection gc = factory.createGeometryCollection(geoms);
        Geometry smoothed = JTS.smooth(gc, 0);
        assertTrue(smoothed instanceof GeometryCollection);
        assertEquals(3, smoothed.getNumGeometries());
       
        // Input point should have been returned
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

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.