Package org.geotools.feature

Examples of org.geotools.feature.DefaultFeatureCollection


        System.out.println("    FeatureSource bounds: " + featureSource.getBounds(Query.ALL));
        System.out.println("FeatureCollection   size: " + featureCollection.size());
        System.out.println("FeatureCollection bounds: " + featureCollection.getBounds());

        // Load into memory!
        DefaultFeatureCollection collection = DataUtilities.collection(featureCollection);
        System.out.println("         collection size: " + collection.size());
        // example6 end
        System.out.println("\nexample6 end\n");
    }
View Full Code Here


public class FeatureCollectingVisitor implements Visitor {
    SimpleFeatureCollection fc;
    int visited_nodes = 0;

    public FeatureCollectingVisitor(SimpleFeatureType type) {
        fc = new DefaultFeatureCollection("FeatureCollectingVisitor", type);
    }
View Full Code Here

        builder.add("geom", Point.class, DefaultGeographicCRS.WGS84);
        testPointFeatureType = builder.buildFeatureType();
    }

    public SimpleFeatureCollection createLineCollection() throws Exception {
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(createLine(-177, 0, -177, 10));
        fc.add(createLine(-177, 0, -200, 0));
        fc.add(createLine(-177, 0, -177, 100));
        return fc;
    }
View Full Code Here

    public void testRotatedTransform() throws Exception {
        // If we rotate the world rectangle + 90 degrees around (0,0), we get the screen rectangle
        final Rectangle screen = new Rectangle(0, 0, 100, 50);
        final Envelope world = new Envelope(0, 50, 0, -100);
        final AffineTransform worldToScreen = AffineTransform.getRotateInstance(Math.toRadians(90), 0, 0);
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(createPoint(0, 0));
        fc.add(createPoint(world.getMaxX(), world.getMinY()));
        MapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84);
        mapContext.addLayer((FeatureCollection)fc, createPointStyle());
        BufferedImage image = new BufferedImage(screen.width, screen.height,
                BufferedImage.TYPE_4BYTE_ABGR);
        final StreamingRenderer sr = new StreamingRenderer();
View Full Code Here

    public void testScreenMapMemory() {
        // build a feature source with two zig-zag line occupying the same position
        LiteCoordinateSequence cs = new LiteCoordinateSequence(new double[] {0, 0, 1, 1, 2, 0, 3, 1, 4, 0});
        SimpleFeature zigzag1 = SimpleFeatureBuilder.build(testLineFeatureType, new Object[] { gf.createLineString(cs) }, "zz1");
        SimpleFeature zigzag2 = SimpleFeatureBuilder.build(testLineFeatureType, new Object[] { gf.createLineString(cs) }, "zz2");
        DefaultFeatureCollection fc = new DefaultFeatureCollection();
        fc.add(zigzag1);
        fc.add(zigzag2);
        SimpleFeatureSource zzSource = new CollectionFeatureSource(fc);
       
        // prepare the map
        MapContent mc = new MapContent();
        StyleBuilder sb = new StyleBuilder();
View Full Code Here

            }
            md.addFeatures(features.toArray(new SimpleFeature[features.size()]));

            //convert back to a feature collection with the query applied
            FeatureReader<SimpleFeatureType, SimpleFeature> fr = md.getFeatureReader(query, Transaction.AUTO_COMMIT);
            SimpleFeatureCollection fc1 = new DefaultFeatureCollection("cachedfeaturecollection", (SimpleFeatureType) fr.getFeatureType());
            while( fr.hasNext() ) {
                fc1.add(fr.next());
            }
            fr.close();

            return fc1;
        }
View Full Code Here

        tb.add( "description", String.class );
        tb.add( "geometry", Geometry.class );
       
        GeometryFactory gf = new GeometryFactory();
        SimpleFeatureBuilder sb = new SimpleFeatureBuilder( tb.buildFeatureType() );
        DefaultFeatureCollection features = new DefaultFeatureCollection();
       
        sb.add( "one" );
        sb.add( "the first feature");
        sb.add( gf.createPoint( new Coordinate(1, 1) ) ) ;
        features.add( sb.buildFeature("1"));
       
        sb.add( "two" );
        sb.add( "the second feature");
        sb.add( gf.createPoint( new Coordinate(2, 2) ) ) ;
        features.add( sb.buildFeature("2"));
       
        Encoder encoder = new Encoder(new KMLConfiguration());
        encoder.setIndenting(true);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode(features, KML.kml, out );
View Full Code Here

     * @return The feature collection.
     *
     * @throws IOException In the event of a parsing error or if the input json is invalid.
     */
    public FeatureCollection readFeatureCollection(Object input) throws IOException {
        DefaultFeatureCollection features = new DefaultFeatureCollection(null, null);
        FeatureCollectionIterator it = (FeatureCollectionIterator) streamFeatureCollection(input);
        while(it.hasNext()) {
            features.add(it.next());
        }

        //check for the case of a crs specified post features in the json
        if (features.getSchema() != null
                && features.getSchema().getCoordinateReferenceSystem() == null
                && it.getHandler().getCRS() != null ) {
            try {
                return new ForceCoordinateSystemFeatureResults(features, it.getHandler().getCRS());
            } catch (SchemaException e) {
                throw (IOException) new IOException().initCause(e);
View Full Code Here

        DataStore store = DataStoreFinder.getDataStore(params);

        final SimpleFeatureType type = store.getSchema("example");
        final FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
        SimpleFeature f;
        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        f = SimpleFeatureBuilder
                .build(type, new Object[] { 1, "jody" }, "fid1");
        collection.add(f);
        f = SimpleFeatureBuilder.build(type, new Object[] { 2, "brent" },
                "fid3");
        collection.add(f);
        f = SimpleFeatureBuilder
                .build(type, new Object[] { 3, "dave" }, "fid3");
        collection.add(f);
        f = SimpleFeatureBuilder.build(type, new Object[] { 4, "justin" },
                "fid4");
        collection.add(f);

        writer = store.getFeatureWriter("road", Transaction.AUTO_COMMIT);
        try {
            // remove all features
            while (writer.hasNext()) {
                writer.next();
                writer.remove();
            }
            // copy new features in
            SimpleFeatureIterator iterator = collection.features();
            while (iterator.hasNext()) {
                SimpleFeature feature = iterator.next();
                SimpleFeature newFeature = writer.next(); // new blank feature
                newFeature.setAttributes(feature.getAttributes());
                writer.write();
View Full Code Here

public class DataUtilities {
    static FilterFactoryImpl ff = new FilterFactoryImpl();

    public static DefaultFeatureCollection createUnitsquareDataSet(int numdata) {
        Generator gen = new Generator(1, 1);
        DefaultFeatureCollection dataset = new DefaultFeatureCollection("Test", Generator.type);

        for (int i = 0; i < numdata; i++) {
            dataset.add(gen.createFeature(i));
        }

        return dataset;
    }
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.