[mapserver-users] Extracting Year, Month, Day from WMS time query

Sommer, Ashley (L&W, Dutton Park) Ashley.Sommer at csiro.au
Mon Jul 26 20:57:10 PDT 2021


Hi All,

I'm trying to get a very specific configuration working in my mapfile.

I have geotiff files in a directory structure that looks like:
http://example.org/v1/AUTH_xyz/my-dataset/YYYY/YYYY_MM_DD/product_name_YYYY_MM_DD.vrt
Where YYYY is a year (eg 2018) and YYYY_MM_DD is a date (eg 2018_08_01)

EG:
DATA "/vsicurl/http://example.org/v1/AUTH_xyz/my-dataset/2018/2018_08_01/product_name_2018_08_01.vrt"

I'm trying to get this working with a dynamic mapfile, with runtime substitution, and ideally, I'd also like it to work with WMS Time queries.

I've found that the WMS TIME query parameter doesn't automatically work with runtime substitution. It can be used as an attribute [TIME] in a FILTER, or in an EXPRESSION, but nowhere else.
To work around that, I've set up a Runtime Substitution variable also named time:

VALIDATION
    "time" "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
END

That works, it captures the right variable and allows me to use the WMS-provided TIME param in the DATA directive like:
LAYER
  DATA "/vsicurl/http://example.org/v1/AUTH_xyz/my-dataset/2018/%time%/product_name_%time%.vrt"

But that doesn't quite match the naming scheme of the dataset.
In order for this to work properly, I need to be able to extract the year, month and day portions of the datestring, and use them individually.
Like:
DATA "/vsicurl/http://example.org/v1/AUTH_xyz/my-dataset/%year%/%year%_%month%_%day%/product_name_%year%_%month%_%day%.vrt"

I've read the documentation around WMS_Time and Runtime Substitution, but I can't quite work out if this is even possible.
Note, I understand I could probably do this at the apache level, by transforming the query with a rewrite eg:
"&TIME=2018-08-01" -> "&TIME=2018-08-01&YEAR=2018&MONTH=08&DAY=01"
But I'd prefer to do it at the Mapfile level.

- Ashley Sommer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20210727/02073c70/attachment.htm>


More information about the MapServer-users mailing list