monius ha scritto:
> Hello there,
> 
> I'm trying to filter a WFS layer's features according to their property
> "arrivaltime":
> each feature has this time property with a value of e.g. 0.0, 120.0, 180.0,
> 240.0, 300.0. I would like to display only those features whose arrival time
> corresponds to the following expression:
> arrivaltime mod 120 = 0
> 
> In other words, I would like to display only those features with an arrival
> time of 0.0, 120.0, 240.0, 360.0,...
> 
> Something like this, but correct :-):
> FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
> PropertyName property = ff.property("arrivaltime");
> PropertyIsEqualTo etf = ff.equals(property % 120.0, ff.literal(0));

The filter factory allows to create only official OGC expressions.
Modulo is not among them unfortunately.
Usually this is solved by using a filter function, and this case
is no exception, you can call the IEEERemainder function passing
the two values as parameters, and then compare to zero.
The code might look something like

ff.equals(ff.function("IEEERemainder", property, ff.literal(120.0)), 
ff.literal(0))

(haven't actually checked the code).
For more information about IEEERemainer function, see 
java.lang.Math.IEEERemainder javadoc).

If your neeeds are not satisified by the IEEERemainer function
you can create your own by looking at the FilterFunction_IEEERemainer
class and by registering it in the SPI mimicking what's done
in META-INF/services/org.opengis.filter.expression.Function
(basically just cite the full name of your function class).

Hope this helps

-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to