38 #include <grass/gis.h>
40 static int scan_ll(
const char *,
const char *,
double *,
int);
41 static int check_minutes(
const char *);
42 static int check_seconds(
const char *);
46 return scan_ll(buf,
"sn", lat, 90);
51 return scan_ll(buf,
"we", lon, 180);
59 return scan_ll(tbuf,
"we", res, 0);
63 static int scan_ll(
const char *
buf,
const char *dir,
double *result,
int max)
75 if (sscanf(buf,
"%d:%d:%d.%[0123456789]%[^\n]", &d, &m, &s, ps, h) == 5) {
78 for (pps = ps; *pps; pps++) {
79 p += (*pps -
'0') * f;
83 else if (sscanf(buf,
"%d:%d:%d%[^\n]", &d, &m, &s, h) == 4) {
86 else if (sscanf(buf,
"%d:%d.%[0123456789]%[^\n]", &d, &m, ps, h) == 4) {
90 for (pps = ps; *pps; pps++) {
91 pm += (*pps -
'0') * f;
95 else if (sscanf(buf,
"%d:%d%[^\n]", &d, &m, h) == 3) {
99 else if (sscanf(buf,
"%d%[^\n]", &d, h) == 2) {
108 if (m < 0 || m >= 60)
110 if (s < 0 || s >= 60)
116 if (d == max && (m > 0 || s > 0 || p > 0.0))
120 if (m && !check_minutes(buf))
122 if (s && !check_seconds(buf))
125 *result = d + (m + pm) / 60.0 + (s + p) / 3600.0;
129 if (*result == 0.0 && *h ==
MARKER)
132 if (*h >=
'A' && *h <=
'Z')
135 if (*h != dir[0] && *h != dir[1])
141 if (*h == dir[0] && *result != 0.0)
142 *result = -(*result);
147 static int check_minutes(
const char *
buf)
156 if (*buf < '0' || *buf >
'9')
159 if (*buf < '0' || *buf >
'9')
162 return (*buf < '0' || *buf >
'9');
165 static int check_seconds(
const char *buf)
179 if (*buf < '0' || *buf >
'9')
182 if (*buf < '0' || *buf >
'9')
185 return (*buf < '0' || *buf >
'9');
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G_lat_scan(const char *buf, double *lat)
int G_strip(char *buf)
Removes all leading and trailing white space from string.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int G_llres_scan(const char *buf, double *res)
tuple h
panel.defaultSize = wx.CheckBox(panel, id = wx.ID_ANY, label = _("Use default size")) panel...
int G_lon_scan(const char *buf, double *lon)