Hi Ben, thanx, I was a bit too hasty and I managed to get it working, but your list of references is more than welcome.
For the record, my solution was: try { f = new File("/Users/turekg/Desktop/Watersheds/tccwatershed.shp"); FileDataStore store2 = FileDataStoreFinder.getDataStore(f); SimpleFeatureSource featureSource = store2.getFeatureSource(); Filter filter = CQL.toFilter("CONTAINS(the_geom, POINT(1876437 5826750.3))"); Query query = new Query(); query.setFilter(filter); query.setHints(new Hints(Hints.FEATURE_2D, Boolean.TRUE)); // force 2D data FeatureCollection srcCollection = featureSource.getFeatures(filter); assertTrue(srcCollection.size() == 1); SimpleFeature[] fc = new SimpleFeature[1]; srcCollection.toArray(fc); assertTrue(fc[0].getID().equals("tccwatershed.85")); } catch (CQLException | IOException ex) { ex.printStackTrace(); } Just in case anyone else asksÅ Gaby On 16/09/14 7:37 pm, "Ben Caradoc-Davies" <ben.caradoc-dav...@csiro.au> wrote: >Gaby, > >there is a detailed example in the user guide that shows how to use a >Query to filter a SimpleFeatureCollection from (amongst other sources) a >shapefile. Spatial queries in CQL are supported. One example is a CQL >BBOX: >http://docs.geotools.org/latest/userguide/tutorial/filter/query.html > >I expect that the ECQL spatial predicates listed in the GeoServer manual >are supported: >http://docs.geoserver.org/latest/en/user/filter/ecql_reference.html >These functions should also be supported: >http://docs.geoserver.org/latest/en/user/filter/function_reference.html > >You should be able to construct a CQL expression to test whether a >catchment shape contains a given point. > >Please let me know if these work for you. I have not tried these in raw >GeoTools as most of my work is in the context of GeoServer. > >More of GeoTools CQL and ECQL: >http://docs.geotools.org/latest/userguide/library/cql/cql.html >http://docs.geotools.org/latest/userguide/library/cql/ecql.html > >Kind regards, >Ben. > >On 16/09/14 12:51, Gabriella Turek wrote: >> I have a shapefile of catchments (multipoly shapes) and I need to find >> which catchment contains a given asset (a point) >> How can I do that without iterating thru thru each shape? >> Can I filter with CQL? The link to the grammar in the javadocs is >>broken. >> Can I do better that check whether the bounding box contains the point? >> Thanx >> Gaby >> >> >> >>------------------------------------------------------------------------- >>----- >> Want excitement? >> Manually upgrade your production database. >> When you want reliability, choose Perforce. >> Perforce version control. Predictably reliable. >> >>http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clk >>trk >> _______________________________________________ >> GeoTools-GT2-Users mailing list >> GeoTools-GT2-Users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> >> > >-- >Ben Caradoc-Davies <ben.caradoc-dav...@csiro.au> >Software Engineer >CSIRO Mineral Resources Flagship >Australian Resources Research Centre ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce. Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users