39 #define LL_TOLERANCE 10
41 static int scan_ll(
const char *,
const char *,
double *,
int);
42 static int check_minutes(
const char *);
43 static int check_seconds(
const char *);
59 sprintf(tbuf,
"%se", buf);
60 return scan_ll(tbuf,
"we", res, 0);
64 static int scan_ll(
const char *buf,
const char *dir,
double *result,
int max)
73 sprintf(tbuf,
"%s%c", buf,
MARKER);
76 if (sscanf(buf,
"%d:%d:%d.%[0123456789]%[^\n]", &d, &m, &s,
ps, h) == 5) {
79 for (pps =
ps; *pps; pps++) {
80 p += (*pps -
'0') * f;
84 else if (sscanf(buf,
"%d:%d:%d%[^\n]", &d, &m, &s, h) == 4) {
87 else if (sscanf(buf,
"%d:%d.%[0123456789]%[^\n]", &d, &m,
ps, h) == 4) {
91 for (pps =
ps; *pps; pps++) {
92 pm += (*pps -
'0') * f;
96 else if (sscanf(buf,
"%d:%d%[^\n]", &d, &m, h) == 3) {
100 else if (sscanf(buf,
"%d%[^\n]", &d, h) == 2) {
109 if (m < 0 || m >= 60)
111 if (s < 0 || s >= 60)
117 if (d ==
max && (m > 0 || s > 0 || p > 0.0))
121 if (m && !check_minutes(buf))
123 if (s && !check_seconds(buf))
126 *result = d + (m + pm) / 60.0 + (s + p) / 3600.0;
130 if (*result == 0.0 && *h ==
MARKER)
133 if (*h >=
'A' && *h <=
'Z')
136 if (*h != dir[0] && *h != dir[1])
142 if (*h == dir[0] && *result != 0.0)
143 *result = -(*result);
148 static int check_minutes(
const char *buf)
157 if (*buf < '0' || *buf >
'9')
160 if (*buf < '0' || *buf >
'9')
163 return (*buf < '0' || *buf >
'9');
166 static int check_seconds(
const char *buf)
180 if (*buf < '0' || *buf >
'9')
183 if (*buf < '0' || *buf >
'9')
186 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_lon_scan(const char *buf, double *lon)
int G_llres_scan(const char *buf, double *res)