本文整理匯總了Java中org.geotools.data.DataStore.getFeatureReader方法的典型用法代碼示例。如果您正苦於以下問題:Java DataStore.getFeatureReader方法的具體用法?Java DataStore.getFeatureReader怎麽用?Java DataStore.getFeatureReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.geotools.data.DataStore
的用法示例。
在下文中一共展示了DataStore.getFeatureReader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: example3
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static void example3() throws IOException {
System.out.println("example3 start\n");
// example3 start
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put("directory", directory);
DataStore datastore = DataStoreFinder.getDataStore(params);
Query query = new Query("example");
FeatureReader<SimpleFeatureType, SimpleFeature> reader = datastore
.getFeatureReader(query, Transaction.AUTO_COMMIT);
try {
int count = 0;
while (reader.hasNext()) {
SimpleFeature feature = reader.next();
System.out.println("feature " + count + ": " + feature.getID());
count++;
}
System.out.println("read in " + count + " features");
} finally {
reader.close();
}
// example3 end
System.out.println("\nexample3 end\n");
}
示例2: example4
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static void example4() throws IOException {
System.out.println("example4 start\n");
// example4 start
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put("directory", directory);
DataStore store = DataStoreFinder.getDataStore(params);
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
Set<FeatureId> selection = new HashSet<FeatureId>();
selection.add(ff.featureId("fid1"));
Filter filter = ff.id(selection);
Query query = new Query("example", filter);
FeatureReader<SimpleFeatureType, SimpleFeature> reader = store
.getFeatureReader(query, Transaction.AUTO_COMMIT);
try {
while (reader.hasNext()) {
SimpleFeature feature = reader.next();
System.out.println("feature " + feature.getID());
for (Property property : feature.getProperties()) {
System.out.print("\t");
System.out.print(property.getName());
System.out.print(" = ");
System.out.println(property.getValue());
}
}
} finally {
reader.close();
}
// example4 end
System.out.println("\nexample4 end\n");
}
示例3: getFeatureReader
import org.geotools.data.DataStore; //導入方法依賴的package包/類
public static FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(DataStore store, String typeName) throws IOException {
DefaultQuery query = new DefaultQuery(typeName);
return store.getFeatureReader(query, Transaction.AUTO_COMMIT);
}