diff options
author | antirez <antirez@gmail.com> | 2015-06-29 16:02:33 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-06-29 16:02:33 +0200 |
commit | 69c5b27273272c93822a5d2bd776ddc11210e88a (patch) | |
tree | c2800a283959bf6885d20de63cc11808ef662293 /src | |
parent | 083acbebc85191314840a02a8618f051f49d0319 (diff) | |
download | redis-69c5b27273272c93822a5d2bd776ddc11210e88a.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/geo.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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)) { + } else if (!strcmp(u, "km")) { + return 1000; + } else if (!strcmp(u, "ft")) { return 0.3048; - } else if (!strcmp(u, "mi") || !strncmp(u, "mile", 4)) { + } else if (!strcmp(u, "mi")) { return 1609.34; - } else if (!strcmp(u, "km") || !strncmp(u, "kilometer", 9)) { - return 1000; } 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; } } |