OK this is the code I am using right now for testing:
//"B" shapefile EnhancedMapLayer hazard = (EnhancedMapLayer)context.getLayer(1); FeatureSource fsh = hazard.getFeatureSource(); //"A" shapefile EnhancedMapLayer asset = (EnhancedMapLayer)context.getLayer(2); FeatureSource fsa = asset.getFeatureSource(); FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory(); String hgeometryName = fsh.getSchema().getDefaultGeometry().getName(); String ageometryName = fsa.getSchema().getDefaultGeometry().getName(); AttributeExpression hgeometryExpression = filterFactory.createAttributeExpression(hgeometryName); AttributeExpression ageometryExpression = filterFactory.createAttributeExpression(ageometryName); GeometryFactory geometryFactory = new GeometryFactory(); GeometryFilter geoFilter = filterFactory.createGeometryFilter(FilterType.GEOMETRY_INTERSECTS); geoFilter.addLeftGeometry(hgeometryExpression); geoFilter.addRightGeometry(ageometryExpression); FeatureCollection fch = fsh.getFeatures(geoFilter); The FilterType will actually change depending on the nature of the features in A and B. For this example I am using INTERSECTS because A features are lines and B features are POLYGONS. (For points, I've been trying to use DWITHIN, with little success.) I don't see how I can map the elements of the resulting collection of B features to A features, and then apply the next filter. Thanx! gaby *************************************************************** ** Gabriella Turek [EMAIL PROTECTED] ** ** National Institute of Water & Atmospheric Research (NIWA) ** ** PO Box 8602 Christchurch New Zealand +64-3-343-8067 ** *************************************************************** >>>Jody Garnett <[EMAIL PROTECTED]> 12/11/07 12:19 pm >>> Yes; although it amounts to setting up your geometry filter to match your definition of "near". What is your definition of near? Cheers, Jody >Is there any way to skip the loop in step (2)? >gaby > > >>>>Jody Garnett <[EMAIL PROTECTED]> 12/11/07 11:02 am >>> >>>> >When you get back the feature collection of those things "near" to A; >you can call the Collection_Max function on the featurecollection >directly; this is way faster (and may be optimzied into SQL if your >datastore is backed by SQL): > >- >http://docs.codehaus.org/display/GEOTDOC/10+FeatureCollection+Aggregate+Functions > > >Cheers, >Jody > >Gabriella Turek wrote: > >>I have two shape files, call them A and B. I need to: >>(1) find out the features in B that are "near" to each feature in A. >>(2) Interrogate an attribute value of these "near" features and pick the >>highest value. >> >>I actually figured out how to do it, but I don't think I am doing it "right", >>i.e. using all the tools >>at my disposal. >> >>My steps are: >>(1) creat up geometry filter to find features in B close to A >>(2) loop thru each feature in A to find these "near" B features >>(3) when one is found, interrogate attribute value and establish if it's a >>new max >> >>I get the nagging feeling that I dont' need to do this looping and that - >>moreover - I can >>have yet another filter which looks for my max value. I've tried a few things >>with little success. >>Any help will be greatly appreciated. >>Gaby >> >> >> >> >>** Gabriella Turek [EMAIL PROTECTED] >>** National Institute of Water & Atmospheric Research (NIWA) >>** PO Box 8602 Christchurch New Zealand +64-3-343-8067 >> >> >> >>------------------------------------------------------------------------- >>SF.Net email is sponsored by: >>Check out the new SourceForge.net Marketplace. >>It's the best place to buy or sell services for >>just about anything Open Source. >>http://sourceforge.net/services/buy/index.php >> >>Geotools-gt2-users mailing list >>Geotools-gt2-users@lists.sourceforge.net >>https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> >> > > > ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users