[mapserver-commits] r11351 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Mar 28 12:12:07 EDT 2011


Author: aboudreault
Date: 2011-03-28 09:12:07 -0700 (Mon, 28 Mar 2011)
New Revision: 11351

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapogcsos.c
   trunk/mapserver/mapows.c
   trunk/mapserver/mapows.h
   trunk/mapserver/mapserver.h
   trunk/mapserver/maputil.c
   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:
Fixed OWS usage of multiple layers with same name (#3778)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/HISTORY.TXT	2011-03-28 16:12:07 UTC (rev 11351)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Fixed OWS usage of multiple layers with same name (#3778)
+
 - WCS implementation should not lookup wms_* metadata (#3779)
 
 - WCS 2.0: Adjusted definition of rangeType.

Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapogcsos.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -1401,7 +1401,7 @@
                 continue;
 
              value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_id");
-             if (value && (msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)))
+             if (value && (msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)))
              {
                  nCurrentOff = -1;
                  for (j=0; j<nOfferings; j++)
@@ -1877,7 +1877,7 @@
   for (i=0; i<map->numlayers; i++) {
       pszTmp = msOWSLookupMetadata(&(GET_LAYER(map, i)->metadata), "S", "offering_id");
     if (pszTmp && (strcasecmp(pszTmp, sosparams->pszOffering) == 0) && 
-        (msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)))
+        (msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)))
       break;
   }
 
@@ -2659,7 +2659,7 @@
           pszProcedureURI = msStrdup("urn:ogc:def:procedure:");
           pszProcedureURI = msStringConcatenate(pszProcedureURI, tokens[k]);
           if ( (pszProcedureURI && strcasecmp(pszProcedureURI, sosparams->pszProcedure) == 0) &&
-               (msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)) ) {
+               (msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) ) {
             bFound = 1; 
             pszProcedureId = msStrdup(tokens[k]);
             msFree(pszProcedureURI);
@@ -2783,7 +2783,7 @@
   tokens = msStringSplit(sosparams->pszObservedProperty, ',', &n);
 
   for (i=0; i<map->numlayers; i++) {
-    if (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers))
+    if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
       continue;
     pszTmp = msOWSLookupMetadata(&(GET_LAYER(map, i)->metadata), "S", "observedproperty_id");
     if (pszTmp) {

Modified: trunk/mapserver/mapows.c
===================================================================
--- trunk/mapserver/mapows.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapows.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -79,7 +79,7 @@
      */
     if ((status = msWMSDispatch(map, request, &ows_request, MS_FALSE)) != MS_DONE )
     {
-        msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+        msFree(ows_request.enabled_layers);
         return status;
     }
 #else
@@ -95,7 +95,7 @@
      */
     if ((status = msWFSDispatch(map, request, &ows_request, (ows_mode == WFS))) != MS_DONE )
     {
-        msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+        msFree(ows_request.enabled_layers);
         return status;
     }
 
@@ -109,7 +109,7 @@
 #ifdef USE_WCS_SVR
     if ((status = msWCSDispatch(map, request, &ows_request)) != MS_DONE )
     {
-        msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+        msFree(ows_request.enabled_layers);
         return status;
     }
 #else
@@ -122,7 +122,7 @@
 #ifdef USE_SOS_SVR
     if ((status = msSOSDispatch(map, request, &ows_request)) != MS_DONE )
     {
-        msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+        msFree(ows_request.enabled_layers);
         return status;
     }
 #else
@@ -153,11 +153,11 @@
          * return MS_SUCCESS since the exception will have been processed 
          * the OWS way, which is a success as far as mapserv is concerned 
          */
-        msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+        msFree(ows_request.enabled_layers);
         return MS_FAILURE; 
     }
 
-    msFreeCharArray(ows_request.enabled_layers, ows_request.numlayers);
+    msFree(ows_request.enabled_layers);
     return MS_DONE;  /* Not a WMS/WFS request... let MapServer handle it 
                       * since we're not in force_ows_mode*/
 }
@@ -259,7 +259,7 @@
 ** If namespaces is NULL then this function just does a regular metadata
 ** lookup.
 **
-** Returns an array of the layers enabled.
+** Generates an array of the layer ids enabled.
 */
 void msOWSRequestLayersEnabled(mapObj *map, const char *namespaces, 
                                const char *request, owsRequestObj *ows_request)
@@ -269,7 +269,7 @@
     const char *enable_request;
 
     if (ows_request->numlayers > 0) 
-        msFreeCharArray(ows_request->enabled_layers, ows_request->numlayers);
+        msFree(ows_request->enabled_layers);
     
     ows_request->numlayers = 0;
     ows_request->enabled_layers = NULL;
