简单的地图投影
我有一张 400x400 的地图,大约代表 250x250km 的区域,因为我想以纬度/经度的形式投影 GPS 坐标。
考虑到精度不是很重要(几公里的误差是可以容忍的),有什么简单的公式或算法可以进行投影并转换为像素坐标吗?如果有的话,我会遇到什么错误? 或者我真的错了,没有简单的方法来达到我需要的精度?
注意:
- 我读过有关 PROJ.4 的内容,但我宁愿不使用任何外部库,因为该程序必须在小型设备中运行
- 我在地图上没有任何校准数据,但我可以使用在线地图自行校准。
- 从这里我记录了我知道如何将纬度/经度转换为 x/y/z 坐标。但我不知道如何用 Z 拨号
I've a map of 400x400 that approximatively represents an area of 250x250km in that I want to project a GPS coordinate in form of Lat/Lon.
Taking in account that precision is not very important(errors of some km are tolerable) there is any easy formula or algorithm to make the projection and translate to a pixel coordinate? If there is one, what error can I expect?
Or I'm really wrong and there not easy way for the precision that I need?
Notes:
- I readed about PROJ.4 but I prefer to don't use any external library because the program has to run in small devices
- I haven't any calibration data on the map but I can calibrate it myself using an online map.
- From here I documented a little and I know how to convert the lat/lon to x/y/z coordinates. But I don't know how to dial with the Z
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,这是使用 转换矩阵 和使用 墨卡托投影。
这是开始。
虽然它不是 java,但有一个名为 OpenHeatMap 的开源项目,它在其源代码中执行此操作。这可能是一个值得一看的好地方(特别是 maprender/src/maprender.mxml 中的 setLatLonViewingArea、setLatLonToXYMatrix、mercatorLatitudeToLatitude)。
希望这有帮助!
Usually, this is done using a transformation matrix and using a Mercarator projection.
Here is a good place to start.
Although it isn't java, there is an open source project called OpenHeatMap which does this within its source code. This might be a good place to look (specifically the setLatLonViewingArea, setLatLonToXYMatrix, mercatorLatitudeToLatitude in maprender/src/maprender.mxml).
Hope this helps!
GIS人员可能会为此向我扔石头,但假设你不是高纬度地区,你可以计算出地图对角的纬度/经度来获取边界框,选择一个角作为你的原点,以GPS 坐标与原点之间的差异,然后进行简单的乘法将其缩放为像素,然后绘制该点。
我过去曾在我正在玩的地图程序中使用过它,并且我大约位于北纬 39 度线处。如果它不必非常准确,也不必太靠近杆子(不过,对于 250 公里的正方形,你必须靠近杆子才会发生严重错误),这将是最快且最有效的。最简单的。
The GIS people will probably stone me for this, but assuming you're not a a high latitude, you could just figure out the lat/lon of diagonal corners of your map to get the bounding box, pick a corner as your origin, take the difference between your GPS coordinate and the origin, then a simple multiplication to scale that to pixels, then draw the point.
I've used this in the past for a map program I was playing with, and I'm at about the 39th parallel. If it doesn't have to be dead accurate, and not too close to a pole (Though, for a 250km square, you'd have to be close to a pole for gross errors to happen), this would be the quickest and the easiest.