Package org.geotools.feature

Examples of org.geotools.feature.FeatureCollection


   
    void testFeatureCollectionStream(boolean withBounds, boolean withCRS) throws Exception {
        FeatureIterator<SimpleFeature> features =
            fjson.streamFeatureCollection(reader(strip(collectionText(withBounds, withCRS))));
       
        FeatureCollection expected = collection();
        FeatureIterator e = expected.features();
       
        while(e.hasNext()) {
            features.hasNext(); //ensure that hasNext() does not skip features
            assertTrue(features.hasNext());
            assertEqualsLax((SimpleFeature)e.next(), features.next());
View Full Code Here


        assertEquals(strip(json), os.toString());
    }

    public void testFeatureCollectionWithCRSRead() throws Exception {
        String json = collectionText(true, true);
        FeatureCollection fcol = fjson.readFeatureCollection(strip(collectionText(true, true)));
        assertNotNull(fcol.getSchema().getCoordinateReferenceSystem());

        FeatureIterator it = fcol.features();
        while(it.hasNext()) {
            assertNotNull(it.next().getType().getCoordinateReferenceSystem());
        }
    }
View Full Code Here

      }
    }

    public void testFeatureCollectionWithCRSPostFeaturesRead() throws Exception {
        String json = collectionText(true, true);
        FeatureCollection fcol = fjson.readFeatureCollection(strip(collectionText(true, true, true, false, false)));
        assertNotNull(fcol.getSchema().getCoordinateReferenceSystem());

        FeatureIterator it = fcol.features();
        while(it.hasNext()) {
            assertNotNull(it.next().getType().getCoordinateReferenceSystem());
        }
    }
View Full Code Here

            "     'type' : 'Feature',"
            "     'properties' : { 'name' : 'Station' }" +
            "  }]," +
            "  'type' : 'FeatureCollection'" +
            "}");
        FeatureCollection fcol = fjson.readFeatureCollection(json);
        FeatureIterator it = fcol.features();
        assertTrue(it.hasNext());

        SimpleFeature f = (SimpleFeature) it.next();
        assertTrue(new WKTReader().read("POINT (17.633333 59.85)").equals((Geometry)f.getDefaultGeometry()));
        assertEquals("Station", f.getAttribute("name"));
View Full Code Here

        it.close();
    }

    public void testEmptyFeatureCollection() throws Exception {
        String json = strip("{'type':'FeatureCollection','features':[]}");
        FeatureCollection fcol = fjson.readFeatureCollection(json);
        assertNull(fcol.getSchema());
        assertTrue(fcol.isEmpty());
    }
View Full Code Here

    String collectionText(boolean withBounds, boolean withCRS, boolean crsAfter, boolean missingFirstFeatureAttribute, boolean nullFirstFeatureAttribute, boolean nullAttributeAllFeatures) {
        StringBuffer sb = new StringBuffer();
        sb.append("{'type':'FeatureCollection',");
        if (withBounds) {
            FeatureCollection features = collection();
            ReferencedEnvelope bbox = features.getBounds();
            sb.append("'bbox': [");
            sb.append(bbox.getMinX()).append(",").append(bbox.getMinY()).append(",")
                .append(bbox.getMaxX()).append(",").append(bbox.getMaxY());
            sb.append("],");
        }
View Full Code Here

    private void fillCache(Query query) throws IOException {
        Query cloned = new DefaultQuery(query);
        cloned.getHints().remove(Hints.GEOMETRY_DISTANCE);
       
        FeatureCollection features = wrapped.getFeatures(cloned);
        FeatureIterator fi = features.features();
        index = null;
        STRtree newIndex = new STRtree();
        while (fi.hasNext()) {
            // consider turning all geometries into packed ones, to save space
            Feature f = fi.next();
            newIndex.insert(ReferencedEnvelope.reference(f.getBounds()), f);
        }
        fi.close();
        index = newIndex;
        cachedQuery = query;
        cachedSchema = (SimpleFeatureType) features.getSchema();
        cachedBounds = getEnvelope(query.getFilter());
        dirty = false;
    }
View Full Code Here

        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSSegmentProcess process = new LRSSegmentProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        try {
            FeatureCollection result = process.execute(origional, "from_lrs_bad", "to_lrs", 1.0,
                    2.0);
            Assert.fail("Expected error from bad from_lrs name");
        } catch (ProcessException e) {
            // Successful
        }
View Full Code Here

        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSSegmentProcess process = new LRSSegmentProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        try {
            FeatureCollection result = process.execute(origional, "from_lrs", "to_lrs_bad", 1.0,
                    2.0);
            Assert.fail("Expected error from bad to_lrs name");
        } catch (ProcessException e) {
            // Successful
        }
View Full Code Here

        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSSegmentProcess process = new LRSSegmentProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        try {
            FeatureCollection result = process.execute(origional, null, "to_lrs", 1.0, 2.0);
            Assert.fail("Expected error from bad from_lrs name");
        } catch (ProcessException e) {
            // Successful
        }
    }
View Full Code Here

TOP

Related Classes of org.geotools.feature.FeatureCollection

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.