[mapserver-commits] r10707 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Nov 4 15:12:55 EDT 2010


Author: aboudreault
Date: 2010-11-04 12:12:55 -0700 (Thu, 04 Nov 2010)
New Revision: 10707

Modified:
   trunk/mapserver/mapserv.c
   trunk/mapserver/maptemplate.c
Log:
Fixed built-in openlayers template to support OGC WMS GetMap version >= 1.3.0 (#3549)

Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c	2010-11-03 23:05:08 UTC (rev 10706)
+++ trunk/mapserver/mapserv.c	2010-11-04 19:12:55 UTC (rev 10707)
@@ -1298,7 +1298,8 @@
                 (requeststarttime.tv_sec+requeststarttime.tv_usec/1.0e6) );
       }
       
-      if (strcasecmp(mapserv->map->imagetype, "application/openlayers")==0)
+      if (status == MS_SUCCESS &&
+          strcasecmp(mapserv->map->imagetype, "application/openlayers")==0)
       {
         for( i=0; i<mapserv->request->NumParams; i++)
         {

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2010-11-03 23:05:08 UTC (rev 10706)
+++ trunk/mapserver/maptemplate.c	2010-11-04 19:12:55 UTC (rev 10707)
@@ -70,8 +70,8 @@
 "                                   '[mapserv_onlineresource]',\n"
 "                                   {layers: '[LAYERS]',\n"
 "                                   bbox: '[minx],[miny],[maxx],[maxy]',\n"
-"                                   width: [mapwidth], height: [mapheight] },"
-"                                   {singleTile: \"true\", ratio:1, projection: '[SRS]'});\n";
+"                                   width: [mapwidth], height: [mapheight], version: '[VERSION]'},"
+"                                   {singleTile: \"true\", ratio:1, projection: '[openlayers_projection]'});\n";
 
 static char *processLine(mapservObj *mapserv, char *instr, FILE *stream, int mode);
 
@@ -4211,19 +4211,26 @@
     char *buffer = NULL, *layer = NULL;
     const char *tmpUrl = NULL;
     char *openlayersUrl = olUrl;
+    char *projection = NULL;
 
     /* 2 CGI parameters are used in the template. we need to transform them
-     * to be sure the case match during the template processing */
+     * to be sure the case match during the template processing. We also
+     * need to search the SRS/CRS parameter to get the projection info. OGC
+     * services version >= 1.3.0 uses CRS rather than SRS */
     for( i=0; i<mapserv->request->NumParams; i++)
     {
-        if(strcasecmp(mapserv->request->ParamNames[i], "SRS") == 0) {
-            free(mapserv->request->ParamNames[i]);
-            mapserv->request->ParamNames[i] = strdup("SRS");
+        if( (strcasecmp(mapserv->request->ParamNames[i], "SRS") == 0) ||
+            (strcasecmp(mapserv->request->ParamNames[i], "CRS") == 0) ) {
+            projection = mapserv->request->ParamValues[i];
         }
         else if(strcasecmp(mapserv->request->ParamNames[i], "LAYERS") == 0) {
             free(mapserv->request->ParamNames[i]);
             mapserv->request->ParamNames[i] = strdup("LAYERS");
         }
+        else if(strcasecmp(mapserv->request->ParamNames[i], "VERSION") == 0) {
+            free(mapserv->request->ParamNames[i]);
+            mapserv->request->ParamNames[i] = strdup("VERSION");
+        }
     }
 
     /* check if the environment variable or config MS_OPENLAYERS_JS_URL is set */
@@ -4244,6 +4251,8 @@
     buffer = processLine(mapserv, olTemplate, NULL, BROWSE);
     buffer = msReplaceSubstring(buffer, "[openlayers_js_url]", openlayersUrl);
     buffer = msReplaceSubstring(buffer, "[openlayers_layer]", layer);
+    if (projection)
+        buffer = msReplaceSubstring(buffer, "[openlayers_projection]", projection);
     msIO_fwrite(buffer, strlen(buffer), 1, stdout);
     free(layer);
     free(buffer);



More information about the mapserver-commits mailing list