This question have been asked many times but i want the answer which i can use in a php application.
The closest answer i found was this
int x = (int) ((MAP_WIDTH/360.0) * (180 + lon));
int y = (int) ((MAP_HEIGHT/180.0) * (90 - lat));
I don’t need to show the map or something. I just need to calculate it.
What should be the MAP_WIDTH and MAP_HEIGTH if i use the above formula ?
There is no such thing as
xandycoordinates for the earth. At most, you could computex,yandz. Note that Euclidean distance then would travel through the earth surface.It should also be pretty obvious that any
x-ybased system will produce completely inaccurate results close to the poles and close to the date line…Keep the data as it is – in latitude, longitude (and height, if available) – and instead of computing Euclidean distance, use the great circle distance. Unless you have detailed information about the actual shape of the earth, the common great circle approximation with a sphere is the best you can do. And actually quite easy to use.
http://en.wikipedia.org/wiki/Great-circle_distance