android - X,Y 图像坐标旋转到纬度和经度

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

好的,我有这些来自 Google 地球的图像叠加数据,如下所示:

North: -7.340917
South: -7.34100
East: 112.751217
West: 112.751167
Rotation: 25.0000

并且我已经使用这些函数成功地将我的图像点 (x,y) 转换为 Lat、Lng:

static Double DEGREES_PER_RADIAN = 180 / Math.PI;
static Double RADIAN_PER_DEGREES = Math.PI / 180;

public static double Gudermannian(double y)
{
    return Math.atan(Math.sinh(y)) * DEGREES_PER_RADIAN;
}

public static double GudermannianInv(double latitude)
{
    double sign = Math.signum(latitude);
    double sin = Math.sin(latitude * RADIAN_PER_DEGREES * sign);
    return sign * (Math.log((1.0 + sin) / (1.0 - sin)) / 2.0);
}

Double mapLatNorth = -7.340917;
Double mapLatSouth = -7.34100;
Double mapLonWest = 112.751167;
Double mapLonEast = 112.751217;

Double ymax = GudermannianInv(mapLatNorth);
Double ymin = GudermannianInv(mapLatSouth);                 
Float latPoint = (float) Gudermannian(ymax - ( ((double) pointY / imgHeight) * (ymax - ymin) )) ;

Double mapLonDelta = mapLonEast - mapLonWest;
Float lngPoint = (float) (mapLonWest + pointX / imgWidth * mapLonDelta);

我从中得到的值

latPoint

lngPoint

是正确的,但是它还没有旋转。 我的问题是:如何将这些 Lat/Lng 值旋转 25 度?

我未能从 Ewan Todd 在 Calculate lat/lng of corners of ground overlay from kml-file 的回答中获得纬度/经度值

最佳答案

这应该可以通过简单的 2D 旋转来实现,应该是这样的:

public Float rotateLatitudeAround(Float lat, double angle, Point center) {
    lat = center.lat + (Math.cos(Math.toRadians(angle)) * (lat - center.lat) - Math.sin(Math.toRadians(angle)) * (lon - center.lon));
    return lat;
}

public Float rotateLongitudeAround(Float lon, double angle, Point center) {
    lon = center.lon + (Math.sin(Math.toRadians(angle)) * (lat - center.lat) + Math.cos(Math.toRadians(angle)) * (lon - center.lon));
    return lon;
}

但改变

center.lat 

center.getLatitudeE6()/1E6 

什么的。

编辑:我忘记了这只适用于 x,y 点。但是您可以先获取与 map 投影中心相关的经纬度点,然后再从投影反转 map 中返回经纬度值吗?

关于android - X,Y 图像坐标旋转到纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18552841/

相关文章:

javascript - Google 行车路线至最近的道路

java - 在 OSMDroid for Android 中旋转标记?

javascript - ES2015 - 集合、映射和数组问题

arrays - 按键对映射/结构进行分组,并对数组的关联值求和

java - ANDROID 两指滑动即可启动应用程序

android - 通过复选框激活android中的停用音乐

安卓数字输入加减号

java - 如何转义 Java 中的撇号?

python - 用于通过邮政编码在美国 map 上绘制点的良好 Python 库

javascript - 访问 Google map 事件中的 Backbone.View 功能