[mapserver-commits] r11035 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Mar 1 09:18:47 EST 2011


Author: aboudreault
Date: 2011-03-01 06:18:47 -0800 (Tue, 01 Mar 2011)
New Revision: 11035

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapobject.c
   trunk/mapserver/mapogcsos.c
   trunk/mapserver/mapows.c
   trunk/mapserver/mapows.h
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapwcs.c
   trunk/mapserver/mapwcs11.c
   trunk/mapserver/mapwcs20.c
   trunk/mapserver/mapwfs.c
   trunk/mapserver/mapwfs11.c
   trunk/mapserver/mapwms.c
Log:
Implemented RFC 67: Enable/Disable layers in ogc web services (#3703)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/HISTORY.TXT	2011-03-01 14:18:47 UTC (rev 11035)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Implemented RFC 67: Enable/Disable layers in ogc web services (#3703)
+
 - Class title can now be used in legends. It's value takes precedence over class name. Previously
   title was not used any place in the code but it is supported for read/write. (#3702)
 

Modified: trunk/mapserver/mapobject.c
===================================================================
--- trunk/mapserver/mapobject.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapobject.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -805,6 +805,7 @@
 #ifdef USE_WMS_SVR
     int version;
     char *wms_exception_format = NULL;
+    const char *wms_request= NULL;
     int i =0;
 
     version = msOWSParseVersionString(wmtver);
@@ -812,9 +813,12 @@
      {
          if (strcasecmp(request->ParamNames[i], "EXCEPTIONS") == 0)
            wms_exception_format = request->ParamValues[i];
+         else if (strcasecmp(request->ParamNames[i], "REQUEST") == 0)
+             wms_request = request->ParamValues[i];
+
      }
-    return msWMSLoadGetMapParams(map, version, request->ParamNames,
-                                 request->ParamValues, request->NumParams,  wms_exception_format);
+     return msWMSLoadGetMapParams(map, version, request->ParamNames,
+                                  request->ParamValues, request->NumParams,  wms_exception_format, wms_request);
 #else
     msSetError(MS_WMSERR, "WMS server support is not available.",
                "msMapLoadOWSParameters()");

Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapogcsos.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -1373,7 +1373,6 @@
     /*Offerings */
      psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Contents", NULL);
      psMainNode = xmlNewChild(psNode, NULL, BAD_CAST "ObservationOfferingList", NULL);
-                                             
      
      /*go through the layers and check for metadata sos_offering_id.
        One or more layers could have the same offering id. In that case they
@@ -1394,7 +1393,7 @@
                 continue;
 
              value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_id");
-             if (value)
+             if (value && (msOWSRequestIsEnabled(map, lp, "S", "GetCapabilities")))
              {
                  nCurrentOff = -1;
                  for (j=0; j<nOfferings; j++)
@@ -1415,7 +1414,7 @@
                  }
              }
          }
-
+         
          if (nOfferings > 0)
          {
              for (i=0; i<nOfferings; i++)
@@ -1868,8 +1867,9 @@
 
   /*validate if offering exists*/
   for (i=0; i<map->numlayers; i++) {
-    pszTmp = msOWSLookupMetadata(&(GET_LAYER(map, i)->metadata), "S", "offering_id");
-    if (pszTmp && (strcasecmp(pszTmp, sosparams->pszOffering) == 0))
+      pszTmp = msOWSLookupMetadata(&(GET_LAYER(map, i)->metadata), "S", "offering_id");
+    if (pszTmp && (strcasecmp(pszTmp, sosparams->pszOffering) == 0) && 
+        (msOWSRequestIsEnabled(map, GET_LAYER(map, i), "S", "GetObservation")))
       break;
   }
 
@@ -2650,7 +2650,8 @@
         if (tokens[k] && strlen(tokens[k]) > 0) {
           pszProcedureURI = msStrdup("urn:ogc:def:procedure:");
           pszProcedureURI = msStringConcatenate(pszProcedureURI, tokens[k]);
-          if (pszProcedureURI && strcasecmp(pszProcedureURI, sosparams->pszProcedure) == 0) {
+          if ( (pszProcedureURI && strcasecmp(pszProcedureURI, sosparams->pszProcedure) == 0) &&
+               (msOWSRequestIsEnabled(map, lp, "S", "DescribeSensor")) ) {
             bFound = 1; 
             pszProcedureId = msStrdup(tokens[k]);
             msFree(pszProcedureURI);

Modified: trunk/mapserver/mapows.c
===================================================================
--- trunk/mapserver/mapows.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapows.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -142,6 +142,117 @@
 
 
 /*
+** msOWSRequestIsEnabled()
+**
+** Check if a layer is visible for a specific OWS request.
+**
+** 'namespaces' is a string with a letter for each namespace to lookup 
+** in the order they should be looked up. e.g. "MO" to lookup wms_ and ows_
+** If namespaces is NULL then this function just does a regular metadata
+** lookup.
+*/
+int msOWSRequestIsEnabled(mapObj *map, layerObj *layer, 
+                          const char *namespaces, const char *request)
+{
+    int disabled = MS_FALSE; /* explicitly disabled flag */
+    
+    if (request == NULL)
+        return MS_FALSE;
+
+    /* First, we check in the layer metadata */
+    const char *enable_request = msOWSLookupMetadata(&layer->metadata, namespaces, "enable_request");
+    if (msOWSParseRequestMetadata(enable_request, request, &disabled))
+        return MS_TRUE;
+    if (disabled) return MS_FALSE;
+
+    enable_request = msOWSLookupMetadata(&layer->metadata, "O", "enable_request");
+    if (msOWSParseRequestMetadata(enable_request, request, &disabled))
+        return MS_TRUE;
+    if (disabled) return MS_FALSE;
+
+    /* then we check in the map metadata */
+    enable_request = msOWSLookupMetadata(&map->web.metadata, namespaces, "enable_request");
+    if (msOWSParseRequestMetadata(enable_request, request, &disabled))
+        return MS_TRUE;
+    if (disabled) return MS_FALSE;
+    
+    enable_request = msOWSLookupMetadata(&map->web.metadata, "O", "enable_request");
+    if (msOWSParseRequestMetadata(enable_request, request, &disabled))
+        return MS_TRUE;
+    if (disabled) return MS_FALSE;
+    
+    return MS_FALSE;
+}
+
+/* msOWSParseRequestMetadata 
+ *  
+ * This function parse a enable_request metadata string and check if the
+ * given request is present and enabled.
+ */
+int msOWSParseRequestMetadata(const char *metadata, const char *request, int *disabled)
+{
+    char requestBuffer[32];
+    int wordFlag = MS_FALSE;
+    int disableFlag = MS_FALSE;
+    int allFlag = MS_FALSE;
+    char *bufferPtr, *ptr = NULL;
+    int i;
+    size_t len = 0;
+
+    *disabled = MS_FALSE;
+    
+    if (metadata == NULL)
+        return MS_FALSE;
+
+    ptr = (char*)metadata;
+    len = strlen(ptr);
+    requestBuffer[0] = '\0';
+    bufferPtr = requestBuffer;
+    
+    for (i=0; i<=len;++i,++ptr) {
+        
+        if (!wordFlag && isspace(*ptr))
+            continue;
+        
+        wordFlag = MS_TRUE;
+        
+        if (*ptr == '!') {
+            disableFlag = MS_TRUE;
+            continue;
+        }
+        else if ( (*ptr == ' ') || (ptr[1] == '\0')) { /* end of word */
+            if (ptr[1] == '\0') {
+                *bufferPtr = *ptr;
+                ++bufferPtr;
+            }
+            
+            *bufferPtr = '\0'; 
+            if (strcasecmp(request, requestBuffer) == 0) {
+                *disabled =  MS_TRUE; /* explicitly disabled, will stop the process in msOWSRequestIsEnabled() */
+                return (disableFlag ? MS_FALSE:MS_TRUE);
+            }
+            else {
+                if (strcmp("*", requestBuffer) == 0) { /* check if we read the all flag */
+                    if (disableFlag)
+                        *disabled =  MS_TRUE;
+                    allFlag = disableFlag ? MS_FALSE:MS_TRUE;
+                }
+                /* reset flags */
+                wordFlag = MS_FALSE;
+                disableFlag = MS_FALSE;
+                bufferPtr = requestBuffer;
+            }
+        }
+        else {
+            *bufferPtr = *ptr;
+            ++bufferPtr;
+        } 
+    }
+    
+    return allFlag;
+}
+
+/*
 ** msOWSLookupMetadata()
 **
 ** Attempts to lookup a given metadata name in multiple OWS namespaces.
@@ -754,7 +865,7 @@
 
     for (i=0; i<map->numlayers; i++)
     {
-       if (GET_LAYER(map, i)->group && (strcmp(GET_LAYER(map, i)->group, pszGroupName) == 0) && &(GET_LAYER(map, i)->metadata))
+        if (GET_LAYER(map, i)->group && (strcmp(GET_LAYER(map, i)->group, pszGroupName) == 0) && &(GET_LAYER(map, i)->metadata))
        {
          if((value = msOWSLookupMetadata(&(GET_LAYER(map, i)->metadata), namespaces, name)))
          { 

Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapows.h	2011-03-01 14:18:47 UTC (rev 11035)
@@ -113,6 +113,10 @@
                                                 hashTableObj *sec,
                                                 const char *namespaces,
                                                 const char *name);
+MS_DLL_EXPORT int msOWSRequestIsEnabled(mapObj *map, layerObj *layer, 
+                                        const char *namespaces, const char *name);
+MS_DLL_EXPORT int msOWSParseRequestMetadata(const char *metadata, const char *request, 
+                                            int *disabled);
 
 /* Constants for OWS Service version numbers */
 #define OWS_0_1_2   0x000102
@@ -358,7 +362,8 @@
  *====================================================================*/
 int msWMSDispatch(mapObj *map, cgiRequestObj *req, int force_wms_mode); 
 MS_DLL_EXPORT int msWMSLoadGetMapParams(mapObj *map, int nVersion,
-                                        char **names, char **values, int numentries, char *wms_exception_format);
+                                        char **names, char **values, int numentries, 
+                                        char *wms_exception_format, const char *wms_request);
 
 
 /*====================================================================

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapserver.h	2011-03-01 14:18:47 UTC (rev 11035)
@@ -1845,6 +1845,7 @@
 MS_DLL_EXPORT char *msTryBuildPath3(char *szReturnPath, const char *abs_path, const char *path1, const char *path2);
 MS_DLL_EXPORT char **msStringSplit(const char *string, char cd, int *num_tokens);
 MS_DLL_EXPORT char ** msStringSplitComplex( const char * pszString, const char * pszDelimiters, int *num_tokens, int nFlags);
+MS_DLL_EXPORT int msStringArrayContains(char **array, const char *element, int numElements);
 MS_DLL_EXPORT char **msStringTokenize( const char *pszLine, const char *pszDelim, int *num_tokens, int preserve_quote);
 MS_DLL_EXPORT int msCountChars(char *str, char ch);
 MS_DLL_EXPORT char *msLongToString(long value);

Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwcs.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -750,8 +750,11 @@
            "   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++)
-  {
+  for(i=0; i<map->numlayers; i++) {
+  
+      if (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "GetCapabilities"))
+          continue;
+  
       if( msWCSGetCapabilities_CoverageOfferingBrief((GET_LAYER(map, i)), params) != MS_SUCCESS ) {
           msIO_printf("</ContentMetadata>\n");
           return MS_FAILURE;
@@ -1191,7 +1194,9 @@
           
         for(i=0; i<map->numlayers; i++) {
           coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata), "COM", "name", GET_LAYER(map, i)->name);
-          if( EQUAL(coverageName, coverages[k]) ) break;
+          if( EQUAL(coverageName, coverages[k]) &&
+              (msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "DescribeCoverage")) )
+              break;
         }
 
         /* i = msGetLayerIndex(map, coverages[k]); */
@@ -1237,8 +1242,12 @@
       }
     }
   } else { /* return all layers */
-    for(i=0; i<map->numlayers; i++)
-      msWCSDescribeCoverage_CoverageOffering((GET_LAYER(map, i)), params);
+      for(i=0; i<map->numlayers; i++) {
+          if (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "DescribeCoverage"))
+              continue;
+
+          msWCSDescribeCoverage_CoverageOffering((GET_LAYER(map, i)), params);
+      }
   }
 
  
