[mapguide-commits] r9943 - sandbox/jng/vanilla_swig/Web/src/mapviewerphp

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu May 26 04:08:52 PDT 2022


Author: jng
Date: 2022-05-26 04:08:52 -0700 (Thu, 26 May 2022)
New Revision: 9943

Modified:
   sandbox/jng/vanilla_swig/Web/src/mapviewerphp/quickplotgeneratepicture.php
Log:
Fix up QuickPlot in PHP AJAX viewer. Force correct double/int data types where required.

Modified: sandbox/jng/vanilla_swig/Web/src/mapviewerphp/quickplotgeneratepicture.php
===================================================================
--- sandbox/jng/vanilla_swig/Web/src/mapviewerphp/quickplotgeneratepicture.php	2022-05-26 11:07:01 UTC (rev 9942)
+++ sandbox/jng/vanilla_swig/Web/src/mapviewerphp/quickplotgeneratepicture.php	2022-05-26 11:08:52 UTC (rev 9943)
@@ -45,7 +45,7 @@
 
         $array       = explode(",", $args["paper_size"]);
         $paperSize   = new Size(ParseLocaleDouble($array[0]), ParseLocaleDouble($array[1]));
-        $printSize   = new Size($paperSize->width / 25.4 * $printDpi, $paperSize->height / 25.4 * $printDpi);
+        $printSize   = new Size(intval($paperSize->width / 25.4 * $printDpi), intval($paperSize->height / 25.4 * $printDpi));
 
         $array       = explode(",", $args["box"]);
         $captureBox  = CreatePolygon($array);
@@ -104,15 +104,15 @@
         $colorString = substr($colorString, 2, 6) . substr($colorString, 0, 2);
         $color = new MgColor($colorString);
 
-        $mgReader = $renderingService->RenderMap($map, 
-                                                $selection, 
-                                                $center,
-                                                $scaleDenominator, 
-                                                $toSize->width, 
-                                                $toSize->height,
-                                                $color,
-                                                "PNG",
-                                                false);
+        $mgReader = $renderingService->RenderMap($map,
+                                                 $selection,
+                                                 $center,
+                                                 doubleval($scaleDenominator),
+                                                 intval($toSize->width),
+                                                 intval($toSize->height),
+                                                 $color,
+                                                 "PNG",
+                                                 false);
 
         $tempImage = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "mgo" . uniqid();
         $mgReader->ToFile($tempImage);
@@ -125,7 +125,7 @@
         imagedestroy($image);
         // Crop the normalized image
         $croppedImg = imagecreatetruecolor($size->width, $size->height);
-        imagecopy($croppedImg, $normalizedImg, 0, 0, (imagesx($normalizedImg) - $size->width) / 2, (imagesy($normalizedImg) - $size->height) / 2, $size->width, $size->height);
+        imagecopy($croppedImg, $normalizedImg, 0, 0, intval((imagesx($normalizedImg) - $size->width) / 2), intval((imagesy($normalizedImg) - $size->height) / 2), $size->width, $size->height);
         // Free the normalized image
         imagedestroy($normalizedImg);
         // Draw the north arrow on the map
@@ -171,10 +171,10 @@
         $naRes      = 300;
         $naMargin   = 12;
         // Calculate the margin as pixels according to the resolutions
-        $margin     = $resolution * $naMargin / 25.4;
+        $margin     = intval($resolution * $naMargin / 25.4);
         // Get the width of the north arrow on the map picture
-        $drawWidth  = $naWidth * $resolution / $naRes;
-        $drawHeight = $naHeight * $resolution / $naRes;
+        $drawWidth  = intval($naWidth * $resolution / $naRes);
+        $drawHeight = intval($naHeight * $resolution / $naRes);
         // Draw the north arrow on the map picture
         imagecopyresized($map, $rotatedNa, $mapWidth - $drawWidth - $margin, $mapHeight - $drawHeight - $margin, 0, 0, $drawWidth, $drawHeight, $naWidth, $naHeight);
         // Free the north arrow image



More information about the mapguide-commits mailing list