[Mapbender-commits] r3807 - in branches/print_dev/http: classes
print/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Mar 25 10:07:03 EDT 2009
Author: mschulz
Date: 2009-03-25 10:07:03 -0400 (Wed, 25 Mar 2009)
New Revision: 3807
Modified:
branches/print_dev/http/classes/class_map.php
branches/print_dev/http/print/classes/mbTemplatePdf.php
Log:
class_map: added scale calculation
Modified: branches/print_dev/http/classes/class_map.php
===================================================================
--- branches/print_dev/http/classes/class_map.php 2009-03-24 13:06:39 UTC (rev 3806)
+++ branches/print_dev/http/classes/class_map.php 2009-03-25 14:07:03 UTC (rev 3807)
@@ -137,7 +137,34 @@
}
$this->setExtent($aMapbenderBbox);
}
+
+ /**
+ *
+ * @return Int scale of map
+ */
+ public function getScale($mapResolutionDpi = MB_RESOLUTION){
+ $scale;
+ $xtenty;
+ $bbox = $this->getExtentInfo();
+ if ($this->getEpsg() == "EPSG:4326") {
+ $pxLenx = ($bbox[2] - $bbox[0]) / $this->getWidth();
+ $pxLeny = ($bbox[3] - $bbox[1]) / $this->getHeight();
+ $lat_from = ((($bbox[3] - $bbox[1]) / 2) * M_PI) / 180;
+ $lat_to = ((($bbox[3] - $bbox[1]) / 2 + $pxLeny) * M_PI) / 180;
+ $lon_from = ((($bbox[2] - $bbox[0]) / 2) * M_PI) / 180;
+ $lon_to = ((($bbox[2] - $bbox[0]) / 2 + $pxLeny) * M_PI) / 180;
+ $dist = 6371229 * acos(sin($lat_from) * sin($lat_to) + cos($lat_from) * cos($lat_to) * cos($lon_from - $lon_to));
+ $scale = ($dist / sqrt(2)) * ($mapResolutionDpi * 100);
+ }
+ else {
+ $xtenty = $bbox[3]) - $bbox[1]);
+ $scale = ($xtenty / $this->getHeight()) * ($mapResolutionDpi * 100);
+ }
+ return round($scale);
+ };
+
+
/**
*
* @return String EPSG code of the map.
Modified: branches/print_dev/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/print_dev/http/print/classes/mbTemplatePdf.php 2009-03-24 13:06:39 UTC (rev 3806)
+++ branches/print_dev/http/print/classes/mbTemplatePdf.php 2009-03-25 14:07:03 UTC (rev 3807)
@@ -48,6 +48,7 @@
$aMap->setWidth($elementConf->width);
$aMap->setHeight($elementConf->height);
$aMap->calculateExtent($aMbBbox);
+ $this->mapinfo["scale"] = $aMap->getScale($elementConf->res_dpi);
$adjustedMapExt = $aMap->getExtentInfo();
return implode(",",$adjustedMapExt);
}
More information about the Mapbender_commits
mailing list