[mapserver-commits] r10864 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Jan 13 16:22:05 EST 2011


Author: assefa
Date: 2011-01-13 13:22:05 -0800 (Thu, 13 Jan 2011)
New Revision: 10864

Modified:
   trunk/mapserver/mapwfs.c
   trunk/mapserver/mapwms.c
Log:
Use default versions if set in the map file #3444

Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c	2011-01-13 18:31:54 UTC (rev 10863)
+++ trunk/mapserver/mapwfs.c	2011-01-13 21:22:05 UTC (rev 10864)
@@ -2912,6 +2912,13 @@
     }
 }
 
+const char *msWFSGetDefaultVersion(mapObj *map)
+{
+  if (msOWSLookupMetadata(&(map->web.metadata), "F", "getcapabilities_version"))
+    return  msOWSLookupMetadata(&(map->web.metadata), "F", "getcapabilities_version");
+  else
+    return "1.1.0";
+}
 /************************************************************************/
 /*                            msWFSParseRequest                         */
 /*                                                                      */
@@ -2985,7 +2992,9 @@
         if (wfsparams->pszVersion == NULL &&
             wfsparams->pszRequest && 
             strcasecmp(wfsparams->pszRequest, "GetCapabilities") == 0)
-          wfsparams->pszVersion = msStrdup("1.1.0");
+        {
+          wfsparams->pszVersion = msStrdup(msWFSGetDefaultVersion(map));
+        }
     }
 /* -------------------------------------------------------------------- */
 /*      Parse the post request. It is assumed to be an XML document.    */
@@ -3038,7 +3047,9 @@
         /* version is optional for the GetCapabilities. If not provided, set it*/
         if (wfsparams->pszVersion == NULL && 
             strcmp(wfsparams->pszRequest,"GetCapabilities") == 0)
-           wfsparams->pszVersion = msStrdup("1.1.0");
+        {
+           wfsparams->pszVersion = msStrdup(msWFSGetDefaultVersion(map));
+        }
 
 
         /*do we validate the xml ?*/
@@ -3478,7 +3489,7 @@
                 if (pszValue)
                   wfsparams->pszVersion = msStrdup(pszValue);
                 else
-                  wfsparams->pszVersion = msStrdup("1.1.0");
+                  wfsparams->pszVersion = msStrdup(msStrdup(msWFSGetDefaultVersion(map));
 
                  pszValue = 
                    CPLGetXMLValue(psGetCapabilities, "service",

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2011-01-13 18:31:54 UTC (rev 10863)
+++ trunk/mapserver/mapwms.c	2011-01-13 21:22:05 UTC (rev 10864)
@@ -72,9 +72,9 @@
     const char *encoding;
     char *schemalocation = NULL;
 
-    /* Default to WMS 1.1.1 exceptions if version not set yet */
+    /* Default to WMS 1.3.0 exceptions if version not set yet */
     if (nVersion <= 0)
-        nVersion = OWS_1_1_1;
+        nVersion = OWS_1_3_0;
 
     /* get scheam location */
     schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) );
@@ -2045,13 +2045,12 @@
     dtd_url = msStrdup(schemalocation);
     dtd_url = msStringConcatenate(dtd_url, "/wms/1.0.7/capabilities_1_0_7.dtd");
   }
-  else if (nVersion == OWS_1_1_0) {
+  else if (nVersion < OWS_1_1_1) {
     nVersion = OWS_1_1_0;
     dtd_url = msStrdup(schemalocation);
     dtd_url = msStringConcatenate(dtd_url, "/wms/1.1.0/capabilities_1_1_0.dtd");
   }
-  /*TODO review wms1.3.0*/
-  else if (nVersion != OWS_1_3_0) {
+  else if (nVersion < OWS_1_3_0) {
     nVersion = OWS_1_1_1;
     dtd_url = msStrdup(schemalocation);
     /* this exception was added to accomadote the OGC test suite (Bug 1576)*/
@@ -2060,6 +2059,8 @@
     else
       dtd_url = msStringConcatenate(dtd_url, "/wms/1.1.1/capabilities_1_1_1.dtd");
   }
+  else
+     nVersion = OWS_1_3_0;
 
   /* We need this server's onlineresource. */
   /* Default to use the value of the "onlineresource" metadata, and if not */
@@ -3903,7 +3904,14 @@
                   strcasecmp(request, "GetCapabilities") == 0) )
   {
       if (nVersion == OWS_VERSION_NOTSET)
-          nVersion = OWS_1_3_0;/* VERSION is optional with getCapabilities only */
+      {
+          version = msOWSLookupMetadata(&(map->web.metadata), "M", "getcapabilities_version");
+          if (version)
+            nVersion = msOWSParseVersionString(version);
+          else
+            nVersion = OWS_1_3_0;/* VERSION is optional with getCapabilities only */
+      }
+
       if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
         return msWMSException(map, nVersion, NULL, wms_exception_format);
       return msWMSGetCapabilities(map, nVersion, req, updatesequence, wms_exception_format);
@@ -3993,6 +4001,17 @@
       return msWMSException(map, OWS_VERSION_NOTSET, NULL, wms_exception_format);
   }
 
+   /*check if the version is one of the supported vcersions*/
+  if (nVersion != OWS_1_0_0 &&  nVersion != OWS_1_0_6 &&
+         nVersion != OWS_1_0_7 && nVersion != OWS_1_1_0 &&
+         nVersion != OWS_1_1_1 && nVersion != OWS_1_3_0)
+  {
+      msSetError(MS_WMSERR,
+                   "Invalid WMS version: VERSION %s is not supported. Supported versions are 1.0.0, 1.0.6, 1.0.7, 1.1.0, 1.1.1, 1.3.0",
+                   "msWMSDispatch()", version);
+      return msWMSException(map, OWS_VERSION_NOTSET, NULL, wms_exception_format);
+  }
+
   if (request==NULL)
   {
       msSetError(MS_WMSERR,



More information about the mapserver-commits mailing list