在c++中将长坐标转换为Y坐标
Convert lat long to X Y coordinates C++
我有一个充满Lat Long坐标的向量,格式为
82.0000000, -180.0000000
我正试图将它们转换为X和Y坐标,以使用此代码将它们绘制成地图,据我所知,这是正确的…
X:double testClass::getX(double lon)
{
// Convert long to X coordinate (2043 = map width)
double x = lon;
// Scale
x = x * 2043.0 / 360.0;
// Center
x += 2043.0/2.0;
return x;
}
Y: double testClass::getY(double lat)
{
// Convert lat to Y coordinate (1730 = map height)
double y = -1 * lat;
// Scale
y = y * 1730.0 / 180.0;
// Center
y += 1730.0/2.0;
return y;
}
然而,当绘制在我的地图上时,我可以看到这些点确实像一个世界地图,但它们都偏离了x量,我认为这与我的缩放有关
任何想法?
我找到答案了
double testClass::getX(double lon, int width)
{
// width is map width
double x = fmod((width*(180+lon)/360), (width +(width/2)));
return x;
}
double testClass::getY(double lat, int height, int width)
{
// height and width are map height and width
double PI = 3.14159265359;
double latRad = lat*PI/180;
// get y value
double mercN = log(tan((PI/4)+(latRad/2)));
double y = (height/2)-(width*mercN/(2*PI));
return y;
}
所以当使用墨卡托地图
相关文章:
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 在 OpenGL 中将笛卡尔世界坐标转换为球面局部坐标
- 如何将鼠标坐标转换为"mm"
- 如何将 QTabWidget 坐标转换为其子坐标?
- 将 2D 图像坐标转换为 z = 0 的 3D 世界坐标
- 如何将世界坐标转换为相机图像坐标
- 将鼠标坐标转换为世界空间坐标
- 将画布坐标转换为外部微件的坐标
- 将 2D 屏幕坐标转换为 3D 世界坐标
- 如何将像素坐标转换为世界坐标
- 如何从 GLUT 坐标转换为窗口坐标
- 将点云的坐标转换为点云库中的另一个坐标,从而使地平面成为X-O-Y平面?
- 将 X Y 坐标转换为拉特长等距柱状投影C++
- 将 3D 坐标转换为 3ds 中的 2D 最大值
- 将屏幕鼠标坐标转换为窗口坐标
- Opengl 屏幕到地图坐标转换
- 在 OpenGL 中将 3D 坐标转换为屏幕坐标
- 将双点坐标转换为字符串
- gluUnProject试图将鼠标坐标转换为opengl坐标的奇怪行为
- 从视口坐标转换为[-1,1]^2顶点[ENGGL]