mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Geo: support units only in abbreviated form.
I'm not a strong believer in multiple syntax for the same stuff, so now units can be specified only as m, km, ft, mi.
This commit is contained in:
parent
083acbebc8
commit
69c5b27273
16
src/geo.c
16
src/geo.c
@ -121,17 +121,17 @@ int longLatFromMember(robj *zobj, robj *member, double *xy) {
|
||||
double extractUnitOrReply(redisClient *c, robj *unit) {
|
||||
char *u = unit->ptr;
|
||||
|
||||
if (!strcmp(u, "m") || !strncmp(u, "meter", 5)) {
|
||||
if (!strcmp(u, "m")) {
|
||||
return 1;
|
||||
} else if (!strcmp(u, "ft") || !strncmp(u, "feet", 4)) {
|
||||
return 0.3048;
|
||||
} else if (!strcmp(u, "mi") || !strncmp(u, "mile", 4)) {
|
||||
return 1609.34;
|
||||
} else if (!strcmp(u, "km") || !strncmp(u, "kilometer", 9)) {
|
||||
} else if (!strcmp(u, "km")) {
|
||||
return 1000;
|
||||
} else if (!strcmp(u, "ft")) {
|
||||
return 0.3048;
|
||||
} else if (!strcmp(u, "mi")) {
|
||||
return 1609.34;
|
||||
} else {
|
||||
addReplyError(c, "unsupported unit provided. please use meters (m), "
|
||||
"kilometers (km), miles (mi), or feet (ft)");
|
||||
addReplyError(c,
|
||||
"unsupported unit provided. please use m, km, ft, mi");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user