Package org.geotools.data.simple

Examples of org.geotools.data.simple.SimpleFeatureSource


    @Test
    public void testFeatureSourceNoGeom() throws IOException {
        log("-----------------------------------------------------");
        log("Testing feature source without geometry");
        DataStore ds = testData.getDataStore();
        SimpleFeatureSource fs = ds.getFeatureSource(typeName);
        try {
            Query query = new Query(typeName, Filter.INCLUDE, new String[] { "TOWN_ID" });
            long runTime = 0;
            for (int run = 0; run < numRuns; run++) {
                runTime += iterate(fs, query);
View Full Code Here


    private void testFeatureSource(final String tableName) throws IOException, DataSourceException,
            UnavailableConnectionException, CQLException {

        testData.truncateTestTable(tableName);

        SimpleFeatureSource fs;

        fs = ds.getFeatureSource(tableName);
        assertNotNull(fs);

        assertNull(fs.getBounds());
        assertTrue(fs instanceof FeatureStore);
        assertEquals(0, fs.getCount(Query.ALL));

        addFeatures(tableName, Transaction.AUTO_COMMIT).close();

        assertNotNull(fs.getFeatures());
        assertEquals(2, fs.getFeatures().size());
        assertNull(fs.getBounds());

        Filter filter = CQL.toFilter("INT_COL = 2000");

        SimpleFeatureCollection features = fs.getFeatures(filter);
        assertNotNull(features);
        assertEquals(1, features.size());
        assertNull(fs.getBounds());

        SimpleFeatureIterator iterator = features.features();
        assertTrue(iterator.hasNext());
        SimpleFeature next = iterator.next();
        assertNotNull(next);
View Full Code Here

     * @return {@link FeatureSource} or {@link FeatureStore} depending on if the user has write
     *         permissions over <code>typeName</code>
     */
    public SimpleFeatureSource getFeatureSource(final String typeName) throws IOException {
        final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName);
        SimpleFeatureSource fsource;
        if (typeInfo.isWritable()) {
            fsource = new ArcSdeFeatureStore(typeInfo, this);
        } else {
            fsource = new ArcSdeFeatureSource(typeInfo, this);
        }
View Full Code Here

    }
   
    public void testLoadGeometry() throws Exception {
        // load up the store and source
        OGRDataStore ods = new OGRDataStore(getAbsolutePath(STATE_POP), null, null, ogr);
        SimpleFeatureSource fs = ods.getFeatureSource("statepop");
       
        // query just the geometry field, check the collection returned
        Query query = new Query("statepop");
        query.setPropertyNames(new String[] {"the_geom"});
        SimpleFeatureCollection fc = fs.getFeatures(query);
        assertTrue(fc.size() > 0);
        SimpleFeatureType schema = fc.getSchema();
        assertEquals(1, schema.getDescriptors().size());
        assertEquals(MultiPolygon.class, schema.getGeometryDescriptor().getType().getBinding());
       
View Full Code Here

        }
        return count;
    }

    protected SimpleFeatureCollection loadFeatures(String resource, Query query) throws Exception {
        SimpleFeatureSource fs = loadSource(resource, query);
        return fs.getFeatures(query);
    }
View Full Code Here

        OGRDataStore s = new OGRDataStore(getAbsolutePath(resource), null, null, ogr);
        return s.getFeatureSource(s.getTypeNames()[0]);
    }

    protected SimpleFeatureCollection loadFeatures(DataStore store, String typeName) throws Exception {
        SimpleFeatureSource fs = store.getFeatureSource(typeName);
        return fs.getFeatures();
    }
View Full Code Here

    public void testViewBounds() throws IOException {
        SelectBody select = ViewRegisteringFactoryHelper
                .parseSqlQuery(InProcessViewSupportTestData.masterChildSql);
        store.registerView(InProcessViewSupportTestData.typeName, (PlainSelect) select);

        SimpleFeatureSource fs = store.getFeatureSource(InProcessViewSupportTestData.typeName);
        assertNotNull(fs);
        Envelope bounds = fs.getBounds();
        assertNotNull(bounds);
        assertEquals(1D, bounds.getMinX(), 0);
        assertEquals(1D, bounds.getMinY(), 0);
        assertEquals(3D, bounds.getMaxX(), 0);
        assertEquals(3D, bounds.getMaxY(), 0);
View Full Code Here

    public void testViewBoundsQuery() throws Exception {
        SelectBody select = ViewRegisteringFactoryHelper
                .parseSqlQuery(InProcessViewSupportTestData.masterChildSql);
        store.registerView(InProcessViewSupportTestData.typeName, (PlainSelect) select);

        SimpleFeatureSource fs = store.getFeatureSource(InProcessViewSupportTestData.typeName);
        assertNotNull(fs);

        String cqlQuery = "NAME='name2' OR DESCRIPTION='description4'";
        Filter filter = CQL.toFilter(cqlQuery);
        Query query = new Query(InProcessViewSupportTestData.typeName, filter);

        Envelope bounds = fs.getBounds(query);

        assertNotNull(bounds);
        assertEquals(2D, bounds.getMinX(), 0);
        assertEquals(2D, bounds.getMinY(), 0);
        assertEquals(3D, bounds.getMaxX(), 0);
View Full Code Here

    public void testViewCount() throws Exception {
        SelectBody select = ViewRegisteringFactoryHelper
                .parseSqlQuery(InProcessViewSupportTestData.masterChildSql);
        store.registerView(InProcessViewSupportTestData.typeName, (PlainSelect) select);

        SimpleFeatureSource fs = store.getFeatureSource(InProcessViewSupportTestData.typeName);
        assertNotNull(fs);
        int count = fs.getCount(Query.ALL);
        final int expected = 7;
        assertEquals(expected, count);
    }
View Full Code Here

    public void testViewCountQuery() throws Exception {
        SelectBody select = ViewRegisteringFactoryHelper
                .parseSqlQuery(InProcessViewSupportTestData.masterChildSql);
        store.registerView(InProcessViewSupportTestData.typeName, (PlainSelect) select);

        SimpleFeatureSource fs = store.getFeatureSource(InProcessViewSupportTestData.typeName);
        assertNotNull(fs);

        String cqlQuery = "NAME='name2' OR DESCRIPTION='description4'";
        Filter filter = CQL.toFilter(cqlQuery);
        Query query = new Query(InProcessViewSupportTestData.typeName, filter);

        int count = fs.getCount(query);
        final int expected = 3;
        assertEquals(expected, count);
    }
View Full Code Here

TOP

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

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.