【问题标题】:How to convert lat lng to xy with custom center point in android如何在android中使用自定义中心点将lat lng转换为xy
【发布时间】:2015-03-27 01:25:51
【问题描述】:

我有一个谷歌地图。我在上面放置了一个 tileOverlay(一个虚构的游戏世界)。游戏使用 x,y 坐标系。我需要将我所有的 lat lng 坐标转换为这个精确的 x,y 系统。

我在地图上选择了两个点,并从游戏中获得了它们的真实 xy 值。 然后从 android 地图中得到这两个点的 lat lng。 然后使用此代码:

// First spot data
static Double game_1_x = 1972.606;
static Double game_1_y = 3817.044;
static Double map_1_lng = 42.108797;
static Double map_1_lat = 43.152977;

// second spot data
static Double game_2_x = -1154.11;
static Double game_2_y = -2715.203;
static Double map_2_lng = -48.3334;
static Double map_2_lat = -80.346344;

Double LAT = latFromMarker;
Double LON = lngFromMarker;

// this works
// all markers added with this equation fall on the correct longitude line
Double X = game_1_x + (LON - map_1_lng) * (game_1_x - game_2_x) / (map_1_lng - map_2_lng);

// this does not work
// markers added using this equation are always too far north or south of where they need to be
Double Y = game_1_y + (LAT - map_1_lat) * (game_1_y - game_2_y) / (map_1_lat - map_2_lat);

“y”转换无法正常工作的原因是由于 Google Maps API v2 墨卡托投影,纬度线的间距不相等。

我需要知道我需要做些什么来解释这种波动。我确信有一些高级方程式或其他东西,但我已经毫不费力地用谷歌搜索了几个小时,却空手而归。

【问题讨论】:

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


    【解决方案1】:

    我认为你必须做一些这样的数学......

    类似cos(alpha) *R=r...?

    不是真正的数学专业,也不擅长数学...... 所以你应该在math stack exchange中询问它

    =-=-=-=-=-=-= OR =-=-=-=-=-=-=

    因为你关心的其实是D:d

    您可以使用computeDistanceBetween(LatLngFrom, LatLngTo) 函数并通过比较具有相同lng 和不同纬度的两对两点之间的距离来找到D:d。 (说在 lng 0 和 lng 45 中 1 度纬度有多长)

    更多关于computeDistanceBetween的信息。

    【讨论】:

      猜你喜欢
      • 2017-09-06
      • 1970-01-01
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-12
      • 1970-01-01
      相关资源
      最近更新 更多