Have a look at the annotated driven process factory; it would work *exactly* 
the same way; after I move the process @annotations into supported status (i.e. 
the gt-api module). 

So you you know how FilterFunction_area (eek what a terrible name) has the 
following:

 public Object evaluate(Object feature) {
 Geometry arg0;

 try { // attempt to get value and perform conversion
 arg0 = getExpression(0).evaluate(feature,Geometry.class);
 } catch (Exception e) // probably a type error
 {
 throw new IllegalArgumentException(
 "Filter Function problem for function area argument #0 - expected type 
Geometry");
 }
 return new Double(StaticGeometry.area(arg0));
 }


Where StaticGeometry.area(arg0) has:

 static public double area(Geometry arg0)
{
if (arg0 == null) return -1d;
Geometry _this = arg0;

return _this.getArea();
}


We would update StaticGeometry to have:

 @DescribeFunction(name="area", ... )
 static public double area(@DescribeParam(name="geom",...) Geometry arg0){
if (arg0 == null) return -1d;
Geometry _this = arg0;

return _this.getArea();
}


And make a base factory class so it can do reflection and sort things out ...

public class StaticGeometry extends 
StaticMethodsFunctionFactory<StaticGeometry> {
 super("StaticGeometry", StaticGeometry.class );
}

For more details on the approach try the new tutorial for process stuff!
- http://docs.geotools.org/latest/userguide/tutorial/advanced/process.html

Aside I really need to make a post foss4g geotools blog post rounding up the 
results of the code sprint; and linking to the presentations etc that used 
GeoTools.
-- 
Jody Garnett


On Thursday, 29 September 2011 at 10:15 PM, Michael Bedward wrote:

> Hi Jody,
> 
> > The functions were auto generated ages ago; I am not sure it was ever
> > packaged up as part of the build system.
> 
> Phew. Glad to know I wasn't just missing the bleeding obvious.
> 
> > I would like to replace them with annotations myself :-)
> 
> How would that work ?
> 
> Michael

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to