Author:   Wolfgang <[email protected]>
Date:     Thu Mar 28 23:27:58 2013 +0100
Committer:   Wolfgang <[email protected]>
Commit-Date: Thu Mar 28 23:27:58 2013 +0100

fix calculation of lat coordinates on geomaps

---

 share/server/core/sources/geomap.php |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/share/server/core/sources/geomap.php 
b/share/server/core/sources/geomap.php
index f9a4489..8e378a2 100644
--- a/share/server/core/sources/geomap.php
+++ b/share/server/core/sources/geomap.php
@@ -351,6 +351,7 @@ function process_geomap($MAPCFG, $map_name, &$map_config) {
 
     $long_para = $params['width'] / $long_diff;
     $lat_para  = $params['height'] / $lat_diff;
+    $lat_mult  = $params['height'] / (ProjectF($img_top) - 
ProjectF($img_down));
 
     // Now add the coordinates to the map objects
     foreach($map_config AS &$obj) {
@@ -358,7 +359,7 @@ function process_geomap($MAPCFG, $map_name, &$map_config) {
             continue;
 
         // Calculate the lat (y) coords
-        $obj['y'] = round($lat_para * ($img_top - $obj['lat']) + ($icon_h / 
2));
+        $obj['y'] = round((ProjectF($img_top) - ProjectF($obj['lat'])) * 
lat_mult - ($icon_h / 2));
         if($obj['y'] < 0)
             $obj['y'] = 0;             
         
@@ -399,4 +400,16 @@ function changed_geomap($MAPCFG, $compare_time) {
     return false;
 }
 
+# calculate lat on Mercator based map
+# for details see:
+#    http://wiki.openstreetmap.org/wiki/Slippy_map_tilesnames#X_and_Y
+# function copied from
+#    http://almien.co.uk/OSM/Tools/Coord/source.php
+
+function ProjectF($Lat){
+  $Lat = deg2rad($Lat);
+  $Y = log(tan($Lat) + (1/cos($Lat)));
+  return($Y);
+}
+
 ?>


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to