Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Get feature on mousePressed method

There is also an example tool in the tutorial code examples project that goes through all the layers in z order and does a query on each one returning the first feature found.

Once you get your feature you have a couple ways of modifying it:
- use an edit command (so the change can be in the undo/redo queue)
- use the featurestore API and call modifyFeatures method. To do this you will need a filter to select the feature (use FeatureID filter to select a single feature) and the name of the attribute to modify and the new value

Jody

Emily Gouge wrote:
A feature source can take a filter so instead of asking for all features [source.getFeatures()] you can make a filter and only ask for features within that filter [source.getFeatures(myFilter)].

I believe the context associated with your tool should have a getBoundingBox(...) function that should return a bounding box around where the user clicked. You can then use a FilterFactory class to create a filter.

Have a look at the info tool; it sounds like you are doing something similar.

Emily


Alessandro Sferrazza wrote:
Hi uDig'gers!

I have a Class that extend AbstractEditTool. I need to get the feature selected by clicking on the map, in the
method mousePressed of my class so that I can modify its attributes.

I have worked on the following code

IMap map = ApplicationGIS.getActiveMap();
FeatureSource source=map.getEditManager().getSelectedLayer().getResource(
FeatureSource.class,  new NullProgressMonitor());
FeatureCollection collection=source.getFeatures();

But it retuns all the features on Selected layer and not the 'Clicked'
single one.

Regards

Alessandro Sferrazza
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



Back to the top