[mapguide-commits] r6868 - in trunk/MgDev/Web/src: localized mapviewerjava mapviewernet mapviewerphp viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jul 6 08:25:21 PDT 2012


Author: jng
Date: 2012-07-06 08:25:20 -0700 (Fri, 06 Jul 2012)
New Revision: 6868

Modified:
   trunk/MgDev/Web/src/localized/en
   trunk/MgDev/Web/src/mapviewerjava/measure.jsp
   trunk/MgDev/Web/src/mapviewerjava/measureui.jsp
   trunk/MgDev/Web/src/mapviewernet/measure.aspx
   trunk/MgDev/Web/src/mapviewernet/measureui.aspx
   trunk/MgDev/Web/src/mapviewerphp/measure.php
   trunk/MgDev/Web/src/mapviewerphp/measureui.php
   trunk/MgDev/Web/src/viewerfiles/measureui.templ
Log:
#1834: Merge in 2.4 branch submissions

Modified: trunk/MgDev/Web/src/localized/en
===================================================================
--- trunk/MgDev/Web/src/localized/en	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/localized/en	2012-07-06 15:25:20 UTC (rev 6868)
@@ -18,6 +18,7 @@
 DISTANCEMILES       = Miles
 DISTANCEKILOMETERS  = Kilometers
 DISTANCEFEET        = Feet
+DISTANCEUSFEET      = US Survey Feet
 DISTANCEMETERS      = Meters
 
 # Fill Patterns/Values
@@ -113,6 +114,7 @@
 COLORPICKERHEXFORMAT            = Hex format
 
 # MeasureUI
+MEASUREUNITS            = Measure units:
 MEASURETITLE            = Measure Distance
 MEASUREINFO             = Click a start and end point.
 RESUME                  = Resume

Modified: trunk/MgDev/Web/src/mapviewerjava/measure.jsp
===================================================================
--- trunk/MgDev/Web/src/mapviewerjava/measure.jsp	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewerjava/measure.jsp	2012-07-06 15:25:20 UTC (rev 6868)
@@ -37,7 +37,7 @@
 double y2;
 double total;
 String srs;
-int us;
+String units;
 int segId;
 String error;
 double distance;
@@ -59,7 +59,7 @@
     y2 = 0;
     total = 0;
     srs = "";
-    us = 0;
+    units = "";
     segId = 1;
     error = "";
     distance = 0;
@@ -124,10 +124,10 @@
 
             distance = srsMap.ConvertCoordinateSystemUnitsToMeters(distance);
 
-            if(0 == us)
-                distance *= 0.001;              //get kilometers
-            else
-                distance *= 0.000621371192;     //get miles
+            if (units.equals("mi")) distance *= 0.000621371192;  //get miles
+            if (units.equals("km")) distance *= 0.001;           //get kilometers
+            if (units.equals("ft")) distance *= 3.2808399;       //get feet
+            if (units.equals("usft")) distance *= 3.2808333;       //get US survey feet
 
             total += distance;
 
@@ -186,7 +186,14 @@
                     featureSrvc.CreateFeatureSource(dataSourceId, parameters);
 
                     //build map tip
-                    String unitText = (us==1)? "Miles": "Kilometers";
+                    String unitText = "";
+                    if (units.equals("mi")) unitText = "DISTANCEMILES";
+                    if (units.equals("km")) unitText = "DISTANCEKILOMETERS";
+                    if (units.equals("ft")) unitText = "DISTANCEFEET";
+                    if (units.equals("usft")) unitText = "DISTANCEUSFEET";
+                    if (units.equals("m")) unitText = "DISTANCEMETERS";
+                    unitText = MgLocalizer.GetString(unitText, locale);
+
                     String tip = "Concat(Concat(Concat('" + MgLocalizer.GetString("MEASUREPARTIAL", locale) + ": ', PARTIAL), Concat(', " + MgLocalizer.GetString("MEASURETOTAL", locale) + ": ', TOTAL)), ' (" + unitText + ")')";
 
                     //Create the layer definition
@@ -262,6 +269,7 @@
             String.valueOf(total),
             String.valueOf(distance),
             "1",
+            units,
             vpath + "measure.jsp",
             vpath + "measure.jsp"
     };
@@ -276,6 +284,7 @@
     mapName = ValidateMapName(GetParameter(request, "MAPNAME"));
     target = GetIntParameter(request, "TGT");
     popup = GetIntParameter(request, "POPUP");
+    units = GetParameter(request, "UNITS");
     if(IsParameter(request, "CLEAR"))
     {
         clear = true;
@@ -288,7 +297,6 @@
         x2 = GetDoubleParameter(request, "X2");
         y2 = GetDoubleParameter(request, "Y2");
         total = GetDoubleParameter(request, "TOTAL");
-        us = GetIntParameter(request, "US");
         segId = GetIntParameter(request, "SEGID");
     }
 }

