just for the fun of it!
it's based btw on this code previously posted here.
void setup() {
char test_str[] = "$GPGGA,072651.00,3754.559774,S,14510.604956,E,1,06,0.8,107.9,M,3.0,M,,45";
int i = 0;
char *start_pch, *end_pch;
char extracted_str[16];
char temp_str[32];
char map_str[100] = "https://www.google.com/maps/place/";
float f_temp, latitude, longuitude;
int i_temp;
start_pch = test_str - 1;
Serial.begin(115200);
end_pch = strstr (test_str, ",");
while ( end_pch != NULL ) {
++i;
memset (extracted_str, 0, 16);
strncpy (extracted_str, start_pch + 1, end_pch - start_pch - 1);
if (i == 3) {
f_temp = atof(extracted_str);
i_temp = (int)f_temp;
f_temp = (f_temp - i_temp) * 60;
sprintf(temp_str, "%i°%i'%s\"", i_temp / 100, i_temp%100, String(f_temp, 1).c_str());
strcat(map_str, temp_str);
latitude = (atof(&extracted_str[2]) / 60) + (i_temp / 100);
}
else if (i == 4) {
strcat(map_str, extracted_str);
if (extracted_str[0] == 'S') latitude *= -1;
}
else if (i == 5) {
f_temp = atof(extracted_str);
i_temp = (int)f_temp;
f_temp = (f_temp - i_temp) * 60;
sprintf(temp_str, "%c%i°%i'%s\"", (i_temp > 0) ? '+' : '-', i_temp / 100, i_temp%100, String(f_temp, 1).c_str());
strcat(map_str, temp_str);
longuitude = (atof(&extracted_str[3]) / 60) + (i_temp / 100);
}
else if (i == 6) {
strcat(map_str, extracted_str);
if (extracted_str[0] == 'W') longuitude *= -1;
}
start_pch = end_pch;
end_pch = strstr (end_pch + 1, ",");
}
//retrieve (checksum)
memset (extracted_str, 0, 16);
strncpy (extracted_str, start_pch + 1, strlen(start_pch));
sprintf(temp_str, "/@%s,%s", String(latitude, 5).c_str(), String(longuitude, 5).c_str());
strcat(map_str, temp_str);
Serial.println(map_str);
}
void loop() {
// put your main code here, to run repeatedly:
}
https://www.google.com/maps/place/37°54'33.6"S+145°10'36.3"E/@-37.90933,145.17674