From: Jacopo B. <jac...@sy...> - 2007-01-10 10:11:06
|
Hi list, I'm sorry for the bad explication of the question, what I want to di is: Click on the map, if at these coordinates there's a feature, I want to retr= ieve the feature's info else retrieve informations about the nearest featur= e. I resolved using the GeometryDistanceFilter. Code: FeatureSource source =3D null; FeatureCollection collection =3D null; Coordinate coord =3D new Coordinate(X,Y); FilterFactory filterFactory =3D FilterFactoryFinder.createFilterFactory(); GeometryFactory fact =3D new GeometryFactory(); GeometryDistanceFilter distanceFilter =3D filterFactory.createGeometryDista= nceFilter(FilterType.GEOMETRY_DWITHIN); distanceFilter.setDistance(10.0); Point point =3D fact.createPoint(coord); distanceFilter.addLeftGeometry(filterFactory.createLiteralExpression(point)= ); try{ =09source=3Dwfs.getFeatureSource(pointQueryTool.getFeatureType().getName())= ; =09collection =3D source.getFeatures(distanceFilter); }catch(IOException e){ =09source=3Dnull; } Cheers Jacopo Boari = =20 Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino tel 0112440983 fax 0112406561 =20 e-mail jac...@sy... www.sysgroup.it -----Messaggio originale----- Da: geo...@li... [mailto:geotools-gt2-u= ser...@li...] Per conto di Jacopo Boari Inviato: gioved=EC 4 gennaio 2007 19.04 A: 'Manuele Ventoruzzo'; 'geo...@li...' Oggetto: [Geotools-gt2-users] R: Obtain feature by X,Y point How can I find the features in he area near the clickPoint? Thanks in advance. Best regards =20 Jacopo Boari = =20 Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino tel 0112440983 fax 0112406561 =20 e-mail jac...@sy... www.sysgroup.it =20 ________________________________ Da: Manuele Ventoruzzo [mailto:man...@ov...] Inviato: gioved=EC 28 dicembre 2006 17.11 A: Jacopo Boari Cc: 'geo...@li...' Oggetto: Re: [Geotools-gt2-users] Obtain feature by X,Y point Of course. First of all, you have to convert point's coordinate in a coordinate refere= nce 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 =3D FilterFactoryFinder.createFilterFactory(); GeometryFactory fact =3D new GeometryFactory(); Expression point =3D ff.createLiteralExpression(fact.createPoint(coord)); GeometryFilter gf =3D ff.createGeometryFilter(FilterType.GEOMETRY_WITHIN); gf.addLeftGeometry(point); FeatureSource fs =3D getFeatureSource(...); FeatureCollection result =3D 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:=20 =09Hi all, =09 =09After a click action on the map, I obtain the point's coordinates (X,Y). =09 =09How can I obtain the feature at this coordinates? =09There's some filter that can I use? =09 =09Best Regards... =09 =09 =09Jacopo Boari = =20 =09Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino =09tel 0112440983 fax 0112406561 =20 =09e-mail jac...@sy... www.sysgroup.it =09 =09 =09------------------------------------------------------------------------= - =09Take Surveys. Earn Cash. Influence the Future of IT =09Join SourceForge.net's Techsay panel and you'll get the chance to share = your =09opinions on IT & business topics through brief surveys - and earn cash =09http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID= =3DDEVDEV =09_______________________________________________ =09Geotools-gt2-users mailing list =09G...@li... =09https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users =09 =20 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share you= r opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE= VDEV _______________________________________________ Geotools-gt2-users mailing list Geo...@li... https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |