Package org.geotools.data.store

Examples of org.geotools.data.store.ContentFeatureSource


        assertNotNull(schema.getDescriptor("State"));
    }
   
    @Test
    public void testFeatureReader() throws Exception {
        ContentFeatureSource featureSource = store.getFeatureSource("gttestdb.counties");
        FeatureReader<SimpleFeatureType, SimpleFeature> reader = featureSource.getReader();
        int cnt = 0;
        while (reader.hasNext()) {
            SimpleFeature nf = reader.next();
            cnt++;
        }
View Full Code Here


        return cnt;
    }
   
    @Test
    public void testBBoxQuery() throws Exception {
        ContentFeatureSource featureSource = store.getFeatureSource("gttestdb.counties");
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        // pueblo county
        BBOX bbox = ff.bbox("geometry", -105.050678,37.734704,-104.053921,38.522548,null);
       
        Query query = new Query("geometry", bbox);
        assertEquals(1, featureSource.getCount(query));
       
        FeatureReader<SimpleFeatureType, SimpleFeature> reader = featureSource.getReader(query);
        int cnt = 0;
        while (reader.hasNext()) {
            SimpleFeature nf = reader.next();
            cnt++;
        }
        assertEquals(1, cnt);
       
        ContentFeatureCollection features = featureSource.getFeatures(query);
        assertEquals(1, count(features));
    }
View Full Code Here

        assertEquals(1, count(features));
    }
   
    @Test
    public void testFilter() throws Exception {
        ContentFeatureSource featureSource = store.getFeatureSource("gttestdb.counties");
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
        PropertyIsEqualTo isPueblo = ff.equal(ff.property("Name"),ff.literal("Pueblo"),true);
        ContentFeatureCollection features = featureSource.getFeatures(isPueblo);
        assertEquals(1, count(features));
    }
View Full Code Here

     * @see WFSClient#supportsTransaction(QName)
     * @see org.geotools.data.store.ContentDataStore#createFeatureSource(org.geotools.data.store.ContentEntry)
     */
    @Override
    protected ContentFeatureSource createFeatureSource(final ContentEntry entry) throws IOException {
        ContentFeatureSource source;

        source = new WFSFeatureSource(entry, client);

        final QName remoteTypeName = getRemoteTypeName(entry.getName());
       
View Full Code Here

        SimpleFeatureIterator fi = null;
        try {
            logger.setLevel(java.util.logging.Level.SEVERE);
            logger.addHandler(handler);
            dataStore.createVirtualTable(vt);
            ContentFeatureSource fs = dataStore.getFeatureSource("invalid_attribute");

            // now hack the sql view definition to inject an invalid column name,
            // it's easier than having to alter the column name in the db to make the existing
            // view invalid
            sb.setLength(0);
            dialect.encodeColumnName(null, aname("not_valid"), sb);
            String notValid = sb.toString();
            sb.setLength(0);
            dialect.encodeColumnName(null, aname("flow"), sb);
            String flow = sb.toString();
            dataStore.virtualTables.get("invalid_attribute").sql = vt.sql.replace(flow, notValid);

            fi = fs.getFeatures().features();
            fail("We should not have gotten here, we were supposed to get a sql exception");
        } catch (RuntimeException e) {
            // fine, this is expected
            assertTrue(e.getCause() instanceof IOException);
        } finally {
View Full Code Here

    @Override
    protected abstract JDBCThreeValuedLogicTestSetup createTestSetup();
   
    public void testSimpleNegation() throws Exception {
        Not filter = ff.not(ff.equal(ff.property(aname(A)), ff.literal(10), false));
        ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC));
        int count = fs.getCount(new Query(tname(ABC), filter));
        assertEquals(2, count);
    }
View Full Code Here

        assertEquals(2, count);
    }
   
    public void testBetweenNegation() throws Exception {
        Not filter = ff.not(ff.between(ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C))));
        ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC));
        Query q = new Query(tname(ABC), filter);
        int count = fs.getCount(q);
        assertEquals(1, count);
        SimpleFeature f = getFirst(fs.getFeatures(q));
        assertEquals("n_n_n", f.getAttribute(aname(NAME)));
    }
View Full Code Here

        Filter fa = ff.greater(ff.property(aname(A)), ff.literal(3));
        Filter fb = ff.equal(ff.property(aname(B)), ff.literal(5), false);
        Filter fc = ff.less(ff.property(aname(C)), ff.literal(0));
        Not filter = ff.not(ff.and(Arrays.asList(fa, fb, fc)));
       
        ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC));
        Query q = new Query(tname(ABC), filter);
        int count = fs.getCount(q);
        assertEquals(2, count);
    }
View Full Code Here

        assertEquals(2, count);
    }
   
    public void test() throws Exception {
        Not filter = ff.not(ff.between(ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C))));
        ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC));
        Query q = new Query(tname(ABC), filter);
        int count = fs.getCount(q);
        assertEquals(1, count);
        SimpleFeature f = getFirst(fs.getFeatures(q));
        assertEquals("n_n_n", f.getAttribute(aname(NAME)));
    }
View Full Code Here

                DataAccess<?,?> dataStore = catalog.getResourcePool().getDataStore( ds );
                if( dataStore instanceof ContentDataStore ){
                    // ask JDBC DataStore to forget cached column information
                    Name name = ft.getQualifiedNativeName();
                    ContentDataStore contentDataStore = (ContentDataStore) dataStore;
                    ContentFeatureSource featureSource = contentDataStore.getFeatureSource(name,Transaction.AUTO_COMMIT);
                    featureSource.getState().flush();
                    flush = true;
                }
            } catch( Exception e ) {
                LOGGER.warning( "Unable to flush '" + ft.getQualifiedNativeName() );
                LOGGER.log(Level.FINE, "", e );
View Full Code Here

TOP

Related Classes of org.geotools.data.store.ContentFeatureSource

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.