[fusion-commits] r1443 - in trunk: MapGuide/php widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Jul 25 12:07:30 EDT 2008
Author: zjames
Date: 2008-07-25 12:07:30 -0400 (Fri, 25 Jul 2008)
New Revision: 1443
Modified:
trunk/MapGuide/php/SaveMap.php
trunk/widgets/SaveMap.js
Log:
closes #91 - savemap dwf scales ignored. Also simplifies SaveMap.php DWF handling.
Modified: trunk/MapGuide/php/SaveMap.php
===================================================================
--- trunk/MapGuide/php/SaveMap.php 2008-07-22 15:00:30 UTC (rev 1442)
+++ trunk/MapGuide/php/SaveMap.php 2008-07-25 16:07:30 UTC (rev 1443)
@@ -27,7 +27,6 @@
/*****************************************************************************
* Purpose: get map initial information
*****************************************************************************/
-
include('Common.php');
$format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'png';
$layout = isset($_REQUEST['layout']) ? $_REQUEST['layout'] : null;
@@ -37,7 +36,6 @@
$pageHeight = isset($_REQUEST['pageheight']) ? $_REQUEST['pageheight'] : 11;
$pageWidth = isset($_REQUEST['pagewidth']) ? $_REQUEST['pagewidth'] : 8.5;
$aMargins = isset($_REQUEST['margins']) ? explode(',',$_REQUEST['margins']) : array(0,0,0,0);
-
try
{
$mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
@@ -48,13 +46,12 @@
$selection = new MgSelection($map);
$selection->Open($resourceService, $mapName);
- //compute center
- $extent = $map->GetMapExtent();
- $centerX = $extent->GetLowerLeftCoordinate()->GetX() + ($extent->GetWidth())/2;
- $centerY = $extent->GetLowerLeftCoordinate()->GetY() + ($extent->GetHeight())/2;
- $geomFactory = new MgGeometryFactory();
- $center = $geomFactory->CreateCoordinateXY($centerX, $centerY);
+ //get current center as a coordinate
+ $center = $map->GetViewCenter()->GetCoordinate();
+ //plot with the passed scale, if provided
+ $scale = isset($_REQUEST['scale']) ? $_REQUEST['scale'] : $map->GetViewScale();
+
if ($format == 'DWF') {
$oLayout = null;
if ($layout) {
@@ -71,53 +68,15 @@
$dwfVersion = new MgDwfVersion('6.01','1.2');
- if ($scale) {
- //plot with the passed scale
-
- $coordSysFactory = new MgCoordinateSystemFactory();
- $coordSystem = $coordSysFactory->Create($map->GetMapSRS());
- $metersPerUnit = $coordSystem->ConvertCoordinateSystemUnitsToMeters(1.0);
- $metersPerPixel = 1.0/(100.0 / 2.54 * $map->GetDisplayDpi());
-
- $height = $map->GetDisplayHeight();
- $width = $map->GetDisplayWidth();
- $mapWidth = $scale * $width * $metersPerPixel/$metersPerUnit;
- $mapHeight = $scale * $height * $metersPerPixel/$metersPerUnit;
- $extent = new MgEnvelope(
- $center->GetX() - 0.5*$mapWidth,
- $center->GetY() - 0.5*$mapHeight,
- $center->GetX() + 0.5*$mapWidth,
- $center->GetY() + 0.5*$mapHeight);
- //this is broken because the swig api has an error
- //$center = $map->GetViewCenter();
- // echo $oPlotSpec; exit;
- //echo $map->GetName()." ".$center->GetX().", ".
- // $center->GetY().", ".
- // $scale." paper height: ".
- //$oPlotSpec->GetPaperHeight().", layout: ".$oLayout->GetTitle().", dwfVersion ".$dwfVersion->GetFileVersion()."\n";
- // $oImg = $mappingService->GeneratePlot($map,
- // $center,
- // $scale,
- // $oPlotSpec,
- // $oLayout,
- // $dwfVersion);
-
- $oImg = $mappingService->GeneratePlot($map, $extent, true,
- $oPlotSpec,
- $oLayout,
- $dwfVersion);
-
- } else {
- //use current extents for plot
- $oImg = $mappingService->GeneratePlot($map, $extent, false,
- $oPlotSpec,
- $oLayout,
- $dwfVersion);
- }
+ $oImg = $mappingService->GeneratePlot($map,
+ $center,
+ $scale,
+ $oPlotSpec,
+ $oLayout,
+ $dwfVersion);
} else {
//render as an image
if (isset($imgHeight) && isset($imgWidth)) {
- $scale = $map->GetViewScale();
$oImg = $renderingService->RenderMap($map, $selection,
$center, $scale,
$imgWidth, $imgHeight,
Modified: trunk/widgets/SaveMap.js
===================================================================
--- trunk/widgets/SaveMap.js 2008-07-22 15:00:30 UTC (rev 1442)
+++ trunk/widgets/SaveMap.js 2008-07-25 16:07:30 UTC (rev 1443)
@@ -80,10 +80,11 @@
if (layout.Scale) {
//create entries for weblayout specified scales
menuItem = new Jx.SubMenu(opt);
+ data.scales = [];
for (var j=0; j < layout.Scale.length; j++) {
- data.scale = layout.Scale[j];
- var scaleAction = new Jx.Action(this.setLayout.bind(this, data));
- var subMenuItem = new Jx.MenuItem(scaleAction,{label:data.scale});
+ data.scales.push(layout.Scale[j]);
+ var scaleAction = new Jx.Action(this.setLayout.bind(this, data, j));
+ var subMenuItem = new Jx.MenuItem(scaleAction,{label:layout.Scale[j]});
menuItem.add(subMenuItem);
}
//add an entry for current scale
@@ -116,11 +117,17 @@
},
setLayout: function(data) {
- this.printScale = data.scale;
this.printLayout = data.rid;
this.pageHeight = data.pageHeight;
this.pageWidth = data.pageWidth;
this.pageMargins = data.margins;
+ //when the selected item has a scale, the index into the scales array
+ //is passed, otherwise value is reset and current scale is used.
+ if (arguments.length == 3){
+ this.printScale = parseFloat(data.scales[arguments[1]]);
+ } else {
+ this.printScale = null;
+ }
this.activateTool();
},
@@ -171,10 +178,10 @@
}
var m = this.getMap().aMaps[0];
if(navigator.appVersion.match(/\bMSIE\b/)) {
- var url = Fusion.fusionURL + '/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMapFrame." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format + szLayout + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
+ var url = Fusion.fusionURL + '/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMapFrame." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format + szLayout + szScale + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
w = open(url, "Save", 'menubar=no,height=200,width=300');
} else {
- var s = Fusion.fusionURL + '/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMap." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format + szLayout + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
+ var s = Fusion.fusionURL + '/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMap." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format + szLayout + szScale + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
this.iframe.src = s;
}
More information about the fusion-commits
mailing list