GPS Coords to map (x,y) coords convertation


I have a problem.
I have a digital 2 dimensional map, I know this map 2d corners coordinates and this coordinates' GPS coordinates.
forexample :
   x,y                       longitude, latitude
  (0,0)                     (47,36'48 and 18,55'24)
  (map.width,0)       (47,28'52 and 18,55'28)
  (0,map.height)        (..... .....)
  (map.width,map.height) (... ...)
and so on...

How can I calibrate the longitude and the latitude If I get an another x,y points
like (20,20)  -----> (??? , ???)

I need a (delphi) procedure or function...
Who is Participating?
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
First of all, how are you storing coordinates values? a good form is in pure grades as a real number:

47g36'48" can be stored as: 47.613333 grades

Or you can store it as pure seconds (my prefered method because no loss of precision)

47g36'48" can be stored as: 171408 seconds

No matters how has you stored them (but need to be stored as a UNIQUE value) the conversion formula is:

lon' = x/mapW * (lonE-lonW) + lonW
lat' = y/mapH * (latS-latN) + latN


x,y        = map coordinates position (ex. 20,20)
mapW,MapH  = map width and height
latW,latN  = upper-left corner of your map, expressed in geodesic coordinates
lonE,latS  = lower-right corner of your map

assuming (very important):
W coordinates are negatives
N coordinates are negatives

wwwbetyarAuthor Commented:
It seems to be good ...
So I accept this answear, but I tried it only only map...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.