[mapserver-commits] r7629 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu May 29 09:54:12 EDT 2008


Author: sdlime
Date: 2008-05-29 09:54:12 -0400 (Thu, 29 May 2008)
New Revision: 7629

Modified:
   trunk/mapserver/maptemplate.c
Log:
Added percentage expansion to extent/bounds tag processing (e.g. [shpext expand=10%]). (#2632)

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2008-05-29 12:55:13 UTC (rev 7628)
+++ trunk/mapserver/maptemplate.c	2008-05-29 13:54:12 UTC (rev 7629)
@@ -1300,7 +1300,7 @@
   char *encodedTagValue=NULL, *tagValue=NULL;
 
   rectObj tempExtent;
-  double expand=0;
+  double xExpand=0, yExpand=0;
 
   char number[64]; /* holds a single number in the extent */
   char numberFormat[16]="%f";
@@ -1326,7 +1326,17 @@
     if(getTagArgs(name, tagStart, &tagArgs) != MS_SUCCESS) return(MS_FAILURE);
     if(tagArgs) {
       argValue = msLookupHashTable(tagArgs, "expand");
-      if(argValue) expand = atof(argValue);
+      if(argValue) {
+        if(strchr(argValue, '%') != NULL) {
+          float f;
+          sscanf(argValue, "%f%%", &f);
+          xExpand = ((f/100.0)*(extent->maxx-extent->minx))/2;
+          yExpand = ((f/100.0)*(extent->maxy-extent->miny))/2;          
+        } else {
+          xExpand = atof(argValue);
+          yExpand = xExpand;
+        }
+      }
 
       argValue = msLookupHashTable(tagArgs, "escape");
       if(argValue && strcasecmp(argValue, "url") == 0) escape = ESCAPE_URL;
@@ -1339,10 +1349,10 @@
       if(argValue) precision = atoi(argValue);
     }
 
-    tempExtent.minx = extent->minx - expand;
-    tempExtent.miny = extent->miny - expand;
-    tempExtent.maxx = extent->maxx + expand;
-    tempExtent.maxy = extent->maxy + expand;
+    tempExtent.minx = extent->minx - xExpand;
+    tempExtent.miny = extent->miny - yExpand;
+    tempExtent.maxx = extent->maxx + xExpand;
+    tempExtent.maxy = extent->maxy + yExpand;
 
     tagValue = strdup(format);
 



More information about the mapserver-commits mailing list