@@ -290,7 +290,7 @@
     {
         int i, layers_size = map->numlayers; //for most of cases, this will be relatively small
 
-        ows_request->enabled_layers = (char**)msSmallMalloc(sizeof(char*)*layers_size);
+        ows_request->enabled_layers = (int*)msSmallMalloc(sizeof(int)*layers_size);
 
         for(i=0; i<map->numlayers; i++)
         {
@@ -312,9 +312,7 @@
             
             if (result || (!disabled && globally_enabled))
             {
-                size_t size = strlen(lp->name)+1;
-                ows_request->enabled_layers[ows_request->numlayers] = (char *)msSmallMalloc(sizeof(char) * size);
-                strlcpy(ows_request->enabled_layers[ows_request->numlayers], lp->name, size);
+                ows_request->enabled_layers[ows_request->numlayers] = lp->index;
                 ows_request->numlayers++;
             }
         }

Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapows.h	2011-03-28 16:12:07 UTC (rev 11351)
@@ -107,7 +107,7 @@
 typedef struct
 {
     int numlayers;
-    char **enabled_layers;
+    int *enabled_layers;
     
 } owsRequestObj;
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapserver.h	2011-03-28 16:12:07 UTC (rev 11351)
@@ -2229,6 +2229,7 @@
 MS_DLL_EXPORT void *msSmallMalloc( size_t nSize );
 MS_DLL_EXPORT void * msSmallRealloc( void * pData, size_t nNewSize );
 MS_DLL_EXPORT void *msSmallCalloc( size_t nCount, size_t nSize );
+MS_DLL_EXPORT int msIntegerInArray(const int value, int *array, int numelements);
 
 MS_DLL_EXPORT int msExtentsOverlap(mapObj *map, layerObj *layer);
 MS_DLL_EXPORT char *msBuildOnlineResource(mapObj *map, cgiRequestObj *req);

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/maputil.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -2260,3 +2260,18 @@
     return online_resource;
 }
 
+
+/************************************************************************/
+/*                             msIntegerInArray()                        */
+/************************************************************************/
+
+/* Check if a integer is in a array */
+int msIntegerInArray(const int value, int *array, int numelements)
+{
+    int i;
+    for (i=0;i<numelements;++i) {
+        if (value == array[i])
+            return MS_TRUE;
+    }
+    return MS_FALSE;
+}

Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwcs.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -907,7 +907,7 @@
 
   for(i=0; i<map->numlayers; i++) {
   
-      if (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers))
+      if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
           continue;
   
       if( msWCSGetCapabilities_CoverageOfferingBrief((GET_LAYER(map, i)), params) != MS_SUCCESS ) {
@@ -1348,7 +1348,7 @@
         for(i=0; i<map->numlayers; i++) {
           coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata), "CO", "name", GET_LAYER(map, i)->name);
           if( EQUAL(coverageName, coverages[k]) &&
-              (msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)) )
+              (msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) )
               break;
         }
 
@@ -1396,7 +1396,7 @@
     }
   } else { /* return all layers */
       for(i=0; i<map->numlayers; i++) {
-          if (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers))
+          if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
               continue;
 
           msWCSDescribeCoverage_CoverageOffering((GET_LAYER(map, i)), params);
@@ -1618,7 +1618,7 @@
   for(i=0; i<map->numlayers; i++) {
      coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata), "CO", "name", GET_LAYER(map, i)->name);
     if( EQUAL(coverageName, params->coverages[0]) &&
-        (msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)) ) {
+        (msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) ) {
       lp = GET_LAYER(map, i);
       break;
     }

Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwcs11.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -556,7 +556,7 @@
             if(!msWCSIsLayerSupported(layer)) 
                 continue;
             
-            if (!msStringInArray(layer->name, ows_request->enabled_layers, ows_request->numlayers))
+            if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
                 continue;
 
             status = msWCSGetCapabilities11_CoverageSummary( 
@@ -895,7 +895,7 @@
         for( j = 0; params->coverages[j]; j++ ) {
             i = msGetLayerIndex(map, params->coverages[j]);
             if ( (i == -1) || 
-                 (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)) )
+                 (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) )
             {
                 msSetError( MS_WCSERR,
                             "COVERAGE %s cannot be opened / does not exist",
@@ -948,7 +948,7 @@
     } else { /* return all layers */
         for(i=0; i<map->numlayers; i++) {
 
-            if (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers))
+            if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
                 continue;
 
             msWCSDescribeCoverage_CoverageDescription11((GET_LAYER(map, i)), 

Modified: trunk/mapserver/mapwcs20.c
===================================================================
--- trunk/mapserver/mapwcs20.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwcs20.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -3026,7 +3026,7 @@
             if(!msWCSIsLayerSupported(layer))
                 continue;
 
-            if (!msStringInArray(layer->name, ows_request->enabled_layers, ows_request->numlayers))
+            if (!msIntegerInArray(layer->index, ows_request->enabled_layers, ows_request->numlayers))
                 continue;
 
             status = msWCSGetCapabilities20_CoverageSummary(
@@ -3228,7 +3228,7 @@
         for (j = 0; params->ids[j]; j++)
         {
             i = msGetLayerIndex(map, params->ids[j]);
-            if (i == -1 || (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)) )
+            if (i == -1 || (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) )
             {
                 msSetError(MS_WCSERR, "Unknown coverage: (%s)",
                         "msWCSDescribeCoverage20()", params->ids[j]);
@@ -3496,7 +3496,7 @@
                                               "CO", "name",
                                               GET_LAYER(map, i)->name);
         if (EQUAL(coverageName, params->ids[0]) && 
-            (msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers)))
+            (msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)))
         {
             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-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwfs.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -830,7 +830,7 @@
       if (lp->status == MS_DELETE)
          continue;
 
-      if (!msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers))
+      if (!msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers))
           continue;
 
       /* List only vector layers in which DUMP=TRUE */
