diff options
author | 杨博东 <bodong.ybd@alibaba-inc.com> | 2020-12-12 08:21:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-12 02:21:05 +0200 |
commit | 4d06d99bf8fc91289c79ae07110c92525ab1c1f8 (patch) | |
tree | 343f512de0c1b0d83c29e99189ba2b02a8f837cb /src/geohash.h | |
parent | 8c291b97b95f2e011977b522acf77ead23e26f55 (diff) | |
download | redis-4d06d99bf8fc91289c79ae07110c92525ab1c1f8.tar.gz |
Add GEOSEARCH / GEOSEARCHSTORE commands (#8094)
Add commands to query geospatial data with bounding box.
Two new commands that replace the existing 4 GEORADIUS* commands.
GEOSEARCH key [FROMMEMBER member] [FROMLOC long lat] [BYRADIUS radius
unit] [BYBOX width height unit] [WITHCORD] [WITHDIST] [WITHASH] [COUNT
count] [ASC|DESC]
GEOSEARCHSTORE dest_key src_key [FROMMEMBER member] [FROMLOC long lat]
[BYRADIUS radius unit] [BYBOX width height unit] [WITHCORD] [WITHDIST]
[WITHASH] [COUNT count] [ASC|DESC] [STOREDIST]
- Add two types of CIRCULAR_TYPE and RECTANGLE_TYPE to achieve different searches
- Judge whether the point is within the rectangle, refer to:
geohashGetDistanceIfInRectangle
Diffstat (limited to 'src/geohash.h')
-rw-r--r-- | src/geohash.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/geohash.h b/src/geohash.h index ed2ef9336..ebe52ff34 100644 --- a/src/geohash.h +++ b/src/geohash.h @@ -90,6 +90,25 @@ typedef struct { GeoHashBits south_west; } GeoHashNeighbors; +#define CIRCULAR_TYPE 1 +#define RECTANGLE_TYPE 2 +typedef struct { + int type; /* search type */ + double xy[2]; /* search center point, xy[0]: lon, xy[1]: lat */ + double conversion; /* km: 1000 */ + double bounds[4]; /* bounds[0]: min_lon, bounds[1]: min_lat + * bounds[2]: max_lon, bounds[3]: max_lat */ + union { + /* CIRCULAR_TYPE */ + double radius; + /* RECTANGLE_TYPE */ + struct { + double height; + double width; + } r; + } t; +} GeoShape; + /* * 0:success * -1:failed |