Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureCollection


            } else {
                output.startElement(element.getNamespace(), element.getName(),
                    null);
            }

            SimpleFeatureCollection fc = (SimpleFeatureCollection) value;

            if (fc.getBounds() != null) {
                BoundingShapeType.getInstance().encode(null, fc.getBounds(),
                    output, hints);
            }else{
              throw new IOException("Bounding box required for the FeatureCollection");
            }

            SimpleFeatureIterator i = fc.features();
            Element e = null;

            while (i.hasNext()) {
                SimpleFeature f = i.next();
                output.startElement(GMLSchema.NAMESPACE, "featureMember", null);
View Full Code Here


    }

    @SuppressWarnings("unused")
    private long iterate(SimpleFeatureSource fs, Query query) throws IOException {
        Stopwatch sw = new Stopwatch();
        SimpleFeatureCollection features;
        features = fs.getFeatures(query);

        SimpleFeatureIterator iterator;
        iterator = features.features();

        log("- Iterating: " + Arrays.asList(query.getPropertyNames()));
        SimpleFeature feature;
        final int shapeIdx = fs.getSchema().getAttributeCount() - 1;
        try {
View Full Code Here

        final Filter filter = CQL.toFilter("INT32_COL = 1");

        // build the query asking for a subset of attributes
        final Query query = new Query(typeName, filter, queryAtts);

        SimpleFeatureCollection features = fs.getFeatures(query);
        SimpleFeatureType resultSchema = features.getSchema();

        assertEquals(1, resultSchema.getAttributeCount());
        assertEquals("SHAPE", resultSchema.getDescriptor(0).getLocalName());

        Feature feature = null;
        SimpleFeatureIterator iterator = features.features();
        try {
            feature = iterator.next();
        } finally {
            iterator.close();
        }
View Full Code Here

            e.printStackTrace();
            throw e;
        }
        // check that getBounds and size do function
        SimpleFeatureIterator reader = null;
        SimpleFeatureCollection results = fs.getFeatures(mixedFilter);
        Envelope bounds = results.getBounds();
        assertNotNull(bounds);
        LOGGER.fine("results bounds: " + bounds);

        reader = results.features();
        try {
            /*
             * verify that when features are already being fetched, getBounds and size still work
             */
            reader.next();
            bounds = results.getBounds();
            assertNotNull(bounds);
            LOGGER.fine("results bounds when reading: " + bounds);

            int count = results.size();
            assertEquals(EXPECTED_RESULT_COUNT, count);
            LOGGER.fine("wooohoooo...");

        } finally {
            reader.close();
View Full Code Here

            propNames.add(type.getDescriptor(i).getLocalName());
        }

        attOnlyQuery.setPropertyNames(propNames);

        SimpleFeatureCollection results = fSource.getFeatures(attOnlyQuery);
        SimpleFeatureType resultSchema = results.getSchema();
        assertEquals(propNames.size(), resultSchema.getAttributeCount());

        for (int i = 0; i < propNames.size(); i++) {
            assertEquals(propNames.get(i), resultSchema.getDescriptor(i).getLocalName());
        }

        // the problem described in GEOT-408 arises in attribute reader, so
        // we must to try fetching features
        SimpleFeatureIterator iterator = results.features();
        SimpleFeature feature = iterator.next();
        iterator.close();
        assertNotNull(feature);

        // the id must be grabed correctly.
View Full Code Here

        Id filter = ff.id(new HashSet<FeatureId>(fids));

        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        Query query = new Query(typeName, filter);
        SimpleFeatureCollection results = source.getFeatures(query);

        assertEquals(fids.size(), results.size());
        SimpleFeatureIterator iterator = results.features();
        try {
            while (iterator.hasNext()) {
                String fid = iterator.next().getID();
                assertTrue("a fid not included in query was returned: " + fid,
                        fids.contains(ff.featureId(fid)));
View Full Code Here

        Id filter = ff.id(fids);

        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        Query query = new Query(typeName, filter);
        SimpleFeatureCollection results = source.getFeatures(query);

        assertEquals(1, results.size());
        SimpleFeatureIterator iterator = results.features();
        try {
            while (iterator.hasNext()) {
                String fid = iterator.next().getID();
                assertTrue("a fid not included in query was returned: " + fid,
                        fids.contains(ff.featureId(fid)));
View Full Code Here

        int expectedCount = 8;
        int fCount = source.getCount(Query.ALL);
        String failMsg = "Expected and returned result count does not match";
        assertEquals(failMsg, expectedCount, fCount);

        SimpleFeatureCollection fresults = source.getFeatures();
        SimpleFeatureCollection features = fresults;
        failMsg = "FeatureResults.size and .collection().size thoes not match";
        assertEquals(failMsg, fCount, features.size());
        LOGGER.fine("fetched " + fCount + " features for " + table + " layer, OK");
    }
View Full Code Here

        BBOX emptyAttNameFilter = ff.bbox("", -10, -10, 10, 10, "EPSG:4326");
        String typeName = testData.getTempTableName();

        SimpleFeatureSource source;
        source = store.getFeatureSource(typeName);
        SimpleFeatureCollection features;
        features = source.getFeatures(emptyAttNameFilter);

        SimpleFeatureIterator iterator = features.features();
        try {
            assertTrue(iterator.hasNext());
        } finally {
            iterator.close();
        }
View Full Code Here

        assertNotNull(fsource);
        assertNotNull(fsource.getDataStore());
        assertEquals(fsource.getDataStore(), store);
        assertNotNull(fsource.getSchema());

        SimpleFeatureCollection results = fsource.getFeatures();
        int count = results.size();
        assertTrue("size returns " + count, count > 0);
        LOGGER.fine("feature count: " + count);

        Envelope env1;
        Envelope env2;
        env1 = fsource.getBounds();
        assertNotNull(env1);
        assertFalse(env1.isNull());
        env2 = fsource.getBounds(Query.ALL);
        assertNotNull(env2);
        assertFalse(env2.isNull());
        env1 = results.getBounds();
        assertNotNull(env1);
        assertFalse(env1.isNull());

        SimpleFeatureIterator reader = results.features();
        assertTrue(reader.hasNext());

        try {
            assertNotNull(reader.next());
        } catch (NoSuchElementException ex) {
View Full Code Here

TOP

Related Classes of org.geotools.data.simple.SimpleFeatureCollection

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.