Index: src/localized/en =================================================================== --- src/localized/en (revision 6096) +++ src/localized/en (working copy) @@ -112,6 +112,7 @@ COLORPICKERHEXFORMAT = Hex format # MeasureUI +MEASUREUNITS = Measure units: MEASURETITLE = Measure Distance MEASUREINFO = Click a start and end point. RESUME = Resume Index: src/mapviewerjava/measure.jsp =================================================================== --- src/mapviewerjava/measure.jsp (revision 6096) +++ src/mapviewerjava/measure.jsp (working copy) @@ -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,9 @@ 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 total += distance; @@ -186,7 +185,13 @@ 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("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 +267,7 @@ String.valueOf(total), String.valueOf(distance), "1", + units, vpath + "measure.jsp", vpath + "measure.jsp" }; @@ -276,6 +282,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 +295,6 @@ x2 = GetDoubleParameter(request, "X2"); y2 = GetDoubleParameter(request, "Y2"); total = GetDoubleParameter(request, "TOTAL"); - us = GetIntParameter(request, "US"); segId = GetIntParameter(request, "SEGID"); } } Index: src/mapviewerjava/measureui.jsp =================================================================== --- src/mapviewerjava/measureui.jsp (revision 6096) +++ src/mapviewerjava/measureui.jsp (working copy) @@ -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"); } %> Index: src/mapviewernet/measure.aspx =================================================================== --- src/mapviewernet/measure.aspx (revision 6096) +++ src/mapviewernet/measure.aspx (working copy) @@ -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,9 @@ 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 total += distance; @@ -164,7 +163,13 @@ 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 == "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 +244,7 @@ total.ToString(NumberFormatInfo.InvariantInfo), distance.ToString(NumberFormatInfo.InvariantInfo), "1", + units, vpath + "measure.aspx", vpath + "measure.aspx" }; @@ -266,6 +272,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 +282,6 @@ x2 = GetDoubleParameter(parameters, "X2"); y2 = GetDoubleParameter(parameters, "Y2"); total = GetDoubleParameter(parameters, "TOTAL"); - us = GetIntParameter(parameters, "US"); segId = GetIntParameter(parameters, "SEGID"); } } Index: src/mapviewernet/measureui.aspx =================================================================== --- src/mapviewernet/measureui.aspx (revision 6096) +++ src/mapviewernet/measureui.aspx (working copy) @@ -30,6 +30,7 @@ int cmdIndex = -1; String mapName = ""; String sessionId = ""; +String units = ""; double total = 0; @@ -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"); } Index: src/mapviewerphp/measure.php =================================================================== --- src/mapviewerphp/measure.php (revision 6096) +++ src/mapviewerphp/measure.php (working copy) @@ -32,7 +32,7 @@ $y2 = 0; $total = 0; $srs = ""; - $us = 1; + $units = ""; $segId = 1; $error = ""; $distance = 0; @@ -92,11 +92,11 @@ $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 + $total += $distance; //create the line string geometry representing this segment @@ -154,7 +154,13 @@ $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 == "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 +233,7 @@ $total, $distance, 1, + $units, $vpath . "measure.php", $vpath . "measure.php"); @@ -282,7 +289,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 +298,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'); Index: src/mapviewerphp/measureui.php =================================================================== --- src/mapviewerphp/measureui.php (revision 6096) +++ src/mapviewerphp/measureui.php (working copy) @@ -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() Index: src/viewerfiles/measureui.templ =================================================================== --- src/viewerfiles/measureui.templ (revision 6096) +++ src/viewerfiles/measureui.templ (working copy) @@ -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; } @@ -110,13 +111,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()? "km": "mi"; + } + + 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); @@ -137,6 +171,15 @@