【问题标题】:Calculate height above map given zoom level in google maps在谷歌地图中给定缩放级别计算地图上方的高度
【发布时间】:2014-03-30 21:54:21
【问题描述】:

在给定缩放级别的情况下,我正在尝试计算地图上方的高度(忽略地形)。我知道特定缩放级别的比例方程是 591657550.5/2^(level-1) (https://gis.stackexchange.com/questions/7430/google-maps-zoom-level-ratio),但我不确定如何使用这些信息(或者这是否是正确的信息)来解决地图上方的高度。任何帮助表示赞赏。

【问题讨论】:

  • 这个问题(从数学上讲)有点不明确;比例与高度有何关系?
  • 我正在使用比例方程来计算变量 h(以及我手机上地图尺寸的常数 5cm)角度尺寸方程 (en.wikipedia.org/wiki/Forced_perspective)。我和一个朋友想出了下面介绍的解决方案,它基本上使用它来解决三角形的一条腿。如果您能对我的解决方案进行校对或提供替代解决方案,我将不胜感激。

标签: java android google-maps math google-maps-api-2


【解决方案1】:

我将我的谷歌地图大小设置为 5 厘米,选择了一个缩放级别,然后在谷歌地球中重新找到该缩放位置以获得眼睛高度级别(角度大小等式 http://en.wikipedia.org/wiki/Forced_perspective 中的 D 值)。我能够通过首先将屏幕上的地图长度设置为 5cm,然后使用 591657550.5/2^(level-1) *5cm 的比例方程来计算角度中的 h 值,从而在角度大小方程中找到 h 值尺寸方程。知道这两个变量后,我能够计算出当地图宽度为 5 厘米(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;
}

对不起,如果我的解释解释得不好。如果你们想使用这种方法,请随意。抱歉,任何措辞不佳的句子。

【讨论】:

    【解决方案2】:

    我基本上已经将 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

    【讨论】:

      猜你喜欢
      • 2012-09-08
      • 2011-09-29
      • 2017-02-23
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多