This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
RECT
Josh Baker edited this page Oct 11, 2016
·
8 revisions
Searches a spatial index for values that overlap the specified rectangle.
This operation is very fast because the values are stored in a R-tree.
- MATCH pattern - Limit results to keys that match the specified pattern
- LIMIT limit - Limit the number of results
- SKIP skip - Skip past the first specified number of results. Using SKIP and LIMIT allow for paging through a spatial index.
- h?llo matches hello, hallo and hxllo
- h*llo matches hllo and heeeello
Array reply: list of results.
Using BuntDB Rects:
> SETINDEX fleet fleet:*:pos SPATIAL
OK
> SET fleet:0:pos "[-115.567 33.532]"
OK
> SET fleet:1:pos "[-121.896 32.334]"
OK
> SET fleet:2:pos "[-116.671 35.735]"
OK
> SET fleet:3:pos "[-113.902 31.234]"
OK
> RECT fleet "[-117 30],[-112 36]"
1) "fleet:0:pos"
2) "[-115.567 33.532]"
3) "fleet:2:pos"
4) "[-116.671 35.735]"
5) "fleet:3:pos"
6) "[-113.902 31.234]"
Using nested GeoJSON:
> SETINDEX fleet fleet:* SPATIAL JSON pos
OK
> SET fleet:0 '{"driver":"Janet","pos":{"type":"Point","coordinates":[-115.567,33.532]}}'
OK
> SET fleet:1 '{"driver":"Tom","pos":{"type":"Point","coordinates":[-121.896,32.334]}}'
OK
> SET fleet:2 '{"driver":"Andrew","pos":{"type":"Point","coordinates":[-116.671,35.735]}}'
OK
> SET fleet:3 '{"driver":"Pam","pos":{"type":"Point","coordinates":[-113.902,31.234]}}'
OK
> RECT fleet '{"pos":"[-117 30],[-112 36]"}'
1) "fleet:0"
2) "{\"driver\":\"Janet\",\"pos\":{\"type\":\"Point\",\"coordinates\":[-115.567,33.532]}}"
3) "fleet:2"
4) "{\"driver\":\"Andrew\",\"pos\":{\"type\":\"Point\",\"coordinates\":[-116.671,35.735]}}"
5) "fleet:3"
6) "{\"driver\":\"Pam\",\"pos\":{\"type\":\"Point\",\"coordinates\":[-113.902,31.234]}}"