summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-06-29 16:02:33 +0200
committerantirez <antirez@gmail.com>2015-06-29 16:02:33 +0200
commit69c5b27273272c93822a5d2bd776ddc11210e88a (patch)
treec2800a283959bf6885d20de63cc11808ef662293 /src
parent083acbebc85191314840a02a8618f051f49d0319 (diff)
downloadredis-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.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/geo.c b/src/geo.c
index 364f0d829..91cfb15a4 100644
--- a/src/geo.c
+++ b/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)) {
+ } 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;
}
}