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的回答中获得纬度/经度值
答案 0 :(得分:1)
这应该可以通过简单的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。但是你可以先获得与地图投影中心相关的lat,lon的点数,并在它返回lat之后,从投影反向地图中获取lon值?