[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] get selected features
|
Selon Andrea Antonello <andrea.antonello@xxxxxxxxx>, 22.04.2007:
> I'm not sure if that was already asked, but I see that the examples do
> not feed my needs, so question:
>
> Is it possible to get the selected features from a layer.
> I mean I get the ILayer from the visible layers and am able to get the
> featurestore from that. But I would like to have just the selected features.
This is what I would do ::
ILayer selectedLayer = handler.getContext().getSelectedLayer() ;
FeatureCollection collection = null ;
FeatureStore store = selectedLayer.getResource(
FeatureStore.class, new SubProgressMonitor(monitor, 1)) ;
collection = store.getFeatures(selectedLayer.getFilter()) ;
FeatureIterator reader = collection.features() ;
if (reader.hasNext()) {
// process selected features
}
where handler is a ToolHandler, but you can get the selected layer from the
active map as well ::
ApplicationGIS.getActiveMap().getEditManager().getSelectedLayer() ;
Christophe