Hi Jeff,
 
thanks for the Example, another little question.
 
Im using a WFSDataStore like that
 

URL url="">new URL("http://beaker.sysgroup.it/geoserver/wfs?version=1.0.0&request=getcapabilities&service=wfs");

Map m = new HashMap();

m.put(WFSDataStoreFactory.URL.key,url);

DataStore wfs = (new WFSDataStoreFactory()).createNewDataStore(m);

 
Can I use the same procedure of your example?
 
Best regards.
 
Jacopo
 
 
Jacopo Boari                                                               
Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino
tel 0112440983   fax 0112406561   
e-mail [EMAIL PROTECTED]           www.sysgroup.it
 


Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Per conto di Hyink, Jeffrey (LCDR)
Inviato: mercoledì 29 novembre 2006 8.27
A: [email protected]
Oggetto: [Geotools-gt2-users] getFeatures and FID filter example provided

Jacopo,

 

The below is a quick example of a getFeatures() operation with a FID filter

 

-Jeff

 

package examples;

 

import java.io.File;

import java.io.IOException;

import java.net.MalformedURLException;

import java.net.URL;

 

import org.geotools.data.FeatureResults;

import org.geotools.data.FeatureSource;

import org.geotools.data.shapefile.ShapefileDataStore;

import org.geotools.filter.FidFilter;

import org.geotools.filter.FilterFactory;

import org.geotools.filter.FilterFactoryFinder;

 

/**

 * @version $Id$

 * @author J. F. Hyink

 *

 */

public class getFeatureExample {

 

      public static void main(String[] args) {

            URL sourceShapeFileURL = null;

            ShapefileDataStore store = null;

            try {

                  sourceShapeFileURL = sourceShapeFileURL = (new File("C:/JavaProjects/Data/Carmel Shapefile/carmel.shp")).toURL();

                  store = new ShapefileDataStore(sourceShapeFileURL);

            } catch (MalformedURLException e) {

                  e.printStackTrace();

            }

            //pull the first name off of the typeNames list in the file

            String nameOfFeatureType = store.getTypeNames()[0]; 

            FeatureSource source = null;

            try {

                  //get a featureSource for the named feature type

                  source = store.getFeatureSource(nameOfFeatureType); 

            } catch (IOException e) {

                  e.printStackTrace();

            }

           

            //now create a FID filter and apply it to get results

            FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory();

            FidFilter filter = filterFactory.createFidFilter();

            filter.addFid("carmel.22");  //carmel.22 is a valid FID in this shapefile.

            FeatureResults r = null;

            int featureCount = 0;

            try {

                  r = source.getFeatures(filter);

                  //the getCount() method below is deprecated, but works for a quick example

                  featureCount = r.getCount();

            } catch (IOException e) {

                  e.printStackTrace();

            }

            System.out.println("caught " + featureCount + " features with filter");

      }

}

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to