Package org.geotools.data.collection

Examples of org.geotools.data.collection.ListFeatureCollection


        List<FeatureCollection> result = new ArrayList<FeatureCollection>();
        for (Map.Entry<FeatureType, List<Feature>> entry : map.entrySet()) {
            FeatureType type = entry.getKey();
            List<Feature> list = entry.getValue();
            if(type instanceof SimpleFeatureType) {
                result.add(new ListFeatureCollection((SimpleFeatureType) type, new ArrayList<SimpleFeature>((List) list)));
            } else {
                result.add(new ListComplexFeatureCollection(type, list));
            }
        }
       
View Full Code Here


        dom = getAsDOM(statusLocation);
        // print(dom);
        assertXpathExists("//wps:ProcessAccepted", dom);
       
        // now schedule the exit and wait for it to exit
        ListFeatureCollection fc = collectionOfThings();
        MonkeyProcess.exit("x2", fc, true);
        dom = waitForProcessEnd(statusLocation, 60);
        assertXpathExists("//wps:ProcessSucceeded", dom);
    }
View Full Code Here

        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.add("name", String.class);
        tb.add("location", Point.class, DefaultGeographicCRS.WGS84);
        tb.setName("thing");
        SimpleFeatureType featureType = tb.buildFeatureType();
        ListFeatureCollection fc = new ListFeatureCollection(featureType);
        return fc;
    }
View Full Code Here

        private SimpleFeatureCollection join(SimpleFeatureCollection inputCollection,
                CoverageBand band, final String coverageName) throws IOException {
            // TODO Improve this by doing batch join and storing the result into memory

            final DefaultProgressListener listener = new DefaultProgressListener();
            final ListFeatureCollection collection = new ListFeatureCollection(schema);
            // Getting attributes structure to be filled

            inputCollection.accepts(new AbstractFeatureVisitor() {
                public void visit(Feature feature) {
                    if (feature instanceof SimpleFeature) {
                        // get the feature
                        final SimpleFeature sourceFeature = (SimpleFeature) feature;
                        Collection<Property> props = sourceFeature.getProperties();
                        Name propName = null;
                        Object propValue = null;

                        // Assigning value to dest feature for matching attributes
                        Filter filter = null;
                        for (Property prop : props) {
                            propName = prop.getName();
                            if (
                            !propName.getLocalPart().equalsIgnoreCase("imageIndex")
                                    && !propName.getLocalPart().equalsIgnoreCase("the_geom")
                                    && !propName.getLocalPart().equalsIgnoreCase("location")) {
                                propValue = prop.getValue();
                                Filter updatedFilter = Utils.FF.equal(Utils.FF.property(propName),
                                        Utils.FF.literal(propValue), true);
                                if (filter == null) {
                                    filter = updatedFilter;
                                } else {
                                    filter = FF.and(filter, updatedFilter);
                                }
                            }
                        }
                        Query query = new Query();
                        query.setFilter(filter);
                        SimpleFeatureCollection coverageCollection;
                        try {
                            coverageCollection = reader.getGranules(coverageName, readOnly)
                                    .getGranules(query);
                            coverageCollection.accepts(new AbstractFeatureVisitor() {
                                public void visit(Feature feature) {
                                    if (feature instanceof SimpleFeature) {
                                        // get the feature
                                        final SimpleFeature destFeature = DataUtilities
                                                .template(schema);
                                        Collection<Property> props = destFeature.getProperties();
                                        Name propName = null;
                                        Object propValue = null;

                                        // Assigning value to dest feature for matching attributes
                                        for (Property prop : props) {
                                            propName = prop.getName();
                                            propValue = ((SimpleFeature) feature)
                                                    .getAttribute(propName);
                                            // Matching attributes are set

                                            destFeature.setAttribute(propName, propValue);
                                        }
                                        collection.add(destFeature);

                                        // check if something bad occurred
                                        if (listener.isCanceled() || listener.hasExceptions()) {
                                            if (listener.hasExceptions())
                                                throw new RuntimeException(listener.getExceptions()
View Full Code Here

    // prepare a mock feature collection
    SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
    tb.setName("test");
    final ReferencedEnvelope re = new ReferencedEnvelope(-10, 10, -10, 10,
        null);
    FeatureCollection fc = new ListFeatureCollection(tb.buildFeatureType()) {
      @Override
      public synchronized ReferencedEnvelope getBounds() {
        return re;
      }
    };
View Full Code Here

        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.add("name", String.class);
        tb.add("location", Point.class, DefaultGeographicCRS.WGS84);
        tb.setName("bomb");
        SimpleFeatureType featureType = tb.buildFeatureType();
        ListFeatureCollection fc = new ListFeatureCollection(featureType) {
            @Override
            public SimpleFeatureIterator features() {
                throw new RuntimeException("Toasted!");
            }
           
View Full Code Here

    }

    public Object decode(InputStream input) throws Exception {
        StreamingParser parser = new StreamingParser(new KMLConfiguration(), input, KML.Placemark);
        SimpleFeature f = null;
        ListFeatureCollection features = null;
        HashMap oldftype = null;
        SimpleFeatureType type = null;
        SimpleFeatureBuilder featureBuilder = null;

        while ((f = (SimpleFeature) parser.parse()) != null) {
            HashMap ftype = getSignature(f);
            if (oldftype == null) {
                oldftype = ftype;
                type = getType(ftype);
                featureBuilder = new SimpleFeatureBuilder(type);
                features = new ListFeatureCollection(type);
            } else {
                if (!oldftype.equals(ftype)) {
                    break;
                }
            }
            for (Object oentry : ftype.entrySet()) {
                Map.Entry entry = (Map.Entry) oentry;
                featureBuilder.add(f.getAttribute((Name) entry.getKey()));
            }
            SimpleFeature fnew = featureBuilder.buildFeature(f.getID());
            features.add(fnew);
        }
        return features;
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.collection.ListFeatureCollection

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.