I am working on a geographic project in Java.
The input are coordinates : 24.4444 N etc
Output: a PLAIN map (not round) showing the point of the coordinates.
I don’t know the algorithm to transform from coordinates to x,y on a JComponent, can somebody help me?
The map looks like this:
http://upload.wikimedia.org/wikipedia/commons/7/74/Mercator-projection.jpg
Thank you
Given your sparse example, the range of your inputs will be (90.0N – 90.0S) and (180W – 180E). It is easiest – and standard – if you convert South and West to negatives giving you latitudes of (90.0..-90.0) and longitudes of (180.0..-180.0).
Given the size of your canvas – let’s say it is 140×120 pixels – you get:
or:
where I have ordered the operations to minimize rounding error. This assumes the canvas has point (0,0) in the upper-left or, if not, that you are Australian.
Added: you just threw in the bit about Mercator projections making my simple answer incorrect (but possibly still usable by you if you don’t actually care about projection)