Peter Fay wrote:
Cory,
Since somehow your name is attached to API-Filters in the Module Matrix
(http://docs.codehaus.org/display/GEOTOOLS/Module+Matrix), could you help me
out with my question below? (i.e. a code sample which creates a Filter to
obtain a collection of all points within a radius of 10 miles... using
version 2.2.C2)?
It would be great to have more sample code of how to use filters and
expressions...
-Peter
Hi Peter,
We're still updating the snippets... I updated a couple of the
Filter-related ones today, but the rest will have to wait.
Here's a few breadcrumbs from my understanding of the code...
GeometryFactory gf = new GeometryFactory();
Geometry geometry = gf.createPoint(new Coordinate(50,50));
FilterFactory ff = FilterFactoryFinder.createFilterFactory();
GeometryDistanceFilter gdf = null;
try {
gdf =
ff.createGeometryDistanceFilter(FilterType.GEOMETRY_DWITHIN);
//instanciates CartesianDistanceFilter
//"radius"
gdf.setDistance(10); //this needs to be modified (in units
of CRS, geom?)
//add geom attribute
gdf.addLeftGeometry(ff.createAttributeExpression("THE_GEOM")); //name of
geometry attribute type
//add center of "circle"
gdf.addRightGeometry(ff.createLiteralExpression(geometry));
FeatureCollection allFeatures = null; //add
datastore/feature collection stuff here
System.out.println("First I have: "+allFeatures.size());
FeatureCollection lessFeatures = allFeatures.subCollection(gdf);
System.out.println("Now I have: "+lessFeatures.size());
} catch (IllegalFilterException e) {
e.printStackTrace();
}
I don't have a chance to test it right now... but let me know how it
goes and i'll add the result to the snippets section if it works out.
Cheers,
Cory.
----
Cory Horner
Refractions Research Inc.
http://www.refractions.net
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users