计算地图上的高度给定缩放级别在谷歌地图

问题描述:

我想计算高于地图(忽略地形)给定缩放级别的高度。我知道特定缩放级别的缩放等式是591657550.5/2 ^(level-1)(https://gis.stackexchange.com/questions/7430/google-maps-zoom-level-ratio),但我不确定如何使用此信息(或者是否这是正确的信息)来解决高度以上地图。任何帮助表示赞赏。计算地图上的高度给定缩放级别在谷歌地图

+0

问题是(从数学上讲)中的比特不明确的;规模与高度有何关系? – Codor

+0

我正在使用比例公式计算变量h(以及手机上地图大小的常数5厘米)角度大小公式(http://en.wikipedia.org/wiki/Forced_perspective)。我和一位朋友想出了下面提出的解决方案,它基本上用它来解决三角形的一条腿。如果您想证明我的解决方案,或者提供替代解决方案,我将非常感激。 – Alek

我将我的谷歌地图大小设置为5厘米,选择了一个缩放级别,然后重新找到该位置,在谷歌地球中获取眼睛高度级别(D值在角度大小公式http://en.wikipedia.org/wiki/Forced_perspective)。我能够通过首先在屏幕上将我的地图长度设置为5厘米,然后使用591657550.5/2 ^(等级-1)* 5厘米的等级方程来计算角度中的h值大小方程。知道这两个变量后,我能够计算当地图宽度为5cm(85.36222058)时谷歌地图显示图像的恒定角度。从这些信息我能够构建这种方法,计算眼睛高度以上,从缩放级别地图的相对精度

public float getAltitude(float mapzoom){ 
    //this equation is a transformation of the angular size equation solving for D. See: http://en.wikipedia.org/wiki/Forced_perspective 
    float googleearthaltitude; 
    float firstPartOfEq= (float)(.05 * ((591657550.5/(Math.pow(2,(mapzoom-1))))/2));//amount displayed is .05 meters and map scale =591657550.5/(Math.pow(2,(mapzoom-1)))) 
    //this bit^essentially gets the h value in the angular size eq then divides it by 2 
    googleearthaltitude =(firstPartOfEq) * ((float) (Math.cos(Math.toRadians(85.362/2)))/(float) (Math.sin(Math.toRadians(85.362/2))));//85.362 is angle which google maps displays on a 5cm wide screen 
    return googleearthaltitude; 
} 

很抱歉,如果我的解释是解释不清。如果你们想使用这种方法,随时可以。对不起,措辞不佳。

我已经基本上将Javascript代码转换为Java。我希望这可以工作。

public int convertRangeToZoom(double range) { 
    //see: google.maps.v3.all.debug.js 
    int zoom = (int) Math.round(Math.log(35200000/range)/Math.log(2)); 
    if (zoom < 0) zoom = 0; 
    else if (zoom > 19) zoom = 19; 
    return zoom; 
} 

public int convertZoomToRange(double zoom){ 
    //see: google.maps.v3.all.debug.js 
    int range = (int) 35200000/(Math.pow(2, zoom)); 
    if (range < 300) range = 300; 
    return range; 
} 

https://groups.google.com/forum/#!msg/google-earth-browser-plugin/eSL9GlAkWBk/T4mdToJz_FgJ