Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [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);