@@ -1455,7 +1464,8 @@
   lp = NULL;
   for(i=0; i<map->numlayers; i++) {
      coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata), "COM", "name", GET_LAYER(map, i)->name);
-    if( EQUAL(coverageName, params->coverages[0]) ) {
+    if( EQUAL(coverageName, params->coverages[0]) &&
+        (msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "GetCoverage")) ) {
       lp = GET_LAYER(map, i);
       break;
     }

Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwcs11.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -545,6 +545,9 @@
             if(!msWCSIsLayerSupported(layer)) 
                 continue;
             
+            if (!msOWSRequestIsEnabled(map, layer, "C", "GetCapabilities"))
+                continue;
+
             status = msWCSGetCapabilities11_CoverageSummary( 
                 map, params, req, psDoc, psMainNode, layer );
             if(status != MS_SUCCESS) return MS_FAILURE;
@@ -882,7 +885,8 @@
     if(params->coverages) { /* use the list */
         for( j = 0; params->coverages[j]; j++ ) {
             i = msGetLayerIndex(map, params->coverages[j]);
-            if(i == -1) {
+            if ( (i == -1) || (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "DescribeCoverage")) )
+            {
                 msSetError( MS_WCSERR,
                             "COVERAGE %s cannot be opened / does not exist",
                             "msWCSDescribeCoverage()", params->coverages[j]);
@@ -932,10 +936,15 @@
                                                         psOwsNs );
         }
     } else { /* return all layers */
-        for(i=0; i<map->numlayers; i++)
+        for(i=0; i<map->numlayers; i++) {
+
+            if (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "DescribeCoverage"))
+                continue;
+
             msWCSDescribeCoverage_CoverageDescription11((GET_LAYER(map, i)), 
                                                         params, psRootNode,
                                                         psOwsNs );
+        }
     }
   
 /* -------------------------------------------------------------------- */

