I am trying to figure out how to plot WGS84 latitude/longitude points on a bitmap but cannot figure out the math required to turn lat/lon points into coordinates that would be plottable. Could anyone give me some pointers or examples on how to do this?
thanks开发者_如何学C
Colin
Turning latitude longitude into x, y for plotting on a flat 2d surface like a bitmap is a large and complicated topic.
For general information about this see map Projections on wikipedia.
In general websites like google maps and bing solve this problem by using a mercator projection on a perfect sphere which can easily cover most of the earth (except the north/south pole) and be 'good enough' for most purposes. However, those are some big ifs and it really depends on how accurate your pictures need to be and what they need to preserve.
Unfortunately I don't know delpi well enough to provide source code but the math for mercator projections is well documented here.
If accuracy is not an issue at all and your points are 'close together', the simplest method would be to simply use a constant factor and offset to shift latitude/longitude into x and y values that fit onto your bitmap.
This might make a slightly squish your pictures in the north/south direction but in general will produce pictures much like mercator without the natural logarithms and sin/tangent calls.
You might have a look at the Mercator Projection Demo, with Delphi source code:
http://delphiforfun.org/programs/MercatorDemo.htm
As already mentioned by MerickOWA, there is no right answer to the question as it depends on the scale you are working at, and the accuracy you require. This will largely be determined by what is on the .bmp you are discussing. If it is a global map in Mercator projection, then Greg's answer will give you some pointers. If it is a local map, then it will depend on the datum the map is using, and the projection used (and the datum will largely be determined by the national authority of the country in question). Having said all that, if what you want to do is just project a GPS provided Lat Lon (GS84 datum) onto a local map covering an area < 6° of Latitude, then you could do worse than projecting the WGS84 Lat Lon to a WGS84 UTM projection, then scaling (and possibly)rotating the map to fit at 2 known coordinates.
The link here should give some help http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm
Did you try The World Coordinate Converter: http://twcc.free.fr ?
精彩评论