.. index:: single: SOS Server .. _sos_server: ***************************************************************************** SOS Server ***************************************************************************** :Author: Jeff McKenna :Contact: jmckenna at gatewaygeomatics.com :Revision: $Revision$ :Date: $Date$ :Last Updated: 2007/12/06 .. contents:: Table of Contents :depth: 2 :backlinks: top Introduction ============ SOS (Sensor Observation Service), currently an OGC discussion paper, is part of of the OGC's SensorWeb Enablement (SWE) group of specifications. These specifications describe how applications and services will be able to access sensors of all types over the Web. Specifically, SOS provides an API for managing deployed sensors and retrieving sensor data. SOS support is **available in MapServer 4.10.0 or more recent**. Note that no client tools currently exist in MapServer for SOS. More SWE based software is available at http://www.52north.org/ SOS support was implemented in MapServer to the guidelines of MapServer :ref:`rfc13`. This document assumes that you are already familiar with certain aspects of MapServer: - MapServer application development and setting up .map files. Links to SOS-Related Information -------------------------------- - `SOS discussion paper`_ - `Sensor Web Enablement and OpenGIS SensorWeb`_ Relevant Definitions -------------------- The following is taken from the SOS discussion paper: Observation An observation is an event with a result which has a value describing some phenomenon. Observation Offering An observation offering is a logical grouping of observations offered by a service that are related in some way. Observed Value A value describing a natural phenomenon, which may use one of a variety of scales including nominal, ordinal, ratio and interval. Sensor An entity capable of observing a phenomenon and returning an observed value. A sensor can be an instrument or a living organism (e.g. a person). Setting Up an SOS Server Using MapServer ======================================== Install the Required Software ----------------------------- SOS requests are handled by the ":ref:`mapserv`" CGI program. The first step is to check that your mapserv executable includes SOS support. One way to verify this is to use the "-v" command-line switch and look for "SUPPORTS=SOS_SERVER". Example 1. On Unix: :: $ ./mapserv -v MapServer version 4.9 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS INPUT=JPEG INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG Example 2. On Windows: :: C:\Apache\cgi-bin> mapserv -v MapServer version 4.9 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS INPUT=JPEG INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG If you don't have SOS support in your MapServer build, then you must compile MapServer with the following in mind: - flag *-DUSE_SOS_SVR* is required - requires either *-DUSE_WMS_SVR* or *-DUSE_WFS_SVR* flags to be enabled - requires libxml2 and proj libraries - requires ICONV support (*-DUSE_ICONV*) on Windows For more help with MapServer compilation see the appropriate HowTo: :ref:`Unix ` / :ref:`Windows ` .. index:: pair: SOS Server; Mapfile Configure a Mapfile For SOS --------------------------- Each instance of SOS server that you setup needs to have its own mapfile. It is just a regular MapServer mapfile in which some parameters and some metadata entries are mandatory. Most of the metadata is required in order to produce a valid GetCapabilites output. Here is the list of parameters and metadata items that usually optional with MapServer, but are **required (or strongly recommended) for a SOS configuration:** **MAP level:** - Map NAME - Map PROJECTION - Map Metadata (in the WEB Object): - sos_title - sos_onlineresource - sos_srs - sos_enable_request - see the `Reference Section`_ of this document for a full list of metadata and descriptions **LAYER level:** - Layer NAME - Layer PROJECTION - Layer METADATA - sos_offering_id - sos_observedproperty_id - sos_observedproperty_id - sos_describesensor_url - see the `Reference Section`_ of this document for a full list of metadata and descriptions Onlineresource URL ################## The sos_onlineresource metadata is set in the map's web object metadata and specifies the URL that should be used to access your server. This is required for the GetCapabilities output. If sos_onlineresource is not provided then MapServer will try to provide a default one using the script name and hostname, but you shouldn't count on that too much. It is strongly recommended that you provide the sos_onlineresource metadata. Here is a valid online resource URL: :: http://my.host.com/cgi-bin/mapserv?map=mysos.map& By creating a wrapper script on the server it is possible to hide the "map=" parameter from the URL and then your server's online resource URL could be something like: :: http://my.host.com/cgi-bin/mapserv? This is covered in more detail in the "More About the Online Resource URL" section of the :ref:`WMS Server ` document. Example SOS Server Mapfile -------------------------- The following is an example of a bare minimum SOS Server mapfile. Note the comments for the required parameters. .. code-block:: mapfile MAP NAME "SOS_DEMO" STATUS ON SIZE 300 300 EXTENT -66 44 -62 45 UNITS METERS SHAPEPATH "./data/" IMAGECOLOR 255 255 0 SYMBOLSET "./etc/symbols.sym" IMAGETYPE png WEB IMAGEPATH "/ms4w/tmp/ms_tmp/" IMAGEURL "/ms_tmp/" METADATA "sos_onlineresource" "http://127.0.0.1/mapserv?map=/sos/sos_test.map" ## REQUIRED "sos_title" "My SOS Demo Server" ## Recommended "sos_srs" "EPSG:4326" ## REQUIRED "sos_enable_request" "*" # Necessary END END PROJECTION "init=epsg:4326" END LAYER NAME "test_sos_layer" METADATA "sos_procedure" "NS01EE0014" ## REQUIRED "sos_offering_id" "WQ1289" ## REQUIRED "sos_observedproperty_id" "Water Quality" ## REQUIRED "sos_describesensor_url" "http://some/url/NS01EE0014.xml" ## REQUIRED END TYPE POINT STATUS ON DATA "sos_test" PROJECTION "init=epsg:4326" END CLASS NAME "water quality" STYLE COLOR 255 0 0 SYMBOL "circle" SIZE 8 END END END END #map Test Your SOS Server -------------------- GetCapabilities Request ####################### The GetCapabilities request allows the clients to retrieve service metadata about a specific service instance. For an SOS service, it allows to identify such things as offerings and observed property available, as well as information on sensors that are used. Using a web browser, access your server's online resource URL to which you add the parameters "SERVICE=SOS&REQUEST=GetCapabilities" to the end, e.g. :: http://my.host.com/cgi-bin/mapserv?MAP=mysos.map&SERVICE=SOS&REQUEST=GetCapabilities If everything went well, you should have a complete XML capabilities document. Search it for the word "WARNING"... MapServer inserts XML comments starting with "