Commit 69c5b272 authored by antirez's avatar antirez
Browse files

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.
parent 083acbeb
...@@ -121,17 +121,17 @@ int longLatFromMember(robj *zobj, robj *member, double *xy) { ...@@ -121,17 +121,17 @@ int longLatFromMember(robj *zobj, robj *member, double *xy) {
double extractUnitOrReply(redisClient *c, robj *unit) { double extractUnitOrReply(redisClient *c, robj *unit) {
char *u = unit->ptr; char *u = unit->ptr;
if (!strcmp(u, "m") || !strncmp(u, "meter", 5)) { if (!strcmp(u, "m")) {
return 1; 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; return 0.3048;
} else if (!strcmp(u, "mi") || !strncmp(u, "mile", 4)) { } else if (!strcmp(u, "mi")) {
return 1609.34; return 1609.34;
} else if (!strcmp(u, "km") || !strncmp(u, "kilometer", 9)) {
return 1000;
} else { } else {
addReplyError(c, "unsupported unit provided. please use meters (m), " addReplyError(c,
"kilometers (km), miles (mi), or feet (ft)"); "unsupported unit provided. please use m, km, ft, mi");
return -1; return -1;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment