## [Geotools-gt2-users] Obtain feature by X,Y point

 [Geotools-gt2-users] Obtain feature by X,Y point From: Jacopo Boari - 2006-12-28 15:46:13 ```Hi all, After a click action on the map, I obtain the point's coordinates (X,Y). How can I obtain the feature at this coordinates? There's some filter that can I use? Best Regards... Jacopo Boari = =20 Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino tel 0112440983 fax 0112406561 =20 e-mail jacopo.boari@... http://www.sysgroup.it ```

 [Geotools-gt2-users] Obtain feature by X,Y point From: Jacopo Boari - 2006-12-28 15:46:13 ```Hi all, After a click action on the map, I obtain the point's coordinates (X,Y). How can I obtain the feature at this coordinates? There's some filter that can I use? Best Regards... Jacopo Boari = =20 Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino tel 0112440983 fax 0112406561 =20 e-mail jacopo.boari@... http://www.sysgroup.it ```
 Re: [Geotools-gt2-users] Obtain feature by X,Y point From: Manuele Ventoruzzo - 2006-12-28 16:11:20 ``` Of course.

First of all, you have to convert point's coordinate in a coordinate reference system used for map rendering (such as WGS:84).
To do this, you have to use an affine transformation.

Then, you can select feature that contains such point.

For example:

FilterFactory ff = FilterFactoryFinder.createFilterFactory();
GeometryFactory fact = new GeometryFactory();
Expression point = ff.createLiteralExpression(
fact.createPoint(coord));
GeometryFilter gf = ff.createGeometryFilter(FilterType.GEOMETRY_WITHIN);
FeatureSource fs = getFeatureSource(...);
FeatureCollection result = fs.getFeatures(gf);

Where coord is a Coordinate object.

Finally, result contains every feature that matches your condition.

Bye,
Manuele.

in data 28/12/2006 16.46 Jacopo Boari ha detto:
Hi all,  After a click action on the map, I obtain the point's coordinates (X,Y).  How can I obtain the feature at this coordinates? There's some filter that can I use?  Best Regards...   Jacopo Boari                                                                Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino tel 0112440983   fax 0112406561    e-mail jacopo.boari@...           www.sysgroup.it;   ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV; _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@... https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users;
```