I want to calculate the distance between two points. I have the latitude and longitude of each of the points as a string formatted as DDDMMmmm (i.e. degrees, minutes and decimal fractions of minutes).
Step one is to convert the latitude and longitude from a string into a decimal number of degrees.
Step two is to calculate the distance between the two points using one of the various mathematical formula easily available on the net. (this one cribbed from http://williams.best.vwh.net/avform.htm#Dist)
The great circle distance d between two points with coordinates {lat1,lon1} and {lat2,lon2} is given by:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
Before I even start on this I'm not sure if it's going to be possible with any reasonable degree of accuracy. I need to be able to convert my string Latitude and Longitude into a number. The best data type for this seems to be float, but on the arduino reference pages I've found the following....
Floats have only 6-7 decimal digits of precision. That means the total number of digits, not the number to the right of the decimal point.
I really need to have lat and long as degrees with at least six decimal places. It seems that a float isn't going to manage this, is this correct?
If I can't get my lat and long accurately converted to a decimal, then the formula quoted above definitely isn't give me an accurate distance. There's a few functions for calculating the distance between two points on this forum, but they all use floats, I guess none of these can be very accurate? I'd like to be able get the distance correct to within a few 10s of meters.
Any suggestions? I had wondered about splitting the lat and long into degrees (as an integer) and minutes (as a float),this should give me the required accuracy, but then I've got to somehow work out the distance the two points using a lot more variables