Search code examples
javadictionarymappinggismap-projections

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 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

Solution

  • 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.