Here's the code I developed:
double Str2LatLong(char* coord)
{
// char* testInput = "47,26'14\"";
int i = 0;
int parts[3] = {0}; // parts[0] is degrees, parts[1] is minutes, parts[2] is seconds
int* pCurr = parts;
do
{
if (coord[i] == '\0')
{
break;
}
if (!isdigit(coord[i]))
{
*pCurr++; // skip from parts[0] ==> [1], or [1] ==> [2]
continue;
}
*pCurr = 10* (*pCurr) + coord[i] - '0';
++i;
} while (1);
return parts[0] + ((double)parts[1])/60.0 + ((double)parts[2])/3600.0;
}
Because it is written for speed, there is NO input validation.
You must supply proper input, or it will mess up badly.
I kept everything to integer math, and sequential memory as best I could.
It doesn't check for "proper" delimiters. Rather, anytime something is not a digit, it assumes that is the transition from degrees to minutes, or minutes to seconds.
It is only at the very last line that it converts to double with some very simple floating point operations.
I suspect you'll want to modify it to handle positive/negative values and North/South, East/West indicators, and decimal places after the seconds. But I think this code is a good foundation for a really fast conversion routine.
I hope this will test out very fast. Please let me know how it goes.