40 #define LL_TOLERANCE 10 42 static int scan_ll(
const char *,
const char *,
double *,
int);
43 static int check_minutes(
const char *);
44 static int check_seconds(
const char *);
60 sprintf(tbuf,
"%se", buf);
61 return scan_ll(tbuf,
"we", res, 0);
65 static int scan_ll(
const char *buf,
const char *dir,
double *result,
int max)
74 sprintf(tbuf,
"%s%c", buf,
MARKER);
77 if (sscanf(buf,
"%d:%d:%d.%[0123456789]%[^\n]", &d, &m, &s, ps, h) == 5) {
80 for (pps = ps; *pps; pps++) {
81 p += (*pps -
'0') * f;
85 else if (sscanf(buf,
"%d:%d:%d%[^\n]", &d, &m, &s, h) == 4) {
88 else if (sscanf(buf,
"%d:%d.%[0123456789]%[^\n]", &d, &m, ps, h) == 4) {
92 for (pps = ps; *pps; pps++) {
93 pm += (*pps -
'0') * f;
97 else if (sscanf(buf,
"%d:%d%[^\n]", &d, &m, h) == 3) {
101 else if (sscanf(buf,
"%d%[^\n]", &d, h) == 2) {
110 if (m < 0 || m >= 60)
112 if (s < 0 || s >= 60)
118 if (d == max && (m > 0 || s > 0 || p > 0.0))
122 if (m && !check_minutes(buf))
124 if (s && !check_seconds(buf))
127 *result = d + (m + pm) / 60.0 + (s + p) / 3600.0;
131 if (*result == 0.0 && *h ==
MARKER)
134 if (*h >=
'A' && *h <=
'Z')
137 if (*h != dir[0] && *h != dir[1])
143 if (*h == dir[0] && *result != 0.0)
144 *result = -(*result);
149 static int check_minutes(
const char *buf)
158 if (*buf < '0' || *buf >
'9')
161 if (*buf < '0' || *buf >
'9')
164 return (*buf < '0' || *buf >
'9');
167 static int check_seconds(
const char *buf)
181 if (*buf < '0' || *buf >
'9')
184 if (*buf < '0' || *buf >
'9')
187 return (*buf < '0' || *buf >
'9');
void G_strip(char *)
Removes all leading and trailing white space from string.
int G_lat_scan(const char *buf, double *lat)
int G_llres_scan(const char *buf, double *res)
int G_lon_scan(const char *buf, double *lon)