Modified: trunk/MgDev/Web/src/mapviewerjava/measureui.jsp
===================================================================
--- trunk/MgDev/Web/src/mapviewerjava/measureui.jsp	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewerjava/measureui.jsp	2012-07-06 15:25:20 UTC (rev 6868)
@@ -31,6 +31,7 @@
 int cmdIndex = -1;
 String mapName = "";
 String sessionId = "";
+String units = "";
 double total = 0;
 %>
 
@@ -54,6 +55,7 @@
             String.valueOf(total),
             "0",
             "0",
+            units,
             vpath + "measure.jsp",
             vpath + "measure.jsp"
     };
@@ -70,5 +72,6 @@
     cmdIndex = GetIntParameter(request, "CMDINDEX");
     mapName = ValidateMapName(GetParameter(request, "MAPNAME"));
     total = GetDoubleParameter(request, "TOTAL");
+    units = GetParameter(request, "UNITS");
 }
 %>

Modified: trunk/MgDev/Web/src/mapviewernet/measure.aspx
===================================================================
--- trunk/MgDev/Web/src/mapviewernet/measure.aspx	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewernet/measure.aspx	2012-07-06 15:25:20 UTC (rev 6868)
@@ -35,7 +35,7 @@
 double y2 = 0;
 double total = 0;
 String srs = "";
-int us = 0;
+String units = "";
 int segId = 1;
 String error = "";
 double distance = 0;
@@ -102,10 +102,10 @@
 
                 distance = srsMap.ConvertCoordinateSystemUnitsToMeters(distance);
 
-                if (0 == 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;
 
@@ -164,7 +164,14 @@
                         featureSrvc.CreateFeatureSource(dataSourceId, parameters);
 
                         //build map tip
-                        String unitText = (us == 1) ? "Miles" : "Kilometers";
+                        String 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 = MgLocalizer.GetString(unitText, locale);
+
                         String tip = String.Format("Concat(Concat(Concat('" + MgLocalizer.GetString("MEASUREPARTIAL", locale) + ": ', PARTIAL), Concat(', " + MgLocalizer.GetString("MEASURETOTAL", locale) + ": ', TOTAL)), ' ({0})')", unitText);
 
                         //Create the layer definition
@@ -239,6 +246,7 @@
                     total.ToString(NumberFormatInfo.InvariantInfo),
                     distance.ToString(NumberFormatInfo.InvariantInfo),
                     "1",
+                    units,
                     vpath + "measure.aspx",
                     vpath + "measure.aspx"
                     };
@@ -266,6 +274,7 @@
     mapName = ValidateMapName(GetParameter(parameters, "MAPNAME"));
     target = GetIntParameter(parameters, "TGT");
     popup = GetIntParameter(parameters, "POPUP");
+    units = GetParameter(parameters, "UNITS");
     if(IsParameter(parameters, "CLEAR"))
         clear = true;
     else
@@ -275,7 +284,6 @@
         x2 = GetDoubleParameter(parameters, "X2");
         y2 = GetDoubleParameter(parameters, "Y2");
         total = GetDoubleParameter(parameters, "TOTAL");
-        us = GetIntParameter(parameters, "US");
         segId = GetIntParameter(parameters, "SEGID");
     }
 }

Modified: trunk/MgDev/Web/src/mapviewernet/measureui.aspx
===================================================================
--- trunk/MgDev/Web/src/mapviewernet/measureui.aspx	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewernet/measureui.aspx	2012-07-06 15:25:20 UTC (rev 6868)
@@ -30,6 +30,7 @@
 int cmdIndex = -1;
 String mapName = "";
 String sessionId = "";
+String units = "";
 double total = 0;
 </script>
 
@@ -53,6 +54,7 @@
                     total.ToString(NumberFormatInfo.InvariantInfo),
                     "0",
                     "0",
+                    units,
                     vpath + "measure.aspx",
                     vpath + "measure.aspx"
                     };
@@ -77,6 +79,7 @@
     popup = GetIntParameter(parameters, "POPUP");
     cmdIndex = GetIntParameter(parameters, "CMDINDEX");
     total = GetDoubleParameter(parameters, "TOTAL");
+    units = GetParameter(parameters, "UNITS");
 }
 
 </script>

Modified: trunk/MgDev/Web/src/mapviewerphp/measure.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/measure.php	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewerphp/measure.php	2012-07-06 15:25:20 UTC (rev 6868)
@@ -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: trunk/MgDev/Web/src/mapviewerphp/measureui.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/measureui.php	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/mapviewerphp/measureui.php	2012-07-06 15:25:20 UTC (rev 6868)
@@ -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()

