[Mapbender-commits] r5374 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Jan 20 08:47:50 EST 2010
Author: christoph
Date: 2010-01-20 08:47:49 -0500 (Wed, 20 Jan 2010)
New Revision: 5374
Modified:
trunk/mapbender/http/classes/class_map.php
Log:
Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php 2010-01-20 13:36:12 UTC (rev 5373)
+++ trunk/mapbender/http/classes/class_map.php 2010-01-20 13:47:49 UTC (rev 5374)
@@ -136,7 +136,33 @@
}
$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.
@@ -584,7 +610,7 @@
// reset the WMS array
// BEWARE, SUPER UGLY CODE AHEAD!!
// (BUT THERE IS NO OTHER WAY TO DO IT)
- if (strpos($row["e_js_file"], "ovnf.php") !== false) {
+ if (strpos($row["e_js_file"], "mb_overview.js") !== false) {
// $e = new mb_exception("guess this is the OV");
$ov_sql = "SELECT var_value FROM gui_element_vars WHERE " .
More information about the Mapbender_commits
mailing list