Modified: trunk/mapserver/mapwcs20.c
===================================================================
--- trunk/mapserver/mapwcs20.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwcs20.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -2789,6 +2789,9 @@
             if(!msWCSIsLayerSupported(layer))
                 continue;
 
+            if (!msOWSRequestIsEnabled(map, layer, "C", "GetCapabilities"))
+                continue;
+
             status = msWCSGetCapabilities20_CoverageSummary(
                 map, params, psDoc, psNode, layer );
             if(status != MS_SUCCESS)
@@ -2988,7 +2991,7 @@
         for (j = 0; params->ids[j]; j++)
         {
             i = msGetLayerIndex(map, params->ids[j]);
-            if (i == -1)
+            if (i == -1 || (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "DescribeCoverage")) )
             {
                 msSetError(MS_WCSERR, "Unknown coverage: (%s)",
                         "msWCSDescribeCoverage20()", params->ids[j]);
@@ -3258,7 +3261,7 @@
         coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata),
                                               "COM", "name",
                                               GET_LAYER(map, i)->name);
-        if (EQUAL(coverageName, params->ids[0]))
+        if (EQUAL(coverageName, params->ids[0]) && (msOWSRequestIsEnabled(map, GET_LAYER(map, i), "C", "GetCoverage")))
         {
             layer = GET_LAYER(map, i);
             i = map->numlayers; /* to exit loop don't use break, we want to free resources first */

Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwfs.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -801,6 +801,10 @@
       if (lp->status == MS_DELETE)
          continue;
 
+      if (!msOWSRequestIsEnabled(map, lp, "F", "GetCapabilities"))
+          continue;
+
+      printf("passed\n");
       /* List only vector layers in which DUMP=TRUE */
       if (msWFSIsLayerSupported(lp))
       {
@@ -1120,7 +1124,8 @@
   /* Validate layers */
   if (numlayers > 0) {
     for (i=0; i<numlayers; i++) {
-      if (msGetLayerIndex(map, layers[i]) < 0) {
+        int index = msGetLayerIndex(map, layers[i]);
+        if ( (index < 0) || (!msOWSRequestIsEnabled(map, GET_LAYER(map, index), "F", "DescribeFeatureType")) ) {
 	      msSetError(MS_WFSERR, "Invalid typename (%s).", "msWFSDescribeFeatureType()", layers[i]);/* paramsObj->pszTypeName); */
               return msWFSException(map, "typename", "InvalidParameterValue", paramsObj->pszVersion);
       }
@@ -1238,7 +1243,8 @@
       bFound = 1;
     }
 
-    if ((numlayers == 0 || bFound) && msWFSIsLayerSupported(lp)) {
+    if ((numlayers == 0 || bFound) && msWFSIsLayerSupported(lp) && 
+        (msOWSRequestIsEnabled(map, lp, "F", "DescribeFeatureType"))) {
 
       /*
       ** OK, describe this layer IF you can open it and retrieve items
@@ -1726,7 +1732,8 @@
 
 	lp = GET_LAYER(map, j);
 	
-	if (msWFSIsLayerSupported(lp) && lp->name && strcasecmp(lp->name, layers[k]) == 0) {
+	if (msWFSIsLayerSupported(lp) && lp->name && (strcasecmp(lp->name, layers[k]) == 0) && 
+            (msOWSRequestIsEnabled(map, lp, "F", "GetFeature"))) {
 	  bLayerFound = MS_TRUE;
 	  
 	  lp->status = MS_ON;

Modified: trunk/mapserver/mapwfs11.c
===================================================================
--- trunk/mapserver/mapwfs11.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwfs11.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -428,6 +428,9 @@
      {
          layerObj *lp;
          lp = GET_LAYER(map, i);
+         
+         if (!msOWSRequestIsEnabled(map, lp, "F", "GetCapabilities"))
+             continue;
 
          /* List only vector layers in which DUMP=TRUE */
          if (msWFSIsLayerSupported(lp))

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2011-03-01 04:45:18 UTC (rev 11034)
+++ trunk/mapserver/mapwms.c	2011-03-01 14:18:47 UTC (rev 11035)
@@ -374,7 +374,7 @@
 **
 */
 int msWMSLoadGetMapParams(mapObj *map, int nVersion,
-                          char **names, char **values, int numentries, char *wms_exception_format)
+                          char **names, char **values, int numentries, char *wms_exception_format, const char *wms_request)
 {
   int i, adjust_extent = MS_FALSE, nonsquare_enabled = MS_FALSE;
   int iUnits = -1;
@@ -510,10 +510,11 @@
           for (j=0; j<map->numlayers; j++)
           {
               /* Turn on selected layers only. */
-              if ((GET_LAYER(map, j)->name &&
-                   strcasecmp(GET_LAYER(map, j)->name, layers[k]) == 0) ||
-                  (map->name && strcasecmp(map->name, layers[k]) == 0) ||
-                  (GET_LAYER(map, j)->group && strcasecmp(GET_LAYER(map, j)->group, layers[k]) == 0))
+              if ( ((GET_LAYER(map, j)->name &&
+                     strcasecmp(GET_LAYER(map, j)->name, layers[k]) == 0) ||
+                    (map->name && strcasecmp(map->name, layers[k]) == 0) ||
+                    (GET_LAYER(map, j)->group && strcasecmp(GET_LAYER(map, j)->group, layers[k]) == 0)) &&
+                   (msOWSRequestIsEnabled(map, GET_LAYER(map, j), "M", wms_request)) )
               {
                   if (GET_LAYER(map, j)->status != MS_DEFAULT)
                   {
@@ -2527,8 +2528,8 @@
          layerObj *lp;
          lp = (GET_LAYER(map, i));
 
-         if (pabLayerProcessed[i] || (lp->status == MS_DELETE))
-             continue;  /* Layer has already been handled */
+         if (pabLayerProcessed[i] || (lp->status == MS_DELETE) || (!msOWSRequestIsEnabled(map, lp, "M", "GetCapabilities")))
+             continue;  /* Layer is hidden or has already been handled */
 
 
          if (numNestedGroups[i] > 0) 
@@ -2825,6 +2826,11 @@
       }
   }
 
+  /* turn off layer if WMS GetMap is not enabled */
+  for (i=0; i<map->numlayers; i++)
+      if (!msOWSRequestIsEnabled(map, GET_LAYER(map, i), "M", "GetMap"))
+          GET_LAYER(map, i)->status = MS_OFF;
+
   if (sldrequested && sldspatialfilter)
   {
       /* set the quermap style so that only selected features will be retruned */
@@ -2863,8 +2869,8 @@
       }
 
   }
-  else
-    img = msDrawMap(map, MS_FALSE);
+  else 
+      img = msDrawMap(map, MS_FALSE);
   if (img == NULL)
     return msWMSException(map, nVersion, NULL, wms_exception_format);
   
@@ -3024,9 +3030,10 @@
         /* Force all layers OFF by default */
 	GET_LAYER(map, j)->status = MS_OFF;
         for(k=0; k<numlayers; k++) {
-          if ((GET_LAYER(map, j)->name && strcasecmp(GET_LAYER(map, j)->name, layers[k]) == 0) ||
+         if (((GET_LAYER(map, j)->name && strcasecmp(GET_LAYER(map, j)->name, layers[k]) == 0) ||
               (map->name && strcasecmp(map->name, layers[k]) == 0) ||
-              (GET_LAYER(map, j)->group && strcasecmp(GET_LAYER(map, j)->group, layers[k]) == 0))
+              (GET_LAYER(map, j)->group && strcasecmp(GET_LAYER(map, j)->group, layers[k]) == 0)) &&
+             (msOWSRequestIsEnabled(map, GET_LAYER(map, j), "M", "GetFeatureInfo")))
             {
                 numlayers_found++;     
                 GET_LAYER(map, j)->status = MS_ON;               
@@ -3091,7 +3098,7 @@
   for (i=0; i<map->numlayers; i++)
   {
       if (GET_LAYER(map, i)->status == MS_ON && !msIsLayerQueryable(GET_LAYER(map, i)))
-      {
+      { 
           msSetError(MS_WMSERR, "Requested layer(s) are not queryable.", "msWMSFeatureInfo()");
           return msWMSException(map, nVersion, "LayerNotQueryable", wms_exception_format);
       }
@@ -3539,8 +3546,9 @@
      for (i=0; i<map->numlayers; i++)
      {
          lp = GET_LAYER(map, i);
-         if ((lp->name && strcasecmp(lp->name, pszLayer) == 0) ||
-             (lp->group && strcasecmp(lp->group, pszLayer) == 0))
+         if ( ((lp->name && strcasecmp(lp->name, pszLayer) == 0) ||
+               (lp->group && strcasecmp(lp->group, pszLayer) == 0)) &&
+              (msOWSRequestIsEnabled(map, lp, "M", "GetLegendGraphic")) )
            {
                nLayers++;
                lp->status = MS_ON;
@@ -4039,7 +4047,7 @@
       strcasecmp(request, "feature_info") == 0 || strcasecmp(request, "GetFeatureInfo") == 0 || strcasecmp(request, "DescribeLayer") == 0)
   {
       status = msWMSLoadGetMapParams(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams, 
-                                     wms_exception_format);
+                                     wms_exception_format, request);
       if (status != MS_SUCCESS) return status;
   }
 



More information about the mapserver-commits mailing list