aboutsummaryrefslogtreecommitdiffstats
path: root/common-address.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common-address.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/common-address.c b/common-address.c
index 8ad8712..2f66208 100644
--- a/common-address.c
+++ b/common-address.c
@@ -3,7 +3,7 @@
int
-parse_coord(char *s, double *lat_min, double *lat_max, double *lon_min, double *lon_max)
+parse_coord(char *s, double *lat, double *lat_min, double *lat_max, double *lon, double *lon_min, double *lon_max)
{
int withsign = 0, neg;
long int tmp;
@@ -12,6 +12,7 @@ parse_coord(char *s, double *lat_min, double *lat_max, double *lon_min, double *
errno = 0;
if (s[0] == ':') {
+ *lat = 0;
*lat_min = -90;
*lat_max = +90;
} else {
@@ -25,24 +26,24 @@ parse_coord(char *s, double *lat_min, double *lat_max, double *lon_min, double *
if (errno || tmp > INT_MAX)
return -1;
}
- *lat_min = (double)tmp;
+ *lat = (double)tmp;
if (s[0] == '.') {
for (s++; isdigit(*s); s++) {
- *lat_min *= 10;
- *lat_min += (double)(*s & 15);
+ *lat *= 10;
+ *lat += (double)(*s & 15);
prec *= 10;
}
- *lat_min /= prec;
+ *lat /= prec;
}
if (!withsign && (s[0] == 'N' || s[0] == 'S')) {
neg = s[0] == 'S';
s = &s[1];
}
if (neg)
- *lat_min = -*lat_min;
+ *lat = -*lat;
prec = (1 / prec) / 2;
- *lat_max = *lat_min + prec;
- *lat_min -= prec;
+ *lat_min = *lat - prec;
+ *lat_max = *lat + prec;
if (s[0] != ':')
return -1;
}
@@ -50,6 +51,7 @@ parse_coord(char *s, double *lat_min, double *lat_max, double *lon_min, double *
s = &s[1];
if (!s[0]) {
+ *lon = 0;
*lon_min = -180;
*lon_max = +180;
} else {
@@ -63,24 +65,24 @@ parse_coord(char *s, double *lat_min, double *lat_max, double *lon_min, double *
if (errno || tmp > INT_MAX)
return -1;
}
- *lon_min = (double)tmp;
+ *lon = (double)tmp;
if (s[0] == '.') {
for (s++; isdigit(*s); s++) {
- *lon_min *= 10;
- *lon_min += (double)(*s & 15);
+ *lon *= 10;
+ *lon += (double)(*s & 15);
prec *= 10;
}
- *lon_min /= prec;
+ *lon /= prec;
}
if (!withsign && (s[0] == 'E' || s[0] == 'W')) {
neg = s[0] == 'W';
s = &s[1];
}
if (neg)
- *lon_min = -*lon_min;
+ *lon = -*lon;
prec = (1 / prec) / 2;
- *lon_max = *lon_min + prec;
- *lon_min -= prec;
+ *lon_min = *lon - prec;
+ *lon_max = *lon + prec;
if (s[0])
return -1;
}