Modified: trunk/MgDev/Web/src/viewerfiles/measureui.templ
===================================================================
--- trunk/MgDev/Web/src/viewerfiles/measureui.templ	2012-07-06 15:12:29 UTC (rev 6867)
+++ trunk/MgDev/Web/src/viewerfiles/measureui.templ	2012-07-06 15:25:20 UTC (rev 6868)
@@ -48,13 +48,14 @@
 var total = %s;
 var partial = %s;
 var refresh = %s;
+var units = "%s";
 
 function InitDocument()
 {
     if(!popup)
         document.onmousedown = OnMouseDown;
+    SetUnits();
     SetMeasureResults(partial, total);
-    ShowUnits();
     if(refresh)
         GetParent().Refresh();
 }
@@ -66,14 +67,14 @@
 
 function AddMeasure(segId, begin, end)
 {
-    var url = "%s?SEGID=" + segId + "&LOCALE=" + locale + "&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&X1=" + begin.X + "&Y1=" + begin.Y + "&X2=" + end.X + "&Y2=" + end.Y + "&TOTAL=" + total + "&US=" + (GetParent().GetMapFrame().IsEnglishUnits()? 1: 0) + "&TGT=" + target + "&POPUP=" + popup;
+    var url = "%s?SEGID=" + segId + "&LOCALE=" + locale + "&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&X1=" + begin.X + "&Y1=" + begin.Y + "&X2=" + end.X + "&Y2=" + end.Y + "&TOTAL=" + total + "&UNITS=" + units + "&TGT=" + target + "&POPUP=" + popup;
     document.location.href = url;
 }
 
 function ClearMeasure()
 {
     GetParent().ClearMeasure();
-    var url = "%s?MAPNAME=" + encodeURIComponent(mapName) + "&LOCALE=" + locale + "&SESSION=" + sessionId + "&CLEAR=&TGT=" + target + "&POPUP=" + popup;
+    var url = "%s?MAPNAME=" + encodeURIComponent(mapName) + "&LOCALE=" + locale + "&SESSION=" + sessionId + "&CLEAR=&TGT=" + target + "&POPUP=" + popup + "&UNITS=" + units;
     document.location.href = url;
     GetParent().ResumeMeasure();
 }
@@ -111,13 +112,46 @@
     document.getElementById("total").innerHTML = FormatLocalizedDecimal(total, 2);
 }
 
-function ShowUnits()
+function OnChangeUnits()
 {
-    var units = GetParent().GetMapFrame().IsEnglishUnits()? "__#MILES#__": "__#KILOMETERS#__";
-    document.getElementById("units1").innerHTML = units;
-    document.getElementById("units2").innerHTML = units;
+    var unitelem = document.getElementById("unitselect");
+    for (var i=0; i < unitelem.length; i++)
+    {
+        var opt = unitelem.options[i];
+        if (opt.selected)
+        {
+            units = opt.value;
+            document.getElementById("units1").innerHTML = opt.text;
+            document.getElementById("units2").innerHTML = opt.text;
+            break;
+        }
+    }
 }
 
+function SetUnits()
+{
+    if (!units || units == "")
+    {
+        units = GetParent().GetMapFrame().IsEnglishUnits()? "mi": "km";
+    }
+
+    var unitelem = document.getElementById("unitselect");
+    var unitText = "";
+    for (var i=0; i < unitelem.length; i++)
+    {
+        var opt = unitelem.options[i];
+        opt.selected = false;
+        if (opt.value == units)
+        {
+            opt.selected = true;
+            unitText = opt.text;
+        }
+    }
+
+    document.getElementById("units1").innerHTML = unitText;
+    document.getElementById("units2").innerHTML = unitText;
+}
+
 function FormatLocalizedDecimal(numberValue, decimalPlaces)
 {
     var unlocalized = numberValue.toFixed(decimalPlaces);
@@ -138,6 +172,16 @@
     <tr><td class="Title">__#MEASURETITLE#__<hr></td></tr>
     <tr><td class="InfoText">__#MEASUREINFO#__</td></tr>
     <tr><td height="6"></td></tr>
+    <tr><td class="InfoText">__#MEASUREUNITS#__</td></tr>
+    <tr><td>
+      <select id="unitselect" name="UNITS" class="Ctrl" onchange="OnChangeUnits()">
+        <option value="mi">__#DISTANCEMILES#__</option>
+        <option value="km">__#DISTANCEKILOMETERS#__</option>
+        <option value="usft">__#DISTANCEUSFEET#__</option>
+        <option value="ft">__#DISTANCEFEET#__</option>
+        <option value="m">__#DISTANCEMETERS#__</option>
+      </select>
+    </td></tr>
   </table>
   <table border="0" cellpadding="5">
     <tr class="RegText">



More information about the mapguide-commits mailing list