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 retrieve 
the feature's info else retrieve informations about the nearest feature.

I resolved using the GeometryDistanceFilter.

Code:

FeatureSource source = null;
FeatureCollection collection = null;
Coordinate coord = new Coordinate(X,Y);

FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory();
GeometryFactory fact = new GeometryFactory();
GeometryDistanceFilter distanceFilter = 
filterFactory.createGeometryDistanceFilter(FilterType.GEOMETRY_DWITHIN);
distanceFilter.setDistance(10.0);
Point point = fact.createPoint(coord);
distanceFilter.addLeftGeometry(filterFactory.createLiteralExpression(point));
try{
        source=wfs.getFeatureSource(pointQueryTool.getFeatureType().getName());
        collection = source.getFeatures(distanceFilter);
}catch(IOException e){
        source=null;
}

Cheers


Jacopo Boari                                                               
Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino
tel 0112440983   fax 0112406561   
e-mail [EMAIL PROTECTED]           www.sysgroup.it

-----Messaggio originale-----
Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Per conto di Jacopo Boari
Inviato: giovedì 4 gennaio 2007 19.04
A: 'Manuele Ventoruzzo'; '[email protected]'
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
 
Jacopo Boari                                                               
Sysgroup srl - Lungo Dora Colletta 113/14 - 10153 Torino
tel 0112440983   fax 0112406561   
e-mail [EMAIL PROTECTED]           www.sysgroup.it
 

________________________________

Da: Manuele Ventoruzzo [mailto:[EMAIL PROTECTED]
Inviato: giovedì 28 dicembre 2006 17.11
A: Jacopo Boari
Cc: '[email protected]'
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 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);
gf.addLeftGeometry(point);
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 [EMAIL PROTECTED]           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
        [email protected]
        https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
          



-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users



-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to