geoserverwmsweb-feature-service

WFS GetFeature query with time parameter does not filter in geoserver


I am trying to get some data filtered by date in GML format by using WFS GetFeature in geoserver, but the operation ignores the time parameter and just returns a huge GML file with all the data. This is the query I am using:

http://localhost:8082/geoserver/it.geosolutions/ows?service=WFS&version=1.2.0&request=GetFeature&typeName=it.geosolutions:tsige&time=2011-07-25T00:00:00.0Z/2011-07-25T23:59:59.999Z

According to this, the time parameter should be supported in WFS GetFeature operation, so I do not know what is wrong. Also, what are the alternatives I have for getting the data filtered by time in XML or JSON format, or some other easy-to-parse format?


Solution

  • Not all vendor implementations support all parameters, one of the joys of working with OGC services. Also note that GeoServer implements WFS 1.0.0, 1.1.0 and 2.0.0 (not 1.2.0 in your sample above)

    You can do what you want with a (relatively verbose) POST request using an OGC filter, this might work with a GET but I'll leave that as an exercise for the reader...

    <wfs:GetFeature 
      xmlns:ogc="http://www.opengis.net/ogc"
      xmlns:gml="http://www.opengis.net/gml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:ows="http://www.opengis.net/ows"
      xmlns:wfs="http://www.opengis.net/wfs"
      xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"
    service="WFS" version="1.1.0" outputFormat="JSON">
      <wfs:Query typeName="it.geosolutions:tsige" srsName="EPSG:4326">
        <ogc:Filter>
          <ogc:And>
            <ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyName>your-time-variabe-here</ogc:PropertyName>
              <ogc:Function name="dateParse">
                <ogc:Literal>yyyy-MM-dd</ogc:Literal>
                <ogc:Literal>2011-07-25</ogc:Literal>
              </ogc:Function>
            </ogc:PropertyIsGreaterThanOrEqualTo>
            <ogc:PropertyIsLessThan>
              <ogc:PropertyName>your-time-variable-here</ogc:PropertyName>
              <ogc:Function name="dateParse">
                <ogc:Literal>yyyy-MM-dd</ogc:Literal>
                <ogc:Literal>2011-07-26</ogc:Literal>
              </ogc:Function>
            </ogc:PropertyIsLessThan>
          </ogc:And>
        </ogc:Filter>
      </wfs:Query>
    </wfs:GetFeature>
    

    You could test this using curl with the request saved as wfs.xml

    curl -d @wfs.xml -H "Content-Type: application/xml" "http://localhost:8082/geoserver/it.geosolutions/ows"