Oh I think I can help.

We ended up copying the styles internally (to keep a copy that won't change). 
As such the code needs to be able to call FunctionFinder with "foo" and for 
that to work you need to register your function with the system as shown here:
- http://docs.geotools.org/latest/userguide/tutorial/advanced/function.html

The above is an "advanced" tutorial as it involves hooking your code into 
geotools; all the basic tutorials just involve using geotools.

-- 
Jody Garnett


On Wednesday, 29 June 2011 at 10:36 PM, LSA wrote:

> Hi All,
> 
> Solution offered by Michael worked flawlessly for geotools.2.6.3.
> 
> However, for geotools 2.7.0, when such filter:
> 
> org.opengis.filter.Filter filter = ff2.equals(foo, ff2.literal(true));
> 
> passed to MapLayer in Style in Rule (mixed with some other filters using 
> filterFactory.and())
> 
> this gives the following error:
> java.lang.RuntimeException: Unable to find function foo
>  at 
> org.geotools.filter.FunctionFinder.findFunction(FunctionFinder.java:103)
> 
> Any ideas?
> 
> Thanks,
> Sergey
> 
> On 21.05.2010 6:32, Michael Bedward wrote:
> > Hi again Sergey,
> > 
> > If you are only going to be using your filter programmatically (rather
> > than in SLD files) you can cheat a bit and set the string that you are
> > looking for in the filter function constructor like this...
> > 
> > public class Foo extends FunctionExpressionImpl {
> >  private final String typeName;
> > 
> >  public Foo(String typeName) {
> >  super("foo");
> >  this.typeName = typeName;
> >  }
> > 
> >  @Override
> >  public int getArgCount() {
> >  return 0;
> >  }
> > 
> >  @Override
> >  public Object evaluate(Object feature) {
> >  return (((SimpleFeature)feature).getID().matches(String.format("%s\\.\\d+",
> > typeName)));
> >  }
> > }
> > 
> > Then you can use it to create a Filter like this...
> > 
> >  FilterFactory2 ff2 = CommonFactoryFinder.getFilterFactory2(null);
> >  org.opengis.filter.expression.Function foo = new Foo("some_name");
> >  org.opengis.filter.Filter filter = ff2.equals(foo, ff2.literal(true));
> > 
> > Michael
> > 
> 
> 
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security 
> threats, fraudulent activity, and more. Splunk takes this data and makes 
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected] 
> (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to