1

How would you query a WFS using relative dates/ranges in a single URL call?

For example, I can do this:

https://my.server/geoserver/ows?service=WFS&version=2.0.0&request=GetFeature&typeNames=domain:dataset&outputFormat=application/json&count=50&cql_filter=(timefield DURING 2019-01-01T00:00:00/2019-01-10T00:00:00) AND ...

This is fine for discrete queries but not for subscription services. If I want to pull "today" minus 365 days, how would I do that?

  • If you can calculate what date is now - 365, you should be able to use the Filter Encoding BegunBy temporal operator – nmtoken Mar 8 at 17:57
  • Yep, easily done with Python. I'm looking to do this entirely in a URL to feed into an ArcGIS Online map for someone who does not have access to run scripts. – auslander Mar 8 at 18:06
  • I understand you want to make it as a single request, the question is whether you can calculate for the request the time you want have as the date-365, or whether you only have the now date. – nmtoken Mar 8 at 18:09
  • It will have to be a fixed duration with a generic stop. I have no ISO-8601 date(s) to use as an input. As @ian-turton commented below it would have to be something like P1Y/PRESENT - except WFS doesn't seem to like that. – auslander Mar 8 at 18:16
0

In WMS you can use P1Y/PRESENT, you may be able to use a similar format in a WFS CQL query.

UPDATE

Looking at the ECQL documentation, it seems as though PRESENT is part of the WMS spec not the ECQL one but you can use a filter like:

time during P1Y / 2019-03-09T00:00:00Z

Which will be converted internally to:

<?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>time</fes:ValueReference>
   <fes:Literal>Period{begin:Instant{position:Position{Fri Mar 09 00:00:00 GMT 2018}}, end:Instant{position:Position{Sat Mar 09 00:00:00 GMT 2019}}}</fes:Literal>
 </fes:During>
</fes:Filter>
  • Yeah, it said Could not parse CQL filter list. Encountered "DURING P1Y / PRESENT" at line 1, column 11. Was expecting one of: "(" ... ":" ... <IDENTIFIER> ... "." ... "*" ... "/" ... "+" ... "-" ... ")" ... "not" ... "in" ... "tequals" ... "before" ... "after" ... "during" <DATE_TIME> ... "during" <DURATION> "/" <DATE_TIME> ... "during" "or" ... "like" ... "ilike" ... "exists" ... "does-not-exist" ... "is" ... "between" ... "=" ... ">" ... "<" ... ">=" ... "<=" ... "<>" ... Parsing : (temporal DURING P1Y/PRESENT) AND... – auslander Mar 8 at 18:04

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.