简体   繁体   English

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

[英]Calculate height above map given zoom level in google maps

I am trying to calculate the height above map (ignoring topography) given a zoom level.我正在尝试在给定缩放级别的情况下计算地图上方的高度(忽略地形)。 I know the equation for scale at a specific zoom level is 591657550.5/2^(level-1) ( https://gis.stackexchange.com/questions/7430/google-maps-zoom-level-ratio ), but I am unsure on how to use this information (or whether or not this is the right information) to solve for height above map.我知道特定缩放级别的比例公式是 591657550.5/2^(level-1) ( https://gis.stackexchange.com/questions/7430/google-maps-zoom-level-ratio ),但我是不确定如何使用此信息(或这是否是正确的信息)来解决地图上方的高度。 Any help is appreciated.任何帮助表示赞赏。

I set my google map size to 5cm selected a zoom level, and then re-found that location with that zoom in google earth to get a eye altitude level (the D value in the angular size equation http://en.wikipedia.org/wiki/Forced_perspective ).我将我的谷歌地图大小设置为 5cm 选择了一个缩放级别,然后在谷歌地球中使用该缩放重新找到该位置以获得眼睛高度级别(角度大小方程中的 D 值http://en.wikipedia.org /wiki/Forced_perspective )。 I was able to find the h value in the angular size equation by first setting my map length on screen to 5cm, and then using the scale equation of 591657550.5/2^(level-1) *5cm to calculate the h value in the angular size equation.我能够通过首先将屏幕上的地图长度设置为 5cm,然后使用比例方程 591657550.5/2^(level-1) *5cm 来计算角度大小方程中的 h 值大小方程。 Knowing these two variables I was able to calculate the constant angle for which google maps displayed images when maps was at a 5cm width (85.36222058).知道这两个变量后,我能够计算出当地图宽度为 5 厘米 (85.36222058) 时,谷歌地图显示图像的恒定角度。 From these pieces of information I was able to construct this method which calculates eye altitude above map from zoom level with relative accuracy根据这些信息,我能够构建这种方法,该方法以相对精度从缩放级别计算地图上方的眼睛高度

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;
}

Sorry if my explanation is poorly explained.对不起,如果我的解释解释得不好。 If you guys want to use this method feel free to.如果你们想使用这种方法,请随意。 Sorry for any poorly worded sentences.对不起,任何措辞不当的句子。

I have basically converted Javascript code to Java.我基本上已将 Javascript 代码转换为 Java。 I hope this works.我希望这有效。

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 https://groups.google.com/forum/#!msg/google-earth-browser-plugin/eSL9GlAKWBk/T4mdToJz_FgJ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM