Compute the sorted set scores min (inclusive), max (exclusive) we should * query in order to retrieve all the elements inside the specified area * 'hash'. The two scores are returned by reference in *min and *max. */
| 319 | * query in order to retrieve all the elements inside the specified area |
| 320 | * 'hash'. The two scores are returned by reference in *min and *max. */ |
| 321 | void scoresOfGeoHashBox(GeoHashBits hash, GeoHashFix52Bits *min, GeoHashFix52Bits *max) { |
| 322 | /* We want to compute the sorted set scores that will include all the |
| 323 | * elements inside the specified Geohash 'hash', which has as many |
| 324 | * bits as specified by hash.step * 2. |
| 325 | * |
| 326 | * So if step is, for example, 3, and the hash value in binary |
| 327 | * is 101010, since our score is 52 bits we want every element which |
| 328 | * is in binary: 101010????????????????????????????????????????????? |
| 329 | * Where ? can be 0 or 1. |
| 330 | * |
| 331 | * To get the min score we just use the initial hash value left |
| 332 | * shifted enough to get the 52 bit value. Later we increment the |
| 333 | * 6 bit prefis (see the hash.bits++ statement), and get the new |
| 334 | * prefix: 101011, which we align again to 52 bits to get the maximum |
| 335 | * value (which is excluded from the search). So we get everything |
| 336 | * between the two following scores (represented in binary): |
| 337 | * |
| 338 | * 1010100000000000000000000000000000000000000000000000 (included) |
| 339 | * and |
| 340 | * 1010110000000000000000000000000000000000000000000000 (excluded). |
| 341 | */ |
| 342 | *min = geohashAlign52Bits(hash); |
| 343 | hash.bits++; |
| 344 | *max = geohashAlign52Bits(hash); |
| 345 | } |
| 346 | |
| 347 | /* Obtain all members between the min/max of this geohash bounding box. |
| 348 | * Populate a geoArray of GeoPoints by calling geoGetPointsInRange(). |
no test coverage detected