- for (k=0; k<2; k++) {
- gchar fmt1[] = "N %d%*[ ]%lf W %d%*[ ]%lf";
- gchar fmt2[] = "%d%*[ ]%lf N %d%*[ ]%lf W";
- gchar fmt3[] = "N %lf W %lf";
- gchar fmt4[] = "%lf N %lf W";
-
- fmt1[0] = latc[j]; fmt1[13] = lonc[k];
- fmt2[11] = latc[j]; fmt2[24] = lonc[k];
- fmt3[0] = latc[j]; fmt3[6] = lonc[k];
- fmt4[4] = latc[j]; fmt4[10] = lonc[k];
-
- if (sscanf(cand, fmt1, &latdeg, &latm, &londeg, &lonm) == 4 ||
- sscanf(cand, fmt2, &latdeg, &latm, &londeg, &lonm) == 4) {
- lat = (j*2-1) * (latdeg + latm / 60);
- lon = (k*2-1) * (londeg + lonm / 60);
- break;
- }
- if (sscanf(cand, fmt3, &lat, &lon) == 2 ||
- sscanf(cand, fmt4, &lat, &lon) == 2) {
- lat *= (j*2-1);
- lon *= (k*2-1);
- break;
- }
- }
- if (k!=2) break;
+ for (k=0; k<2; k++) {
+ // DMM
+ gchar fmt1[] = "N %d%*[ ]%lf W %d%*[ ]%lf";
+ gchar fmt2[] = "%d%*[ ]%lf N %d%*[ ]%lf W";
+ // DDD
+ gchar fmt3[] = "N %lf W %lf";
+ gchar fmt4[] = "%lf N %lf W";
+ // DMS
+ gchar fmt5[] = "N%d%*[ ]%d%*[ ]%lf%*[ ]W%d%*[ ]%d%*[ ]%lf";
+
+ // Substitute in 'N','E','S' or 'W' values for each attempt
+ fmt1[0] = latc[j]; fmt1[13] = lonc[k];
+ fmt2[11] = latc[j]; fmt2[24] = lonc[k];
+ fmt3[0] = latc[j]; fmt3[6] = lonc[k];
+ fmt4[4] = latc[j]; fmt4[10] = lonc[k];
+ fmt5[0] = latc[j]; fmt5[23] = lonc[k];
+
+ if (sscanf(cand, fmt1, &latdeg, &latm, &londeg, &lonm) == 4 ||
+ sscanf(cand, fmt2, &latdeg, &latm, &londeg, &lonm) == 4) {
+ lat = (j*2-1) * (latdeg + latm / 60);
+ lon = (k*2-1) * (londeg + lonm / 60);
+ break;
+ }
+ if (sscanf(cand, fmt3, &lat, &lon) == 2 ||
+ sscanf(cand, fmt4, &lat, &lon) == 2) {
+ lat *= (j*2-1);
+ lon *= (k*2-1);
+ break;
+ }
+ gint am = sscanf(cand, fmt5, &latdeg, &latmi, &lats, &londeg, &lonmi, &lons);
+ if ( am == 6 ) {
+ lat = (j*2-1) * (latdeg + latmi / 60.0 + lats / 3600.0);
+ lon = (k*2-1) * (londeg + lonmi / 60.0 + lons / 3600.0);
+ break;
+ }
+ }
+ if (k!=2) break;