Package org.geotools.data

Examples of org.geotools.data.DefaultQuery


        monitor.beginTask(Messages.CreateOrSetFeature_name, 10);
        monitor.worked(1);
        FeatureStore<SimpleFeatureType, SimpleFeature> store = layer.getResource(FeatureStore.class, new SubProgressMonitor(monitor,2));
        Filter id = FeatureUtils.id(fid);
        String typeName = store.getSchema().getTypeName();
        DefaultQuery query = new DefaultQuery(typeName, id);
        FeatureIterator<SimpleFeature> iter=store.getFeatures( query ).features();
        try{
            createFeature=!iter.hasNext();
        }finally{
            iter.close();
View Full Code Here


            ProjectPlugin.getPlugin().log(e);
            return null;
        }
        BBOX filter = filterFactory.bbox(geomAttributeName, layerBounds.getMinX(),
            layerBounds.getMinY(), layerBounds.getMaxX(), layerBounds.getMaxY(), srs);
        Query query=new DefaultQuery(schema.getName().getLocalPart(), filter);

        return source.getFeatures(query);
    }
View Full Code Here

                .startsWith(RENAMED));
    }

    public void testGetFeaturesReader() throws Exception {
        FeatureReader<SimpleFeatureType, SimpleFeature> fr;
        fr = rts.getFeatureReader(new DefaultQuery(RENAMED), Transaction.AUTO_COMMIT);
        SimpleFeature sf = fr.next();
        fr.close();

        assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart());
View Full Code Here

        // build a filter that will retrieve that feature only
        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        final String fid = RENAMED + ".1107531701011";
        Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid)));

        FeatureCollection<SimpleFeatureType, SimpleFeature> fc = fs.getFeatures(new DefaultQuery(RENAMED, fidFilter));
        assertEquals(RENAMED, fc.getSchema().getName().getLocalPart());
        assertEquals(1, fc.size());
        FeatureIterator <SimpleFeature> it = fc.features();
        assertTrue(it.hasNext());
        SimpleFeature sf = it.next();
View Full Code Here

        assertEquals(fid, sf.getID());
    }

    public void testFeautureReaderFidFilter() throws Exception {
        FeatureReader<SimpleFeatureType, SimpleFeature> fr;
        fr = rts.getFeatureReader(new DefaultQuery(RENAMED, fidFilter), Transaction.AUTO_COMMIT);
        assertEquals(RENAMED, fr.getFeatureType().getName().getLocalPart());
        assertTrue(fr.hasNext());
        SimpleFeature sf = fr.next();
        assertFalse(fr.hasNext());
        fr.close();
View Full Code Here

        fr.close();
        assertEquals(fid, sf.getID());
    }

    public void testDelete() throws Exception {
        final DefaultQuery queryAll = new DefaultQuery(RENAMED);

        FeatureStore<SimpleFeatureType, SimpleFeature> store;
        store = (FeatureStore<SimpleFeatureType, SimpleFeature>) rts.getFeatureSource(RENAMED);
        int count = store.getCount(queryAll);
        store.removeFeatures(fidFilter);
View Full Code Here

        assertEquals(count - 1, store.getCount(queryAll));
    }

    public void testModify() throws Exception {
        final DefaultQuery queryAll = new DefaultQuery(RENAMED);

        FeatureStore<SimpleFeatureType, SimpleFeature> store;
        store = (FeatureStore<SimpleFeatureType, SimpleFeature>) rts.getFeatureSource(RENAMED);
        SimpleFeature original = store.getFeatures(fidFilter).features().next();
        String newAddress = ((String) original.getAttribute("ADDRESS")) + " xxx";
View Full Code Here

        FeatureLocking<SimpleFeatureType, SimpleFeature> fl2;
        fl2 = (FeatureLocking<SimpleFeatureType, SimpleFeature>) rts.getFeatureSource(RENAMED);
        fl.setFeatureLock(lock);
        fl2.setTransaction(new DefaultTransaction());

        Query q = new DefaultQuery(RENAMED, fidFilter);
        assertEquals(1, fl.lockFeatures(q));
        assertEquals(0, fl2.lockFeatures(q));

        fl.unLockFeatures(q);
        assertEquals(1, fl2.lockFeatures(q));
View Full Code Here

    }

    public void testQueryWithPropertyNames() throws Exception {
        // check the schemas in feature source and feature collection
        FeatureSource<SimpleFeatureType, SimpleFeature> fs = rts.getFeatureSource(RENAMED);
        DefaultQuery q = new DefaultQuery(RENAMED, Filter.INCLUDE, new String[] { "ADDRESS"} );
        FeatureCollection<SimpleFeatureType,SimpleFeature> fc = fs.getFeatures( q );
        assertEquals( 1, fc.getSchema().getAttributeCount() );
       
        // make sure the feature schema is good as well
        FeatureIterator <SimpleFeature> it = fc.features();
View Full Code Here

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        BBOX filter = ff.bbox(geom.getLocalName(), nativeEnv.getMinX(),
                nativeEnv.getMinY(), nativeEnv.getMaxX(), nativeEnv.getMaxY(), null);

        // build an optimized query (only the necessary attributes
        DefaultQuery q = new DefaultQuery();
        q.setFilter(filter);
        q.setPropertyNames(new String[] { geom.getLocalName(), attribute });
        // TODO: enable this when JTS learns how to compute centroids
        // without triggering the
        // generation of Coordinate[] out of the sequences...
        // q.setHints(new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY,
        // PackedCoordinateSequenceFactory.class));
        q.setSortBy(new SortBy[] { ff.sort(attribute, SortOrder.DESCENDING) });

        // return the reader
        return fs.getFeatures(q).features();
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.DefaultQuery

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.