本文整理汇总了Java中org.geotools.data.simple.SimpleFeatureStore.removeFeatures方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureStore.removeFeatures方法的具体用法?Java SimpleFeatureStore.removeFeatures怎么用?Java SimpleFeatureStore.removeFeatures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.simple.SimpleFeatureStore
的用法示例。
在下文中一共展示了SimpleFeatureStore.removeFeatures方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeExample
import org.geotools.data.simple.SimpleFeatureStore; //导入方法依赖的package包/类
private void removeExample() throws Exception {
// removeExample start
Transaction transaction = new DefaultTransaction("removeExample");
SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
store.setTransaction(transaction);
FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Filter filter = ff.id(Collections.singleton(ff.featureId("fred")));
try {
store.removeFeatures(filter);
transaction.commit();
} catch (Exception eek) {
transaction.rollback();
}
// removeExample end
}
示例2: removeExample2
import org.geotools.data.simple.SimpleFeatureStore; //导入方法依赖的package包/类
private void removeExample2() throws Exception {
// removeExample2 start
Transaction transaction = new DefaultTransaction("removeExample");
SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
store.setTransaction(transaction);
FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Filter filter = ff.id(Collections.singleton(ff.featureId("fred")));
try {
final Set<FeatureId> removed = new HashSet<FeatureId>();
SimpleFeatureCollection collection = store.getFeatures( new Query( typeName, filter, Query.NO_NAMES ));
collection.accepts( new FeatureVisitor(){
public void visit(Feature feature) {
removed.add( feature.getIdentifier() );
}
}, null );
store.removeFeatures(filter);
transaction.commit();
} catch (Exception eek) {
transaction.rollback();
}
// removeExample2 end
}
示例3: delete
import org.geotools.data.simple.SimpleFeatureStore; //导入方法依赖的package包/类
@Override
@Transactional(rollbackFor = { Throwable.class })
public void delete(String featureId) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
try {
store.removeFeatures(filter);
if (log.isDebugEnabled()) {
log.debug("Deleted feature {} in {}", featureId, getFeatureSourceName());
}
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to delete from " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.DELETE_NOT_IMPLEMENTED, getFeatureSourceName(), source.getClass()
.getName());
}
}