From: Jody G. <jga...@re...> - 2008-03-17 21:57:46
|
Cliff Darling wrote: > I want to identify if a given latitude/longitude coordinate lies > within any of the features within the shapefile. Question; is your shapefile also measured in lat/long? Or is it measured in something else? You can tell because the shapefile will have a ".prj" file :-) > So far, I am able to load in the Shape File and iterate through the > features with Feature Iterator. I tried to do my comparison by > creating a Point through a GeometryFactory from the latitude/longitude > values I have, and then trying: > > feature.getDefaultGeometry().contains(thePoint). > > However, this is always false. That seems correct. > The lat/long values I have are: > > 26.49247 > -80.47114 > > Is there some additional step I need to do? Do these values need to > be converted in some fashion before performing the geometry operation > (contains())? The values; and your geometry should both be in the same "coordinate reference system" (ie they should be measuring the same thing). Have a look here: - http://docs.codehaus.org/display/GEOTDOC/02+JTS+Utility+Class Note you can also set up a "query" and only ask for the features that contain your point: - http://docs.codehaus.org/display/GEOTDOC/Filter+Examples - http://docs.codehaus.org/display/GEOTDOC/06+FeatureSource > Please let me know if I should be asking a different question. I am > feeling my way through this right now. Best of luck Jody |