@@ -1153,7 +1153,7 @@
   if (numlayers > 0) {
     for (i=0; i<numlayers; i++) {
         int index = msGetLayerIndex(map, layers[i]);
-        if ( (index < 0) || (!msStringInArray(GET_LAYER(map, index)->name, ows_request->enabled_layers, ows_request->numlayers)) ) {
+        if ( (index < 0) || (!msIntegerInArray(GET_LAYER(map, index)->index, ows_request->enabled_layers, ows_request->numlayers)) ) {
 	      msSetError(MS_WFSERR, "Invalid typename (%s).", "msWFSDescribeFeatureType()", layers[i]);/* paramsObj->pszTypeName); */
               return msWFSException(map, "typename", "InvalidParameterValue", paramsObj->pszVersion);
       }
@@ -1272,7 +1272,7 @@
     }
 
     if ((numlayers == 0 || bFound) && msWFSIsLayerSupported(lp) && 
-        (msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)) ) {        
+        (msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) ) {        
 
       /*
       ** OK, describe this layer IF you can open it and retrieve items
@@ -1761,7 +1761,7 @@
 	lp = GET_LAYER(map, j);
 	
 	if (msWFSIsLayerSupported(lp) && lp->name && (strcasecmp(lp->name, layers[k]) == 0) && 
-            (msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)) ) {
+            (msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) ) {
 	  bLayerFound = MS_TRUE;
 	  
 	  lp->status = MS_ON;

Modified: trunk/mapserver/mapwfs11.c
===================================================================
--- trunk/mapserver/mapwfs11.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwfs11.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -435,7 +435,7 @@
          layerObj *lp;
          lp = GET_LAYER(map, i);
          
-         if (!msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers))
+         if (!msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers))
              continue;
 
          /* List only vector layers in which DUMP=TRUE */

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2011-03-28 16:01:05 UTC (rev 11350)
+++ trunk/mapserver/mapwms.c	2011-03-28 16:12:07 UTC (rev 11351)
@@ -516,7 +516,7 @@
                      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)) &&
-                   ((msStringInArray(GET_LAYER(map, j)->name, ows_request->enabled_layers, ows_request->numlayers))) )
+                   ((msIntegerInArray(GET_LAYER(map, j)->index, ows_request->enabled_layers, ows_request->numlayers))) )
               {
                   if (GET_LAYER(map, j)->status != MS_DEFAULT)
                   {
@@ -2558,7 +2558,7 @@
          lp = (GET_LAYER(map, i));
 
          if (pabLayerProcessed[i] || (lp->status == MS_DELETE) || 
-             (!msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)))
+             (!msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)))
              continue;  /* Layer is hidden or has already been handled */
          
          if (numNestedGroups[i] > 0) 
@@ -2857,7 +2857,7 @@
 
   /* turn off layer if WMS GetMap is not enabled */
   for (i=0; i<map->numlayers; i++)
-      if (!msStringInArray(GET_LAYER(map, i)->name, ows_request->enabled_layers, ows_request->numlayers))
+      if (!msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers))
           GET_LAYER(map, i)->status = MS_OFF;
 
   if (sldrequested && sldspatialfilter)
@@ -3062,7 +3062,7 @@
          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)) &&
-             (msStringInArray(GET_LAYER(map, j)->name, ows_request->enabled_layers, ows_request->numlayers)) )
+             (msIntegerInArray(GET_LAYER(map, j)->index, ows_request->enabled_layers, ows_request->numlayers)) )
             {
                 numlayers_found++;     
                 GET_LAYER(map, j)->status = MS_ON;               
@@ -3577,7 +3577,7 @@
          lp = GET_LAYER(map, i);
          if ( ((lp->name && strcasecmp(lp->name, pszLayer) == 0) ||
                (lp->group && strcasecmp(lp->group, pszLayer) == 0)) &&
-              (msStringInArray(lp->name, ows_request->enabled_layers, ows_request->numlayers)) )
+              (msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) )
            {
                nLayers++;
                lp->status = MS_ON;



More information about the mapserver-commits mailing list