I'm doing some experiments with date-time filtering on GeoTools/GeoServer ... what I have noticed is as follows:
1) With WFS all works fine; it seems that the filtering is passed directly to the Datastore which builds a query and retrieves the needed features
this is an example of the request:
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:nurc="http://www.nurc.nato.int"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Query typeName="nurc:Main">
<!--wfs:PropertyName>nurc:Source</wfs:PropertyName>
<wfs:PropertyName>nurc:Date</wfs:PropertyName-->
<ogc:Filter>
<ogc:And>
<ogc:BBOX>
<ogc:PropertyName>the_geom</ogc:PropertyName>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coordinates>8.2768,43.3032 8.361859,43.4140</gml:coordinates>
</gml:Box>
</ogc:BBOX>
<ogc:PropertyIsBetween>
<ogc:PropertyName>Date</ogc:PropertyName>
<ogc:LowerBoundary>
<ogc:Literal>1982-07-15T00:00:00Z</ogc:Literal>
</ogc:LowerBoundary>
<ogc:UpperBoundary>
<ogc:Literal>1982-07-17T00:00:00Z</ogc:Literal>
</ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:And>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
2) Using the StreamingRenderer we have several problems ... look at this URL
http://.../geoserver/wms?bbox=8.2768,43.3032,8.361859,43.4140&Format=image/png&request=GetMap&width=550&height=250&srs=EPSG:4326 ...
&SLD_BODY=%3CStyledLayerDescriptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3Enurc:Main%3C/Name%3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFeatureTypeStyle%3E%3CRule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/gml%22%3E%3CPropertyIsBetween%3E%3CPropertyName%3EDate%3C/PropertyName%3E%3CLowerBoundary%3E%3CLiteral%3E1982-07-16T00:00:00Z%3C/Literal%3E%3C/LowerBoundary%3E%3CUpperBoundary%3E%3CLiteral%3E1983-01-01T00:00:00Z%3C/Literal%3E%3C/UpperBoundary%3E%3C/PropertyIsBetween%3E%3C/Filter%3E%3CPointSymbolizer%3E%3CGraphic%3E%3CMark%3E%3CWellKnownName%3Ecircle%3C/WellKnownName%3E%3CFill%3E%3CCssParameter%20name%3D%22fill%22%3E%23EDE513%3C/CssParameter%3E%3CCssParameter%20name%3D%22fill-opacity%22%3E1.0%3C/CssParameter%3E%3C/Fill%3E%3C/Mark%3E%3CSize%3E7%3C/Size%3E%3C/Graphic%3E%3C/PointSymbolizer%3E%3C/Rule%3E%3CRule%3E%3CLineSymbolizer%3E%3CStroke/%3E%3C/LineSymbolizer%3E%3C/Rule%3E%3C/FeatureTypeStyle%3E%3C/UserStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E
The SLD_BODY specifies exactly the same filter of the point 1.
Looking at the StreamingRenderer, in the processSymbolizers method it does a filter.contains(feature) (or filter.evaluate(feature)) passing the _expression_ to the specific Filter implementation.
Check this piece of code of the BetweenFilterImpl
public boolean evaluate(Feature feature) {
...
Object leftObj = expression1.evaluate(feature);
Object rightObj = expression2.evaluate(feature);
Object middleObj = middleValue.evaluate(feature);
...
if (leftObj instanceof Number &&
middleObj instanceof Number &&
rightObj instanceof Number) {
...
} else if (leftObj.getClass() == middleObj.getClass() &&
rightObj.getClass() == middleObj.getClass() &&
leftObj instanceof Comparable) {
...
} else {
String mesg = "Supplied between values are either not " +
"compatible or not supported for comparison: " + leftObj +
" <= " + middleObj + " <= " + rightObj;
throw new IllegalArgumentException(mesg);
}
As you can see it gets the objects from the feature and filter; the result is that leftObj and rightObj are of type String and middleObj is of type sql.Date
and the Filter throws ever an IllegalArgumentException without evaluating the _expression_.
What do you think about that? How we can solve this problem?
In my opinion the solutions can be two:
1 - Add another "else if" to the FilterImpl which evaluates the case when we have Date and String objects
2 - Modify the StreamingRenderer in order to force him filtering against Datastores
Regards,
Alessio.
--
-------------------------------------------------------
Eng. Alessio Fabiani
Vice President/CTO GeoSolutions
http://www.geo-solutions.it
---------------------------------------------------------
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
