GEOPOS key ele1 ele2 ... eleN * * Returns an array of two-items arrays representing the x,y position of each * element specified in the arguments. For missing elements NULL is returned. */
| 931 | * Returns an array of two-items arrays representing the x,y position of each |
| 932 | * element specified in the arguments. For missing elements NULL is returned. */ |
| 933 | void geoposCommand(client *c) { |
| 934 | int j; |
| 935 | |
| 936 | /* Look up the requested zset */ |
| 937 | robj_roptr zobj = lookupKeyRead(c->db, c->argv[1]); |
| 938 | if (checkType(c, zobj, OBJ_ZSET)) return; |
| 939 | |
| 940 | /* Report elements one after the other, using a null bulk reply for |
| 941 | * missing elements. */ |
| 942 | addReplyArrayLen(c,c->argc-2); |
| 943 | for (j = 2; j < c->argc; j++) { |
| 944 | double score; |
| 945 | if (!zobj || zsetScore(zobj, szFromObj(c->argv[j]), &score) == C_ERR) { |
| 946 | addReplyNullArray(c); |
| 947 | } else { |
| 948 | /* Decode... */ |
| 949 | double xy[2]; |
| 950 | if (!decodeGeohash(score,xy)) { |
| 951 | addReplyNullArray(c); |
| 952 | continue; |
| 953 | } |
| 954 | addReplyArrayLen(c,2); |
| 955 | addReplyHumanLongDouble(c,xy[0]); |
| 956 | addReplyHumanLongDouble(c,xy[1]); |
| 957 | } |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | /* GEODIST key ele1 ele2 [unit] |
| 962 | * |
nothing calls this directly
no test coverage detected