Package org.geotools.feature

Examples of org.geotools.feature.DefaultFeatureCollection


    @Test
    public void testHolyPolygons() throws Exception {
        SimpleFeatureType type = DataUtilities.createType("junk",
                "a:MultiPolygon");
        SimpleFeatureCollection features = new DefaultFeatureCollection();

        File tmpFile = getTempFile();
        tmpFile.delete();

        // write features
View Full Code Here


        build.add(gf.createPoint((new Coordinate(0, 0))));
        build.add(new Long(0));
        build.add(new Long(0));
        build.add("Hey");
        SimpleFeature newFeature = build.buildFeature(null);
        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        collection.add(newFeature);

        List<FeatureId> newFids = featureStore.addFeatures(collection);
        assertEquals(1, newFids.size());
        // this.assertFidsMatch();
View Full Code Here

        tb.add("integer", Integer.class);

        GeometryFactory gf = new GeometryFactory();
        SimpleFeatureBuilder b = new SimpleFeatureBuilder(tb.buildFeatureType());

        DefaultFeatureCollection features = new DefaultFeatureCollection(null, b.getFeatureType());
        DefaultFeatureCollection secondFeatures = new DefaultFeatureCollection(null, b
                .getFeatureType());
        Geometry[] firstArrayGeometry = new Geometry[5];
        Geometry[] secondArrayGeometry = new Geometry[5];
        for (int numFeatures = 0; numFeatures < 5; numFeatures++) {
            Coordinate firstArray[] = new Coordinate[5];
            for (int j = 0; j < 4; j++) {
                firstArray[j] = new Coordinate(j + numFeatures, j + numFeatures);
            }
            firstArray[4] = new Coordinate(0 + numFeatures, 0 + numFeatures);
            LinearRing shell = new LinearRing(firstArray, new PrecisionModel(), 0);
            b.add(gf.createPolygon(shell, null));
            b.add(0);
            firstArrayGeometry[numFeatures] = gf.createPolygon(shell, null);
            features.add(b.buildFeature(numFeatures + ""));

        }
        for (int numFeatures = 0; numFeatures < 5; numFeatures++) {
            Coordinate array[] = new Coordinate[5];
            for (int j = 0; j < 4; j++) {
                array[j] = new Coordinate(j + numFeatures + 50, j + numFeatures + 50);
            }
            array[4] = new Coordinate(0 + numFeatures + 50, 0 + numFeatures + 50);
            LinearRing shell = new LinearRing(array, new PrecisionModel(), 0);
            b.add(gf.createPolygon(shell, null));
            b.add(0);
            secondArrayGeometry[numFeatures] = gf.createPolygon(shell, null);
            secondFeatures.add(b.buildFeature(numFeatures + ""));

        }
        UnionFeatureCollection process = new UnionFeatureCollection();
        SimpleFeatureCollection output = process.execute(features, secondFeatures);
        assertEquals(5, output.size());
View Full Code Here

            SimpleFeatureBuilder.build( type, new Object[] { null }, "f4" ),
            SimpleFeatureBuilder.build( type, new Object[] { null }, "f5" ),
            SimpleFeatureBuilder.build( type, new Object[] { null }, "f6" )
        };

        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        List<SimpleFeature> list = Arrays.asList(features);
        collection.addAll(list);
        arrayReader = new CollectionFeatureReader(features);
        collectionReader = new CollectionFeatureReader(list, type);
        featureCollectionReader = new CollectionFeatureReader((SimpleFeatureCollection)collection, type);
    }
View Full Code Here

     * Builds a data store wrapper around an empty collection.
     *
     * @param collection
     */
    public CollectionDataStore(SimpleFeatureType schema) {
        this.collection = new DefaultFeatureCollection();
        this.featureType = schema;
    }
View Full Code Here

        tb.add("shape", MultiPoint.class);
        tb.add("value", Double.class);

        SimpleFeatureType type = tb.buildFeatureType();
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
        DefaultFeatureCollection fc = new DefaultFeatureCollection();

        GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());

        for (Coordinate p : pts) {
            Geometry point = factory.createPoint(p);
            fb.add(point);
            fb.add(p.z);
            fc.add(fb.buildFeature(null));
        }

        return fc;
    }
View Full Code Here

        tb.add("shape", MultiPoint.class);
        tb.add("value", Double.class);

        SimpleFeatureType type = tb.buildFeatureType();
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
        DefaultFeatureCollection fc = new DefaultFeatureCollection();

        GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());

        for (Coordinate p : pts) {
            Geometry point = factory.createPoint(p);
            fb.add(point);
            fb.add(p.z);
            fc.add(fb.buildFeature(null));
        }

        return fc;
    }
View Full Code Here

        SimpleFeatureType type = tb.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        WKTReader reader = new WKTReader();

        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        SimpleFeature feature;

        feature = buildFeature(builder, reader,
                "MULTIPOLYGON(((10 10, 10 20, 30 20, 30 10, 10 10)))", "left", 1);
        fc.add(feature);

        feature = buildFeature(builder, reader,
                "MULTIPOLYGON(((40 10, 40 20, 60 20, 60 10, 40 10)))", "right", 3);
        fc.add(feature);

        feature = buildFeature(builder, reader,
                "MULTIPOLYGON(((20 0, 20 30, 50 30, 50 0, 20 0)))", "middle", 2);
        fc.add(feature);

        return fc;
    }
View Full Code Here

        SimpleFeatureType type = tb.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        WKTReader reader = new WKTReader();

        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        Random rand = new Random();
       
        GridCoordinates2D gridPos = new GridCoordinates2D();
        int i = 1;
        for (int y = 0; y < gridDim.height; y++) {
            for (int x = 0; x < gridDim.width; x++) {
                if (rand.nextDouble() < PROB_POINT) {
                    gridPos.setLocation(x, y);
                    DirectPosition worldPos = gridGeom.gridToWorld(gridPos);
                   
                    String wkt = String.format(Locale.US, "MULTIPOINT((%f %f))",
                            worldPos.getOrdinate(0), worldPos.getOrdinate(1));
                    fc.add( buildFeature(builder, reader, wkt, "p" + i, i ) );
                    i++ ;
                }
            }
        }
        return fc;
View Full Code Here

        SimpleFeatureType type = tb.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        WKTReader reader = new WKTReader();

        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        SimpleFeature feature;
       
        feature = buildFeature(builder, reader,
                "LINESTRING(10 0, 10 20)", "horizontal", "1");
        fc.add(feature);

        feature = buildFeature(builder, reader,
                "LINESTRING(0 10, 20 10)", "vertical", "2");
        fc.add(feature);

        feature = buildFeature(builder, reader,
                "LINESTRING(0 20,0 0,20 0,20 20,0 20)", "box", "3");
        fc.add(feature);
       
        return fc;
    }
View Full Code Here

TOP

Related Classes of org.geotools.feature.DefaultFeatureCollection

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.