5

There's a WFS I'm accessing via script to pull in features that will match a particular day. The attribute I care about in the output is DATE_TIME. However because it's WFS 1.1.0 it does not support temporal CQL queries (per the GeoServer documentation anyway).

The DATE_TIME values are stored in ISO format, YYYY-MM-DDTHH:mm:ss. I would like to issue a CQL query that will return only rows matching a wild-carded day or month, but have been unable to find examples of this kind of thing that will work with 1.1.0:

/ogc/wfsServer?service=WFS&request=GetFeature&typename=[name]&version=1.1.0&propertyname=DATETIME,EVENT,DESCRIPTION,ETC&[put CQL here to do ONLY RETURN ROWS WHERE DATETIME=2017-01-01%]&maxFeatures=1000&outputFormat=application/json

Not looking for my homework to be done for me - If there is a reference page with examples on this, would be happy for a link, as I haven't turned up anything by googling.

4

Note only a GeoServer based WFS will understand a CQL filter, you can and should use an OGC Filter to achieve this effect too.

You can use one (or more) of the ECQL temporal filters for this. I would probably use something like the following for your query:

 DATE_TIME during 2017-02-28T00:00:00Z/P1D

to find all features that occurred today - the time period can be specified as a Time/Time, Duration/Time or Time/Duration as discussed here.

For reference the OGC Filter is

<?xml version="1.0" encoding="UTF-8"?><fes:Filter xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2">
  <fes:During>
    <fes:ValueReference>DATE_TIME</fes:ValueReference>
          <gml:TimePeriod gml:id="TP1">
     <gml:begin>
        <gml:TimeInstant gml:id="TI1">
           <gml:timePosition>2017-02-28T00:00:00Z</gml:timePosition>
        </gml:TimeInstant>
     </gml:begin>
     <gml:end>
        <gml:TimeInstant gml:id="TI2">
           <gml:timePosition>2017-03-01T00:00:00Z</gml:timePosition>
        </gml:TimeInstant>
     </gml:end>
  </gml:TimePeriod>
  </fes:During>
</fes:Filter>
  • Thanks for the in-depth response, would I just string that along with &FILTER=<?xml version="1.0"..... within the URL then? – auslander Feb 28 '17 at 18:24
  • Really be best to switch to POST for filters – Ian Turton Feb 28 '17 at 18:28
  • If it works though, I should get something back, in a GET request correct? I just want to make sure, because I'm getting an ogc:ServiceException on trying to filter on this when testing via the browser URL bar. – auslander Feb 28 '17 at 18:47
  • You can start from <fes:Filter... but URL-escaping does not always go as it should. However, before doing tests with GET make sure that your filter works as POST. You can use browser add-on like Poster for testing. – user30184 Feb 28 '17 at 21:31
  • 1
    Thanks, what I've found is that this server I'm trying to hit is a homebrew thing, and I am getting java nullpointer exceptions on my web calls - so I'll have to work with the data provider to figure out the next step. However I've marked the question as answered, as this is probably the most helpful breakdown of how to do this sort of thing I've found, and will probably reference it more than once in the future. – auslander Mar 1 '17 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.