In one of our projects we got a huge amount of georeferenced plane survey sheets (see Fig.1). Because of their thematically link we published them within one time enabled Web Mapping Service (WMS) and Web Coverage Service (WCS) layer. The main goal of the WMS and WCS was to support reasearchers and other stakeholder by using our map data within there local reasearch environment (e.g. DesktopGIS). After a couple of months I got a call from a person from another state department. The person was quite happy about our data and the possibilitie to consume it also via GI-Services. But she had a hard time to figure out how to integrate the time enabled services in their DesktopGIS. I haven't a complete overview about the support of time enabled GI-Service through the classical DesktopGIS systems, but it seems that is still not the best. I managed to help on the phone, but after that I though about the cons of the time enabled Service solution, which is basically his higher rate of complexity.
Figure 1.: digital georeferenced plane survey sheet
On the next morning I tried an alternative approach. Normally the most person request only a single or a few plane survey sheets. Because we already use the UMN Mapserver software for publishing our WMS and WCS I would like to stick with this software. A single service wherein every plane survey sheet would be represetend through a single layer was not a solution for me. This would mean we would blast our mapfiles with over 6.000 layer what would make it slow and hard to manage. Also to produce >6.000 services with a single layer was not the best option for me. This would mean I got a folder with over 6.000 files, which also wasn't really appealing for me.
Finally I decide to use Mapscript and developed a small script who checks if there does a exist a service for a given service name and if not to create one from a template and information queried from a database. The script looks basically like this.
#!/usr/bin/env python # This scripts parse the WMS service request and checks if a matching mapfile exist. If not it create one. # Dependencies: python-psycopg2, python-mapscript # @author: jacmendt import cgi, os, psycopg2 from mapscript import mapObj, OWSRequest # Configuration parameters ... # utility functions ... # This part parses the request and builds the mapfile # initialize service request wmsRequest = OWSRequest() wmsRequest.loadParams() # parse map parameter and check if it exist mapfileId = wmsRequest.getValueByName('map') mapfilePath = os.path.join(MAPFILE_DIR, mapfileId + '.map') if os.path.exists(mapfilePath): # initialize mapfile and dispatch request wmsMap = mapObj(mapfilePath) wmsMap.OWSDispatch(wmsRequest) else: # copy mapfile wmsMap = mapObj(MAPFILE_TEMPLATE).clone() updateMapObj(wmsMap, mapfileId) wmsMap.save(mapfilePath) wmsMap.OWSDispatch(wmsRequest)
The complete script can be found on GitHub together with the used template file.