Package org.geotools.data

Examples of org.geotools.data.FeatureStore


            selectedLayers = new ArrayList<FeatureStore>();
            for( String name : itemNames ) {
                ILayer tmpLayer = itemsMap.get(name);
                if (tmpLayer != null) {
                    try {
                        FeatureStore tmpStore = tmpLayer.getResource(FeatureStore.class, null);
                        if (tmpStore != null)
                            selectedLayers.add(tmpStore);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
View Full Code Here


    public void refreshEditFeature() {
        Layer editLayer = getEditLayerInternal();
        try {
            FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools
                    .getDefaultHints());
            FeatureStore resource = editLayer.getResource(FeatureStore.class, null);
            Set<Identifier> fids = FeatureUtils.stringToId(filterFactory, getEditFeature().getID());
            Id filter = filterFactory.id(fids);
            FeatureIterator<SimpleFeature> features = resource.getFeatures(filter).features();
            if (features.hasNext()) {
                SimpleFeature feature = features.next();
                setEditFeature(feature, editLayer);
            } else {
                setEditFeature(null, editLayer);
View Full Code Here

    params.put( "url", file.toURL() );
    ShapefileDataStore dataStore =
        (ShapefileDataStore) factory.createNewDataStore( params );   
    dataStore.createSchema( featureType );
   
    FeatureStore store = (FeatureStore) dataStore.getFeatureSource();
    store.addFeatures( source.getFeatures() );
    dataStore.forceSchemaCRS( crs );
}
View Full Code Here

            catch( Exception e2 ) {
                throw e;
            }
           
            //delete all features
            FeatureStore store = (FeatureStore) dataStore.getFeatureSource( schema.getName() );
            store.removeFeatures(Filter.INCLUDE);
        }
       
        return dataStore.getFeatureWriterAppend( schema.getTypeName(), Transaction.AUTO_COMMIT );
    }
View Full Code Here

    }

    protected LayerInfo buildLayer(String name, WorkspaceInfo ws,
            Class<? extends ResourceInfo> resourceClass) throws Exception {
       
        FeatureStore fs = createNiceMock(FeatureStore.class);
        replay(fs);
       
        DataStore dstore = createNiceMock(DataStore.class);
        replay(dstore);
       
View Full Code Here

    }

    public void testFullAccess() throws Exception {
        FeatureSource source = getFeatureSource(MockData.LINES);
        FeatureCollection fc = source.getFeatures();
        FeatureStore store = (FeatureStore) source;
        store.removeFeatures(Filter.INCLUDE);
    }
View Full Code Here

            // fine, we should not be able to get to the feature source
        }
    }

    public void testCannotWrite() throws Exception {
        FeatureStore fs = (FeatureStore) getFeatureSource(MockData.DELETES);
               
        try {
            fs.removeFeatures(Filter.INCLUDE);
            fail("This should have failed with a security exception!");
        } catch (AcegiSecurityException e) {
            // fine, we should not be able to get to the feature source
        }
    }
View Full Code Here

    public void testReadOnlyFeatureStore() throws Exception {
        // build up the mock
        SimpleFeatureType schema = createNiceMock(SimpleFeatureType.class);
        expect(schema.getName()).andReturn(new NameImpl("testFT"));
        replay(schema);
        FeatureStore fs = createNiceMock(FeatureStore.class);
        expect(fs.getSchema()).andReturn(schema);
        replay(fs);
       
        ReadOnlyFeatureStore ro = new ReadOnlyFeatureStore(fs, WrapperPolicy.RO_CHALLENGE);
        try {
            ro.addFeatures(createNiceMock(FeatureCollection.class));
View Full Code Here

    private DataStore ds;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        FeatureStore fs = createNiceMock(FeatureStore.class);
        replay(fs);
        ds = createNiceMock(DataStore.class);
        expect(ds.getFeatureSource("blah")).andReturn(fs);
        replay(ds);
    }
View Full Code Here

    File tempShape = getTempFile();
    ShapefileDataStore store = new ShapefileDataStore(tempShape.toURI().toURL());
    store.createSchema(schema);
   
    // write out the features
    FeatureStore fs = (FeatureStore) store.getFeatureSource();
    fs.addFeatures(collection);

    // read it back
      SimpleFeature[] readfc =  (SimpleFeature[]) fs.getFeatures().toArray(new SimpleFeature[3]);
     
      // check the first geometry
      Geometry read = (Geometry) features[0].getDefaultGeometry();
        assertNull(read);
     
View Full Code Here

TOP

Related Classes of org.geotools.data.FeatureStore

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.