From d58306ec06b31257307f3da7fb6dde2e26c0e220 Mon Sep 17 00:00:00 2001 From: goodsoft Date: Wed, 24 Apr 2013 03:40:53 +0300 Subject: [PATCH] Updated quadkey calculations for new protocol --- code/map_data_calc_tools.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index 2f383197..c464d277 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -1,5 +1,4 @@ - // MAP DATA REQUEST CALCULATORS ////////////////////////////////////// // Ingress Intel splits up requests for map data (portals, links, // fields) into tiles. To get data for the current viewport (i.e. what @@ -23,9 +22,9 @@ window.calculateR = function(convCenterLat) { } window.convertLatLngToPoint = function(latlng, magic, R) { - var x = (magic/2 + latlng.lng * magic / 360)*R; + var x = (magic + latlng.lng * magic / 180)*R; var l = Math.sin(latlng.lat * DEG2RAD); - var y = (magic/2 + 0.5*Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; + var y = (magic + Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; return {x: Math.floor(x/magic), y: Math.floor(y/magic)}; } @@ -35,13 +34,13 @@ window.convertPointToLatLng = function(x, y, magic, R) { // orig function put together from all over the place // lat: (2 * Math.atan(Math.exp((((y + 1) * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), // shortened version by your favorite algebra program. - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*(y+1)/R)))/Math.PI - 90, - lng: 360*x/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*(y+1)/R)))/Math.PI - 90, + lng: 180*x/R-180 }; e.ne = { //lat: (2 * Math.atan(Math.exp(((y * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*y/R)))/Math.PI - 90, - lng: 360*(x+1)/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*y/R)))/Math.PI - 90, + lng: 180*(x+1)/R-180 }; return e; } @@ -49,7 +48,8 @@ window.convertPointToLatLng = function(x, y, magic, R) { // calculates the quad key for a given point. The point is not(!) in // lat/lng format. window.pointToQuadKey = function(x, y) { - var quadkey = []; + return window.map.getZoom() + "_" + x + "_" + y; + /*var quadkey = []; for(var c = window.map.getZoom(); c > 0; c--) { // +-------+ quadrants are probably ordered like this // | 0 | 1 | @@ -62,7 +62,7 @@ window.pointToQuadKey = function(x, y) { (y & e) != 0 && (quadrant++, quadrant++); // push down quadkey.push(quadrant); } - return quadkey.join(""); + return quadkey.join("");*/ } // given quadkey and bounds, returns the format as required by the