Hello,
This is my first post to this mailing list. My name is Go and I am working for
a civil engineering firm developing web applications with GeoServer.
Recently, I have bumped into an issue when building a SLD for GeoServer which
is reported here in detail.
https://osgeo-org.atlassian.net/browse/GEOS-7768
Out of curiosity, I have attempted to debug geotools to get to the bottom by
myself. The quickstart guide was very helpful.
What I found was, in case of greaterEqualThan filter,
org.geotools.filter.function.FilterFunction_greaterEqualThan.evaluate()
receives expressions as strings and then evaluates them as strings and finally
passes strings to
org.geotools.filter.function.StaticGeometry.greaterEqualThan().
So, no matter which I define numeric params as ogc:Literal or ogc:Function in
the SLD, FilterFunction_greaterEqualThan always performs comparisons in
lexicographical order. The same issue was found in greaterThan, lessEqualThan
and lessThan filters.
To make numeric comparisons happen in these filters, I would suggest to change
their behaviours to make comparisons in lexicographic ordering only when either
one of the expressions were non-numeric. Otherwise, I think there is very
limited use for these comparison filters in layer styling.
The patch will be like the following for all greaterEqualThan, greaterThan,
lessEqualThan and lessThan
Replace lines 46 - 60 of
geotools/modules/library/main/src/main/java/org/geotools/filter/function/FilterFunction_greaterEqualThan.java
with
try { // attempt to get values as numbers and perform conversion
arg0 = (Object) getExpression(0).evaluate(feature,
Long.class).longValue();
arg1 = (Object) getExpression(1).evaluate(feature,
Long.class).longValue();
} catch (Exception wereNotNumbers) // probably a type error
{
try { // attempt to get value and perform conversion
arg0 = (Object) getExpression(0).evaluate(feature);
} catch (Exception e) // probably a type error
{
throw new IllegalArgumentException(
"Filter Function problem for function greaterEqualThan
argument #0 - expected type Object");
}
try { // attempt to get value and perform conversion
arg1 = (Object) getExpression(1).evaluate(feature);
} catch (Exception e) // probably a type error
{
throw new IllegalArgumentException(
"Filter Function problem for function greaterEqualThan
argument #1 - expected type Object");
}
}
Thank you for your consideration in advance.
[WSP_PB_Logo_RGB-192]
Go Sato
GIS Developer | Smart Consulting
WSP Parsons Brinckerhoff in the UK
Email: go.s...@wspgroup.com
www.wsp-pb.com<http://www.wsp-pb.com/>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel