[fusion-commits] r2419 - trunk/widgets/QuickPlot
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Aug 9 02:22:52 EDT 2011
Author: liuar
Date: 2011-08-08 23:22:51 -0700 (Mon, 08 Aug 2011)
New Revision: 2419
Modified:
trunk/widgets/QuickPlot/GeneratePicture.php
Log:
On behalf of Mars Wu
For ticket 1757: http://trac.osgeo.org/mapguide/ticket/1757
Modified: trunk/widgets/QuickPlot/GeneratePicture.php
===================================================================
--- trunk/widgets/QuickPlot/GeneratePicture.php 2011-08-03 06:17:17 UTC (rev 2418)
+++ trunk/widgets/QuickPlot/GeneratePicture.php 2011-08-09 06:22:51 UTC (rev 2419)
@@ -14,9 +14,18 @@
$normalizedCapture;
$printSize;
$paperSize;
-
- GetParameters();
- GenerateMap($printSize);
+
+ try
+ {
+ GetParameters();
+ GenerateMap($printSize);
+ }
+ catch (MgException $e)
+ {
+ header ("Content-type: text/html");
+ echo "ERROR: " . $e->GetExceptionMessage() . "<br>";
+ echo $e->GetStackTrace() . "<br>";
+ }
?>
<?php
@@ -82,7 +91,6 @@
$map->Open($resourceService, $mapName);
$selection = new MgSelection($map);
- $color = new MgColor(255, 255, 255);
// Calculate the generated picture size
$envelope = $captureBox->Envelope();
@@ -92,30 +100,27 @@
$toSize = new Size($size1->width / $size2->width * $size->width, $size1->height / $size2->height * $size->height);
$center = $captureBox->GetCentroid()->GetCoordinate();
- // Get the map agent url
- // Get the correct http protocal
- $mapAgent = "http";
- if ($_SERVER["HTTPS"] == "on")
- {
- $mapAgent .= "s";
- }
- // Get the correct port number
- $mapAgent .= "://127.0.0.1:" . $_SERVER["SERVER_PORT"];
- // Get the correct virtual directory
- $mapAgent .= substr($_SERVER["REQUEST_URI"], 0, strpos($_SERVER["REQUEST_URI"], "/", 1));
- $mapAgent .="/mapagent/mapagent.fcgi?VERSION=1.0.0&OPERATION=GETMAPIMAGE" .
- "&SESSION=$sessionID" .
- "&MAPNAME=" . rawurlencode($mapName) .
- "&FORMAT=PNG" .
- "&SETVIEWCENTERX=" . $center->GetX() .
- "&SETVIEWCENTERY=" . $center->GetY() .
- "&SETVIEWSCALE=$scaleDenominator" .
- "&SETDISPLAYDPI=$printDpi" .
- "&SETDISPLAYWIDTH=$toSize->width" .
- "&SETDISPLAYHEIGHT=$toSize->height" .
- "&CLIP=0";
+ $map->SetDisplayDpi($printDpi);
+ $colorString = $map->GetBackgroundColor();
+ // The returned color string is in AARRGGBB format. But the constructor of MgColor needs a string in RRGGBBAA format
+ $colorString = substr($colorString, 2, 6) . substr($colorString, 0, 2);
+ $color = new MgColor($colorString);
- $image = imagecreatefrompng($mapAgent);
+ $mgReader = $renderingService->RenderMap($map,
+ $selection,
+ $center,
+ $scaleDenominator,
+ $toSize->width,
+ $toSize->height,
+ $color,
+ "PNG",
+ false);
+
+ $tempImage = sys_get_temp_dir() . uniqid();
+ $mgReader->ToFile($tempImage);
+ $image = imagecreatefrompng($tempImage);
+ unlink($tempImage);
+
// Rotate the picture back to be normalized
$normalizedImg = imagerotate($image, -$rotation, 0);
// Free the original image
More information about the fusion-commits
mailing list