[mapguide-commits] r6010 - in trunk/MgDev/Web/src: mapviewerjava
mapviewernet mapviewerphp
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 27 21:51:16 EDT 2011
Author: liuar
Date: 2011-07-27 18:51:16 -0700 (Wed, 27 Jul 2011)
New Revision: 6010
Modified:
trunk/MgDev/Web/src/mapviewerjava/quickplotgeneratepicture.jsp
trunk/MgDev/Web/src/mapviewernet/quickplotgeneratepicture.aspx
trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php
Log:
On behalf of Mars Wu
For Ticket 1757: http://trac.osgeo.org/mapguide/ticket/1757
Modified: trunk/MgDev/Web/src/mapviewerjava/quickplotgeneratepicture.jsp
===================================================================
--- trunk/MgDev/Web/src/mapviewerjava/quickplotgeneratepicture.jsp 2011-07-27 12:59:56 UTC (rev 6009)
+++ trunk/MgDev/Web/src/mapviewerjava/quickplotgeneratepicture.jsp 2011-07-28 01:51:16 UTC (rev 6010)
@@ -46,24 +46,25 @@
%>
<%
-
GetRequestParameters(request);
response.setContentType("image/png");
ImageIO.write(GenerateMap(printSize), "png", response.getOutputStream());
-
%>
<%!
-void GetRequestParameters(HttpServletRequest request) throws MgException
+void GetRequestParameters(HttpServletRequest request) throws MgException, ParseException
{
+ NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
+
sessionId = ValidateSessionId(GetParameter(request, "session_id"));
mapName = ValidateMapName(GetParameter(request, "map_name"));
- rotation = GetDoubleParameter(request, "rotation");
+ rotation = numberFormat.parse(request.getParameter("rotation")).doubleValue();
printDpi = GetIntParameter(request, "print_dpi");
scaleDenominator = GetIntParameter(request, "scale_denominator");
String[] a = GetParameter(request, "paper_size").split(",");
- paperSize = new Size<Double>(Double.parseDouble(a[0]), Double.parseDouble(a[1]));
+
+ paperSize = new Size<Double>(numberFormat.parse(a[0]).doubleValue(), numberFormat.parse(a[1]).doubleValue());
printSize = new Size<Integer>((int) (paperSize.width / 25.4 * printDpi), (int) (paperSize.height / 25.4 * printDpi));
a = GetParameter(request, "box").split(",");
@@ -76,17 +77,18 @@
naPath = getServletContext().getRealPath("viewerfiles/quickplotnortharrow.png");
}
-MgPolygon CreatePolygon(String[] coordinates) throws MgException
+MgPolygon CreatePolygon(String[] coordinates) throws MgException, ParseException
{
MgGeometryFactory geometryFactory = new MgGeometryFactory();
MgCoordinateCollection coordinateCollection = new MgCoordinateCollection();
+ NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
for (int i = 0; i < coordinates.length; ++i)
{
- coordinateCollection.Add(geometryFactory.CreateCoordinateXY(Double.parseDouble(coordinates[i]), Double.parseDouble(coordinates[++i])));
+ coordinateCollection.Add(geometryFactory.CreateCoordinateXY(numberFormat.parse(coordinates[i]).doubleValue(), numberFormat.parse(coordinates[++i]).doubleValue()));
}
- coordinateCollection.Add(geometryFactory.CreateCoordinateXY(Double.parseDouble(coordinates[0]), Double.parseDouble(coordinates[1])));
+ coordinateCollection.Add(geometryFactory.CreateCoordinateXY(numberFormat.parse(coordinates[0]).doubleValue(), numberFormat.parse(coordinates[1]).doubleValue()));
MgLinearRing linearRing = geometryFactory.CreateLinearRing(coordinateCollection);
return geometryFactory.CreatePolygon(linearRing, null);
Modified: trunk/MgDev/Web/src/mapviewernet/quickplotgeneratepicture.aspx
===================================================================
--- trunk/MgDev/Web/src/mapviewernet/quickplotgeneratepicture.aspx 2011-07-27 12:59:56 UTC (rev 6009)
+++ trunk/MgDev/Web/src/mapviewernet/quickplotgeneratepicture.aspx 2011-07-28 01:51:16 UTC (rev 6010)
@@ -23,6 +23,7 @@
<%@ Import Namespace="OSGeo.MapGuide" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
+<%@ Import Namespace="System.Globalization" %>
<!-- #Include File="common.aspx -->
@@ -41,6 +42,7 @@
<%
Response.Charset = "utf-8";
+
GetRequestParameters();
GenerateMap(printSize);
%>
@@ -65,7 +67,7 @@
scaleDenominator = GetIntParameter(parameters, "scale_denominator");
string[] a = parameters["paper_size"].Split(',');
- paperSize = new SizeF(float.Parse(a[0]), float.Parse(a[1]));
+ paperSize = new SizeF(float.Parse(a[0], CultureInfo.InvariantCulture), float.Parse(a[1], CultureInfo.InvariantCulture));
printSize = new Size((int) (paperSize.Width / 25.4 * printDpi), (int) (paperSize.Height / 25.4 * printDpi));
a = parameters["box"].Split(',');
@@ -82,10 +84,10 @@
for (int i = 0; i < coordinates.Length; ++i)
{
- coordinateCollection.Add(geometryFactory.CreateCoordinateXY(double.Parse(coordinates[i]), double.Parse(coordinates[++i])));
+ coordinateCollection.Add(geometryFactory.CreateCoordinateXY(double.Parse(coordinates[i], CultureInfo.InvariantCulture), double.Parse(coordinates[++i], CultureInfo.InvariantCulture)));
}
- coordinateCollection.Add(geometryFactory.CreateCoordinateXY(double.Parse(coordinates[0]), double.Parse(coordinates[1])));
+ coordinateCollection.Add(geometryFactory.CreateCoordinateXY(double.Parse(coordinates[0], CultureInfo.InvariantCulture), double.Parse(coordinates[1], CultureInfo.InvariantCulture)));
MgLinearRing linearRing = geometryFactory.CreateLinearRing(coordinateCollection);
return geometryFactory.CreatePolygon(linearRing, null);
Modified: trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php 2011-07-27 12:59:56 UTC (rev 6009)
+++ trunk/MgDev/Web/src/mapviewerphp/quickplotgeneratepicture.php 2011-07-28 01:51:16 UTC (rev 6010)
@@ -30,13 +30,13 @@
// Not necessary to validate the parameters
$sessionID = $args["session_id"];
$mapName = $args["map_name"];
- $rotation = floatval($args["rotation"]);
+ $rotation = ParseLocaleDouble($args["rotation"]);
$printDpi = intval($args["print_dpi"]);
$scaleDenominator = intval($args["scale_denominator"]);
$array = explode(",", $args["paper_size"]);
- $paperSize = new Size(floatval($array[0]), floatval($array[1]));
+ $paperSize = new Size(ParseLocaleDouble($array[0]), ParseLocaleDouble($array[1]));
$printSize = new Size($paperSize->width / 25.4 * $printDpi, $paperSize->height / 25.4 * $printDpi);
$array = explode(",", $args["box"]);
@@ -54,11 +54,11 @@
for ($index = 0; $index < count($coordinates); ++$index)
{
- $coordinate = $geometryFactory->CreateCoordinateXY(floatval($coordinates[$index]), floatval($coordinates[++$index]));
+ $coordinate = $geometryFactory->CreateCoordinateXY(ParseLocaleDouble($coordinates[$index]), ParseLocaleDouble($coordinates[++$index]));
$coordinateCollection->Add($coordinate);
}
- $coordinateCollection->Add($geometryFactory->CreateCoordinateXY(floatval($coordinates[0]), floatval($coordinates[1])));
+ $coordinateCollection->Add($geometryFactory->CreateCoordinateXY(ParseLocaleDouble($coordinates[0]), ParseLocaleDouble($coordinates[1])));
$linearRingCollection = $geometryFactory->CreateLinearRing($coordinateCollection);
$captureBox = $geometryFactory->CreatePolygon($linearRingCollection, null);
@@ -92,7 +92,7 @@
// Get the map agent url
// Get the correct http protocal
$mapAgent = "http";
- if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on")
+ if ($_SERVER["HTTPS"] == "on")
{
$mapAgent .= "s";
}
@@ -113,7 +113,7 @@
"&SETDISPLAYWIDTH=$toSize->width" .
"&SETDISPLAYHEIGHT=$toSize->height" .
"&CLIP=0";
-
+
$image = imagecreatefrompng($mapAgent);
// Rotate the picture back to be normalized
$normalizedImg = imagerotate($image, -$rotation, 0);
@@ -165,6 +165,12 @@
imagedestroy($rotatedNa);
}
+ function ParseLocaleDouble($stringValue)
+ {
+ $lc = localeconv();
+ $result = str_replace(".", $lc["decimal_point"], $stringValue);
+ return doubleval($result);
+ }
?>
<?php
More information about the mapguide-commits
mailing list