[mapserver-commits] r12934 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Fri Dec 30 06:18:31 EST 2011


Author: schpidi
Date: 2011-12-30 03:18:31 -0800 (Fri, 30 Dec 2011)
New Revision: 12934

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapwcs.c
   trunk/mapserver/mapwcs11.c
   trunk/mapserver/mapwcs20.c
Log:
Adjusting WCS GetCapabilities for an empty list of layers (#4140)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-12-29 12:11:50 UTC (rev 12933)
+++ trunk/mapserver/HISTORY.TXT	2011-12-30 11:18:31 UTC (rev 12934)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk, 6.1-dev, future 6.2): 
 -------------------------------------------------
 
+- Adjusted WCS GetCapabilities for an empty list of layers (#4140)
+
 - Adjusted WMS GetCapabilities for an empty list of layers (#3755)
 
 - Refactor cgi masperv to not call exit on argument errors (#3099)

Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c	2011-12-29 12:11:50 UTC (rev 12933)
+++ trunk/mapserver/mapwcs.c	2011-12-30 11:18:31 UTC (rev 12934)
@@ -827,9 +827,9 @@
   msIO_printf("  <Request>\n");
 
   msWCSPrintRequestCapability(params->version, "GetCapabilities", script_url_encoded);
-  if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_TRUE)) 
+  if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_FALSE))
       msWCSPrintRequestCapability(params->version, "DescribeCoverage", script_url_encoded);
-  if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_TRUE)) 
+  if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_FALSE))
       msWCSPrintRequestCapability(params->version, "GetCoverage", script_url_encoded);
  
   msIO_printf("  </Request>\n");
@@ -921,15 +921,21 @@
            "   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" 
            "   xsi:schemaLocation=\"http://www.opengis.net/wcs %s/wcs/%s/wcsCapabilities.xsd\">\n", params->version, params->updatesequence, msOWSGetSchemasLocation(map), params->version); 
 
-  for(i=0; i<map->numlayers; i++) {
-  
+  if(ows_request->numlayers == 0)
+  {
+    msIO_printf("  <!-- WARNING: No WCS layers are enabled. Check wcs/ows_enable_request settings. -->\n");
+  }
+  else
+  {
+    for(i=0; i<map->numlayers; i++) {
       if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
-          continue;
-  
+        continue;
+
       if( msWCSGetCapabilities_CoverageOfferingBrief((GET_LAYER(map, i)), params) != MS_SUCCESS ) {
-          msIO_printf("</ContentMetadata>\n");
-          return MS_FAILURE;
+         msIO_printf("</ContentMetadata>\n");
+         return MS_FAILURE;
       }
+    }
   }
 
   /* done */
@@ -1025,8 +1031,8 @@
     /* print common capability elements  */
     /* TODO: DocType? */
 
-  if (!updatesequence)
-    updatesequence = msStrdup("0");
+    if (!updatesequence)
+      updatesequence = msStrdup("0");
 
     msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), NULL, "wcs_encoding", OWS_NOERR, "<?xml version='1.0' encoding=\"%s\" standalone=\"no\" ?>\n", "ISO-8859-1");
   
@@ -2027,17 +2033,6 @@
         return msWCSException(map, "MissingParameterValue", "request",
                               ows_request->version );
     }
-
-    /* Check the number of enabled layers for the REQUEST */
-    msOWSRequestLayersEnabled(map, "C", ows_request->request, ows_request);
-    if (ows_request->numlayers == 0)
-    {
-        msSetError(MS_WCSERR, "WCS request not enabled. Check "
-                              "wcs/ows_enable_request settings.",
-                              "msWCSDispatch()");
-        return msWCSException(map, "InvalidParameterValue", "request",
-                              ows_request->version );
-    }
     
     if (EQUAL(ows_request->request, "GetCapabilities"))
     {
@@ -2059,6 +2054,28 @@
                               ows_request->version);
     }
     
