Here is the example I mentioned earlier:
-
http://svn.refractions.net/udig/udig/trunk/tutorials/net.refractions.udig.tutorials.examples/src/net/refractions/udig/tutorials/examples/PickTool.java

You should be able to pick up all the helpful advice Jesse mentioned in the
code there :-)

Jody

On Thu, Feb 12, 2009 at 5:30 PM, Jesse Eichar
<[email protected]>wrote:

> The ToolContext (obtained using the getContext() method) has methods for
> generating Boundingboxes in the correct project.  Remember that when doing a
> spatial query on a layer the filter must be in the same projection as the
> layer (at least for now).  So take a look at the context and the layer
> object for assistance creating the bounding box.  The idea of a bounding box
> filter for a mouse click the point that a pixel covers a lot of ground in
> the map so you do a BBox query to get the features that intersect with that
> pixel.
>
> Jesse
>
>
> On 11-Feb-09, at 6:08 PM, 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
>>
>
> _______________________________________________
> 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

Reply via email to