开发者

Simple map projection

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开发者_如何学C 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


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