My app based on Mapserver contains dynamic layers and using PHPMapscript I modify MAPFILE->LAYER->DATA value based on a parameter that comes via GET. Or I could even use RegEXP in the LAYER->DATA (http://osdir.com/ml/mapserver-users-gis/2012-02/msg00208.html)

I know GeoServer has good REST support and most probably after my analysis this will be one of the reasons why I'm going to change.

Is it possible to define a GeoServer layer dynamically? E.G. I will create datastores for specific topics Layers (shp or raster) are stored following the criteria:

/data/layers/topic1/2013/201305/Layer1.shp, /data/layers/topic1/2013/201305/Layer2.shp, /data/layers/topic2/2013/201305/Layer3.shp

/data/layers/raster/2013/201304/Raster1.{png,geotiff,}, /data/layers/raster/2013/201304/Raster2.{png,geotiff,}

The layers change each month and absolutely I don't want to recreate them via GeoServer admin. Using OpenLayers I can pass a parameter mergeNewParams=YYYYMM and get the specific OWS out of the layer (WMS or WFS), but how?

Something like this when I define the datastore URL http://docs.geoserver.org/latest/en/user/webadmin/data/stores.html#adding-a-store in the connection URL I would like to specify file:/data//YYYY/YYYYMM/YYYYMMDDUTC Is it possible?



Yes and No. :)

It's possible to create a datastore dynamically with REST, but not with parameters (I know of no method to do that). But, you can create a script, that use Geoserver REST interface to achieve the aim.

For REST in Geoserver, look the documentation: http://docs.geoserver.org/stable/en/user/rest/api/datastores.html

I recommend to you the "geoserver-manager" Java library, because it's easy way to achieve this funcionality. If you don't want to use Java, you can use "cURL" and follow this example: http://docs.geoserver.org/2.1.x/en/user/restconfig/rest-config-examples/rest-config-examples-curl.html

You can do a monthly task to publish the new datastore and publish the layer.

  • Thanks for replying! Ideally my workflow was to create the layer using GeoServer Admin. Those files (shp and raster) could also be daily following the criteria /data/YYYY/YYYYMM/YYYYMMDD/ doing so I should be able to load WMS <service>*&<layerName>&param=YYYYMMDD. What do you think about the creation of a custom datastore? Is it feasible? – Daviddd Jun 6 '13 at 9:53
  • I don't know if you can add a "param" in layer (please! Geoserver Gurus rescue us! :P), but you can do a script that create a datastore and then publish a layer using the REST Geoserver API. Looking around the documentation, i have seen this feature for 2.4.x branch... docs.geoserver.org/latest/en/user/services/wms/time.html could help you! – Taber Jun 6 '13 at 11:23
  • Thanks again! I knew about WMS Time, but my case is a bit different. We will produce different shape files each day and they must be saved on the disk following the above criteria. – Daviddd Jun 6 '13 at 12:22

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.