[mapguide-commits] r6864 - branches/2.4/MgDev/Web/src/mapviewerphp

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jul 6 08:11:38 PDT 2012


Author: jng
Date: 2012-07-06 08:11:38 -0700 (Fri, 06 Jul 2012)
New Revision: 6864

Modified:
   branches/2.4/MgDev/Web/src/mapviewerphp/measure.php
   branches/2.4/MgDev/Web/src/mapviewerphp/measureui.php
Log:
#1834: Add support for specifying units for measurement. This submission is the PHP viewer files

Modified: branches/2.4/MgDev/Web/src/mapviewerphp/measure.php
===================================================================
--- branches/2.4/MgDev/Web/src/mapviewerphp/measure.php	2012-07-06 15:10:52 UTC (rev 6863)
+++ branches/2.4/MgDev/Web/src/mapviewerphp/measure.php	2012-07-06 15:11:38 UTC (rev 6864)
@@ -32,7 +32,7 @@
     $y2 = 0;
     $total = 0;
     $srs = "";
-    $us = 1;
+    $units = "";
     $segId = 1;
     $error = "";
     $distance = 0;
@@ -92,11 +92,12 @@
                 $distance = $srsMap->MeasureEuclideanDistance($x1, $y1, $x2, $y2);
 
             $distance = $srsMap->ConvertCoordinateSystemUnitsToMeters($distance);
-            if(!$us)
-                $distance *= 0.001;             //get kilometers
-            else
-                $distance *= 0.000621371192;    //get miles
 
+            if ($units == "mi") $distance *= 0.000621371192;  //get miles
+            if ($units == "km") $distance *= 0.001;           //get kilometers
+            if ($units == "ft") $distance *= 3.2808399;       //get feet
+            if ($units == "usft") $distance *= 3.2808333;       //get US survey feet
+
             $total += $distance;
 
             //create the line string geometry representing this segment
@@ -154,7 +155,14 @@
                     $featureSrvc->CreateFeatureSource($dataSourceId, $params);
 
                     //build map tip
-                    $unitText = $us? GetLocalizedString("DISTANCEMILES", $locale): GetLocalizedString("DISTANCEKILOMETERS", $locale);
+                    $unitText = "";
+                    if ($units == "mi") $unitText = "DISTANCEMILES";
+                    if ($units == "km") $unitText = "DISTANCEKILOMETERS";
+                    if ($units == "ft") $unitText = "DISTANCEFEET";
+                    if ($units == "usft") $unitText = "DISTANCEUSFEET";
+                    if ($units == "m") $unitText = "DISTANCEMETERS";
+                    $unitText = GetLocalizedString($unitText, $locale);
+
                     $tip = sprintf("Concat(Concat(Concat('" . GetLocalizedString("MEASUREPARTIAL", $locale) . ": ', PARTIAL), Concat(', " . GetLocalizedString("MEASURETOTAL", $locale) . ": ', TOTAL)), ' (%s)')", $unitText);
 
                     //Create the layer definition
@@ -227,6 +235,7 @@
                 $total,
                 $distance,
                 1,
+                $units,
                 $vpath . "measure.php",
                 $vpath . "measure.php");
 
@@ -282,7 +291,7 @@
 
 function GetParameters($params)
 {
-    global $mapName, $sessionId, $x1, $y1, $x2, $y2, $popup;
+    global $mapName, $sessionId, $x1, $y1, $x2, $y2, $popup, $units;
     global $total, $clear, $us, $segId, $target, $locale;
 
     $sessionId = ValidateSessionId(GetParameter($params, 'SESSION'));
@@ -291,11 +300,11 @@
 
     $target = GetIntParameter($params, 'TGT');
     $popup = GetIntParameter($params, 'POPUP');
+    $units = GetParameter($params, 'UNITS');
     if(isset($params['CLEAR']))
         $clear = true;
     else
     {
-        $us = GetIntParameter($params, 'US');
         $segId = GetIntParameter($params, 'SEGID');
         $x1 = GetDoubleParameter($params, 'X1');
         $y1 = GetDoubleParameter($params, 'Y1');

Modified: branches/2.4/MgDev/Web/src/mapviewerphp/measureui.php
===================================================================
--- branches/2.4/MgDev/Web/src/mapviewerphp/measureui.php	2012-07-06 15:10:52 UTC (rev 6863)
+++ branches/2.4/MgDev/Web/src/mapviewerphp/measureui.php	2012-07-06 15:11:38 UTC (rev 6864)
@@ -26,6 +26,7 @@
     $clientWidth = 0;
     $mapName = "";
     $sessionId = "";
+    $units = "";
     $total = 0;
 
     GetRequestParameters();
@@ -36,7 +37,7 @@
     $templ = Localize($templ, $locale, GetClientOS());
 
     $vpath = GetSurroundVirtualPath();
-    print sprintf($templ, $locale, $target, $popup, $mapName, $sessionId, $total, 0, 0, $vpath . "measure.php", $vpath . "measure.php");
+    print sprintf($templ, $locale, $target, $popup, $mapName, $sessionId, $total, 0, 0, $units, $vpath . "measure.php", $vpath . "measure.php");
 
 function GetParameters($params)
 {
@@ -50,6 +51,7 @@
     $cmdIndex = GetIntParameter($params, 'CMDINDEX');
     $clientWidth = GetIntParameter($params, 'WIDTH');
     $total = GetDoubleParameter($params, 'TOTAL');
+    $units = GetParameter($params, 'UNITS');
 }
 
 function GetRequestParameters()



More information about the mapguide-commits mailing list