[MapServer-users] mapserver v8.0.0, ogcapi feature and datetime/time

Trygve Aspenes trygve at aspenes.priv.no
Wed Nov 9 03:30:57 PST 2022


Hi

I have been looking at mapserver v8.0.0 and the ogcapi feature.

As far as I understand from documentation only the feature ogcapi is 
implemented https://mapserver.org/ogc/ogc_api.html#table-of-contents

I follow this and get the api working, i.e. I get up the website(using 
the templates from share/ogcapi/templates/html-bootstrap4.). When I try 
it out using Get <layer> items I fill in bbox coordinates and get 
expected results. Doing the same on command line with f=json I get 
something like:

{"features":[{"geometry":{"coordinates":[12.15,50.074201],"type":"Point"},"id":"1","properties":{"ID":1,"epoch":1371747619.972},"type":"Feature"},{"geometry":{"coordinates":[10.8405,48.6999],"type":"Point"},"id":"5","properties":{"ID":5,"epoch":1371747620.317},"type":"Feature"},{"geometry":{"coordinates":[11.5641,52.026301],"type":"Point"},"id":"6","properties":{"ID":6,"epoch":1371747620.319},"type":"Feature"},{"geometry":{"coordinates":[12.2634,50.5764],"type":"Point"},"id":"7","properties":{"ID":7,"epoch":1371747620.325},"type":"Feature"},{"geometry":{"coordinates":[10.843201,48.2706],"type":"Point"},"id":"10","properties":{"ID":10,"epoch":1371747620.613},"type":"Feature"},{"geometry":{"coordinates":[12.7035,50.6439],"type":"Point"},"id":"11","properties":{"ID":11,"epoch":1371747620.62},"type":"Feature"},{"geometry":{"coordinates":[12.285,51.300001],"type":"Point"},"id":"12","properties":{"ID":12,"epoch":1371747620.72},"type":"Feature"},{"geometry":{"coordinates":[16.278301,52.5042
01],"type":"Point"},"id":"13","properties":{"ID":13,"epoch":1371747620.73},"type":"Feature"},{"geometry":{"coordinates":[12.2256,51.624],"type":"Point"},"id":"14","properties":{"ID":14,"epoch":1371747620.782},"type":"Feature"},{"geometry":{"coordinates":[10.8864,48.9861],"type":"Point"},"id":"15","properties":{"ID":15,"epoch":1371747620.787},"type":"Feature"}],"links":[{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&limit=10&offset=0","rel":"self","title":"Items 
for this collection as 
GeoJSON","type":"application/geo+json"},{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=html&limit=10&offset=0","rel":"alternate","title":"Items 
for this collection as 
HTML","type":"text/html"},{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&limit=10&offset=10","rel":"next","title":"next 
page","type":"application/geo+json"}],"numberMatched":516,"numberReturned":10,"type":"FeatureCollection"}

But I don't understand how to use the datetime. I see from the ogcapi 
features docs that this is required: 
https://docs.opengeospatial.org/is/17-069r3/17-069r3.html#_parameter_datetime 
in the implementation. So that's fine.

I have an idea that the datetime should work using run-time substitution 
https://mapserver.org/cgi/runsub.html#table-of-contents
so I construct my layer query(my data is sqlite)

         CONNECTIONTYPE OGR
         CONNECTION "<path to my .sqlite>"
         DATA "select ogc_fid as ID, * from li_spatialite_demo where 
epoch > unixepoch('%datetime%')-1 and epoch <= 
unixepoch('%datetime%')+1"

But this does not seem to work, at least return no features; no error 
messages in the log as far as I can see
curl -s 
'http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&bbox=0,40,20,60&datetime=2013-06-20T07%3A00%3A00Z&offset=0&limit=10'
{"features":[],"links":[{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&limit=10&offset=0","rel":"self","title":"Items 
for this collection as 
GeoJSON","type":"application/geo+json"},{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=html&limit=10&offset=0","rel":"alternate","title":"Items 
for this collection as 
HTML","type":"text/html"}],"numberMatched":0,"numberReturned":0,"type":"FeatureCollection"}

If I hardcode in DATA for datetime I get one feature as expected:
         DATA "select ogc_fid as ID, * from li_spatialite_demo where 
epoch > unixepoch('2013-06-20T07:00:00Z')-1 and epoch <= 
unixepoch('2013-06-20T07:00:00Z')+1"

curl -s 
'http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&bbox=0,40,20,60&offset=0&limit=10'
{"features":[{"geometry":{"coordinates":[6.9066,49.8582],"type":"Point"},"id":"602","properties":{"ID":602,"epoch":1371711600.409},"type":"Feature"}],"links":[{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=json&limit=10&offset=0","rel":"self","title":"Items 
for this collection as 
GeoJSON","type":"application/geo+json"},{"href":"http://localhost:8080/mapserverapi/test_mapfile/ogcapi/collections/li_spatialite_demo_wfs/items?f=html&limit=10&offset=0","rel":"alternate","title":"Items 
for this collection as 
HTML","type":"text/html"}],"numberMatched":1,"numberReturned":1,"type":"FeatureCollection"}

If I change the DATA to this:
         DATA "select ogc_fid as ID, * from li_spatialite_demo"
I get expected features, but of course datetime is not used

This got a bit long, but my question is how to use the datetime query 
parameter with mapserver ogcapi features.

Trygve Aspenes


More information about the MapServer-users mailing list