+    /* Check the number of enabled layers for the REQUEST */
+    msOWSRequestLayersEnabled(map, "C", ows_request->request, ows_request);
+    if (ows_request->numlayers == 0)
+    {
+        int caps_globally_enabled = MS_FALSE, disabled = MS_FALSE;
+        const char *enable_request;
+        if(operation == MS_WCS_GET_CAPABILITIES)
+        {
+            enable_request = msOWSLookupMetadata(&map->web.metadata, "OC", "enable_request");
+            caps_globally_enabled = msOWSParseRequestMetadata(enable_request, "GetCapabilities", &disabled);
+        }
+
+        if(caps_globally_enabled == MS_FALSE)
+        {
+            msSetError(MS_WCSERR, "WCS request not enabled. Check "
+                                  "wcs/ows_enable_request settings.",
+                                  "msWCSDispatch()");
+            return msWCSException(map, "InvalidParameterValue", "request",
+                                  ows_request->version );
+        }
+    }
+
     /* Check the VERSION parameter */
     if (ows_request->version == NULL)
     {

Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c	2011-12-29 12:11:50 UTC (rev 12933)
+++ trunk/mapserver/mapwcs11.c	2011-12-30 11:18:31 UTC (rev 12934)
@@ -491,7 +491,7 @@
 /* -------------------------------------------------------------------- */
 /*      DescribeCoverage                                                */
 /* -------------------------------------------------------------------- */
-        if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_TRUE)) 
+        if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_FALSE))
         {
             psNode = msOWSCommonOperationsMetadataOperation(
                 psOwsNs, psXLinkNs,
@@ -509,7 +509,7 @@
 /* -------------------------------------------------------------------- */
 /*      GetCoverage                                                     */
 /* -------------------------------------------------------------------- */
-        if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_TRUE)) 
+        if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_FALSE))
         {
 
             psNode = msOWSCommonOperationsMetadataOperation(
@@ -549,20 +549,29 @@
     {
         psMainNode = xmlNewChild( psRootNode, NULL, BAD_CAST "Contents", NULL );
 
-        for(i=0; i<map->numlayers; i++)
+        if(ows_request->numlayers == 0)
         {
-            layerObj *layer = map->layers[i];
-            int       status;
-            
-            if(!msWCSIsLayerSupported(layer)) 
-                continue;
-            
-            if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
-                continue;
+            xmlAddChild(psMainNode,
+                    xmlNewComment("WARNING: No WCS layers are enabled. "
+                                  "Check wcs/ows_enable_request settings."));
+        }
+        else
+        {
+            for(i=0; i<map->numlayers; i++)
+            {
+                layerObj *layer = map->layers[i];
+                int       status;
 
-            status = msWCSGetCapabilities11_CoverageSummary( 
-                map, params, req, psDoc, psMainNode, layer );
-            if(status != MS_SUCCESS) return MS_FAILURE;
+                if(!msWCSIsLayerSupported(layer))
+                    continue;
+
+                if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
+                    continue;
+
+                status = msWCSGetCapabilities11_CoverageSummary(
+                    map, params, req, psDoc, psMainNode, layer );
+                if(status != MS_SUCCESS) return MS_FAILURE;
+            }
         }
     }
 

Modified: trunk/mapserver/mapwcs20.c
===================================================================
--- trunk/mapserver/mapwcs20.c	2011-12-29 12:11:50 UTC (rev 12933)
+++ trunk/mapserver/mapwcs20.c	2011-12-30 11:18:31 UTC (rev 12934)
@@ -2893,7 +2893,7 @@
         /* -------------------------------------------------------------------- */
         /*      DescribeCoverage                                                */
         /* -------------------------------------------------------------------- */
-        if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_TRUE)) 
+        if (msOWSRequestIsEnabled(map, NULL, "C", "DescribeCoverage", MS_FALSE))
         {
             psNode = msOWSCommonOperationsMetadataOperation(
                 psOwsNs, psXLinkNs,
@@ -2907,7 +2907,7 @@
         /* -------------------------------------------------------------------- */
         /*      GetCoverage                                                     */
         /* -------------------------------------------------------------------- */
-        if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_TRUE)) 
+        if (msOWSRequestIsEnabled(map, NULL, "C", "GetCoverage", MS_FALSE))
         {
             psNode = msOWSCommonOperationsMetadataOperation(
                 psOwsNs, psXLinkNs,
@@ -2934,24 +2934,33 @@
     {
         psNode = xmlNewChild( psRootNode, psWcsNs, BAD_CAST "Contents", NULL );
 
-        for(i = 0; i < map->numlayers; ++i)
+        if(ows_request->numlayers == 0)
         {
-            layerObj *layer = map->layers[i];
-            int       status;
+            xmlAddChild(psNode,
+                    xmlNewComment(BAD_CAST("WARNING: No WCS layers are enabled. "
+                                  "Check wcs/ows_enable_request settings.")));
+        }
+        else
+        {
+            for(i = 0; i < map->numlayers; ++i)
+            {
+                layerObj *layer = map->layers[i];
+                int       status;
 
-            if(!msWCSIsLayerSupported(layer))
-                continue;
+                if(!msWCSIsLayerSupported(layer))
+                    continue;
 
-            if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
-                continue;
+                if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
+                    continue;
 
-            status = msWCSGetCapabilities20_CoverageSummary(
-                map, params, psDoc, psNode, layer );
-            if(status != MS_SUCCESS)
-            {
-                xmlFreeDoc(psDoc);
-                xmlCleanupParser();
-                return msWCSException(map, "mapserv", "Internal", params->version);
+                status = msWCSGetCapabilities20_CoverageSummary(
+                    map, params, psDoc, psNode, layer );
+                if(status != MS_SUCCESS)
+                {
+                    xmlFreeDoc(psDoc);
+                    xmlCleanupParser();
+                    return msWCSException(map, "mapserv", "Internal", params->version);
+                }
             }
         }
     }



More information about the mapserver-commits mailing list