algorithm - 将国家坐标映射到暂停的屏幕像素
问题描述
我有拉脱维亚三个城市的坐标
57.4093885,21.5246563
56.9713962,23.9890814
55.8958226,26.4671762
我需要把它们放在我的拉脱维亚地图上。我无法理解算法,因为它放在我的地图上。我可以使用什么算法将纬度和经度转换为地图上的点。
解决方案
对于 Merkator,投影映射相当简单。
地图有边界坐标 - LatMin, LonMin, Lattin, LonMax
。它对应于坐标为 0、0、Width、Height 的屏幕矩形。
经度有线性映射
X = Width * (Lon - LonMin) / (LonMax- LonMin)
纬度应该用一些数学计算:
a = 6378137 //geo-ellipsoid parameters
b = 6356752.31
f=(a-b)/a
e=sqrt(2*f-f^2) //excentricitet
YY = a * ln(Tan(pi / 4 + Lat / 2) *
((1 - e * sin(Lat)) / (1 + e * sin(Lat)))**(e/2));
更简单,不太精确的版本:
YY = a * ln(Tan(pi / 4 + Lat / 2))
为 LatMin、LatMax、城市纬度 Lat 查找 YY,并应用类似的线性插值
Y = Height * (YY_Lat - YY_LonMin) / (YY_LonMax- YY_LonMin)
推荐阅读
- firebase - 为什么我从 firebase 提取的数据来自 null?
- c# - 如何在 XElement (XML Serializer) 中添加 if 条件
- r - 使用 ggplot2 绘制线图时,我得到了两个图例
- r - 访问要在 dplyr::mutate 中使用的函数中的列名
- python - Scrapy 无法使用 Xpath 检索属性值
- excel - 用于自动刷新数据透视表的宏
- python - IndexError:位置参数元组的替换索引 2 超出范围
- ios - 自由驾驶模式 - Mapbox
- html - 具有可变默认值的复选框
- ocaml - 如何解决这个 Ocaml 字典问题?