1

I have an image mosaic in GeoServer with some .tif which its name are the date of that raster:

20190929.tif
20191004.tif
...

So I can load every raster by passing the date in OpenLayers:

date="2019-09-29";

var myTileLayer = new TileLayer({
  source: new TileWMS({
    url: 'http://localhost:8080/geoserver/myworkspace/wms',
    params: {'LAYERS': 'myworkspace:mylayer','TIME':date,'TILED': true},
    serverType: 'geoserver',
  }),
  extent: extent,
});

The problem is that I want that the user could choose the date for example in a calendar (in the example I put the date manually) but for that I need to know which dates are avalaible in the image mosaic so I was trying to search if there was avalaible any get request in GeoServer to retrieve this information like:

curl -u admin:geoserver -XGET localhost:8080/geoserver/rest/layers/myworkspace:mylayer/time.json
//Of course this doesn't work

Expected return:

{
"time":[20190929,20191004]
}

The other approach I think it would be to save this information in a database but that would more complicated.

1
  • 1
    Publish the image mosaic index as a vector layer and you can make pretty useful queries with WFS.
    – user30184
    Oct 17, 2019 at 8:52

1 Answer 1

2

You need to look in the getCapabilities response and within the layer's information there will be a section giving the various extents of the layer:

    <LatLonBoundingBox minx="-179.993" miny="-77.079" maxx="179.999" maxy="86.681"/>
    <BoundingBox SRS="EPSG:4326" minx="-179.993" miny="-77.079" maxx="179.999" maxy="86.681"/>
    <Dimension name="time" units="ISO8601"/>
    <Extent name="time" default="2012-12-29T00:00:00Z">1900-07-29T00:00:00.000Z/2012-12-29T00:00:00.000Z/P1D</Extent>

So this is saying that my layer has data from midnight 1900-07-29 to midnight 2012-12-29 and that is available in intervals of one day (P1D). The full range of possible values and periods is explained in the manual.

The format of the time extend depends on how you have configured your layer and might contain a list of all of the available times or start/end times with periods, so to be general your code should handle both formats.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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