2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-07-13 16:28:09 +08:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "redis_command.hpp"
|
2015-07-13 16:28:09 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2015-07-13 16:28:09 +08:00
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#define GEO_INVALID 360
|
|
|
|
|
#define GEO_LONGITUDE_MIN -180
|
|
|
|
|
#define GEO_LONGITUDE_MAX 180
|
|
|
|
|
#define GEO_LATITUDE_MIN -85.05112878
|
|
|
|
|
#define GEO_LATITUDE_MAX 85.05112878
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
GEO_UNIT_FT,
|
|
|
|
|
GEO_UNIT_M,
|
|
|
|
|
GEO_UNIT_MI,
|
|
|
|
|
GEO_UNIT_KM,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
GEO_WITH_COORD = 1 << 0,
|
|
|
|
|
GEO_WITH_DIST = 1 << 1,
|
|
|
|
|
GEO_WITH_HASH = 1 << 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
GEO_SORT_NONE,
|
|
|
|
|
GEO_SORT_ASC,
|
|
|
|
|
GEO_SORT_DESC,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API geo_member
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
geo_member(const char* name);
|
|
|
|
|
geo_member(const geo_member& member);
|
2016-01-17 13:35:12 +08:00
|
|
|
|
~geo_member(void);
|
2015-07-13 16:28:09 +08:00
|
|
|
|
|
|
|
|
|
void set_name(const char* name);
|
|
|
|
|
const char* get_name() const
|
|
|
|
|
{
|
|
|
|
|
return name_.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_dist(double dist);
|
|
|
|
|
double get_dist() const
|
|
|
|
|
{
|
|
|
|
|
return dist_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
void set_hash(__int64 hash);
|
|
|
|
|
__int64 get_hash() const
|
|
|
|
|
#else
|
|
|
|
|
void set_hash(long long int hash);
|
|
|
|
|
long long int get_hash() const
|
|
|
|
|
#endif // defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
{
|
|
|
|
|
return hash_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_coordinate(double longitude, double latitude);
|
|
|
|
|
double get_longitude() const
|
|
|
|
|
{
|
|
|
|
|
return longitude_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double get_latitude() const
|
|
|
|
|
{
|
|
|
|
|
return latitude_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
string name_;
|
|
|
|
|
double dist_;
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
__int64 hash_;
|
|
|
|
|
#else
|
|
|
|
|
long long int hash_;
|
|
|
|
|
#endif // defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
|
|
|
|
|
double longitude_;
|
|
|
|
|
double latitude_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API redis_geo : virtual public redis_command
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command()
|
|
|
|
|
*/
|
|
|
|
|
redis_geo();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client*)
|
|
|
|
|
*/
|
|
|
|
|
redis_geo(redis_client* conn);
|
|
|
|
|
|
|
|
|
|
/**
|
2020-07-20 11:21:47 +08:00
|
|
|
|
* see redis_command::redis_command(redis_client_cluster*)
|
2015-07-13 16:28:09 +08:00
|
|
|
|
*/
|
2020-07-20 11:21:47 +08:00
|
|
|
|
redis_geo(redis_client_cluster* cluster);
|
|
|
|
|
|
|
|
|
|
ACL_CPP_DEPRECATED
|
|
|
|
|
redis_geo(redis_client_cluster* cluster, size_t max_conns);
|
2021-01-09 23:16:15 +08:00
|
|
|
|
|
|
|
|
|
redis_geo(redis_client_pipeline* pipeline);
|
|
|
|
|
|
2015-07-13 16:28:09 +08:00
|
|
|
|
virtual ~redis_geo();
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> key <EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Add the specified geospatial item (latitude, logitude, name)
|
|
|
|
|
* to the specified key.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param member {const char*} <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʶ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the geospatial's identifier
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param longitude {double} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the geospatial's loginitude
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param latitude {double} γ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the geospatial's latitude
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>
|
|
|
|
|
* Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<EFBFBD><EFBFBD>-1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the return value as below:
|
|
|
|
|
* 1: add one new member successfully
|
|
|
|
|
* 0: the member already existed, and the geospatial may be changed
|
|
|
|
|
* -1: some erro happened
|
|
|
|
|
*/
|
|
|
|
|
int geoadd(const char* key, const char* member,
|
|
|
|
|
double longitude, double latitude);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Add the specified geospatial items (latitude, logitude, name)
|
|
|
|
|
* to the specified key.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param size {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the array's size
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param members {const char* []} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members array, which's length was specified by size parameter
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param longitudes {const double[]} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the logintitudes array, which's length was specifed by size parameter
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param latitudes {const double[]} γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the lattitudes array, which's length was specifed by size parameter
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD>ij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* return the successfully added members's count:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* represent the successfully added members's count
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* 0: <EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members's belong the key already existing
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* -1: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> result_error <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鿴<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* some error happened, the result_error function can be used
|
|
|
|
|
* to find the error's reason
|
|
|
|
|
*/
|
2019-09-13 19:47:23 +08:00
|
|
|
|
int geoadd(const char* key, size_t size, const char* members[],
|
2015-07-13 16:28:09 +08:00
|
|
|
|
const double longitudes[], const double latitudes[]);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Add the specified geospatial items (latitude, logitude, name)
|
|
|
|
|
* to the specified key.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param members {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members array
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param longitudes {const std::vector<double>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the logintitudes array
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param latitudes {const std::vector<double>&} γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the lattitudes array
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD>ij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* return the successfully added members's count:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* represent the successfully added members's count
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* 0: <EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members's belong the key already existing
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* -1: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> result_error <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鿴<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* some error happened, the result_error function can be used
|
|
|
|
|
* to find the error's reason
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ע<EFBFBD>⣺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(members, longitudes, latitudes)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鳤<EFBFBD>ȱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Notice: the three array's length must be equal between members,
|
|
|
|
|
* longitudes and latitudes
|
|
|
|
|
*/
|
|
|
|
|
int geoadd(const char* key, const std::vector<string>& members,
|
|
|
|
|
const std::vector<double>& longitudes,
|
|
|
|
|
const std::vector<double>& latitudes);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD> GEOHASH ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns members of a geospatial index as standard geohash strings.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param members {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members array
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param results {std::vector<string>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* store the result
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool geohash(const char* key, const std::vector<string>& members,
|
|
|
|
|
std::vector<string>& results);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD> GEOHASH ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns members of a geospatial index as standard geohash strings.
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param member {const char*} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the member of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param result {std::vector<string>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* store the result
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool geohash(const char* key, const char* member, string& result);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns longitude and latitude of members of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-09-13 19:47:23 +08:00
|
|
|
|
* @param members {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the members array
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param results {std::vector<std::pair<double, double> >&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* store the results
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool geopos(const char* key, const std::vector<string>& members,
|
|
|
|
|
std::vector<std::pair<double, double> >& results);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns longitude and latitude of the one member of
|
|
|
|
|
* a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specifed key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param member {const char*} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified member
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param result {std::pair<double, double>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* store the result of longitude and latitude of the member
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool geopos(const char* key, const char* member,
|
|
|
|
|
std::pair<double, double>& result);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns the distance between two members of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param member1 {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* one member of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param member2 {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* another member of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param unit {int} <EFBFBD><EFBFBD><EFBFBD>صľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λֵ
|
|
|
|
|
* @return {double} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ < 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* returns the distance between two members, which was less than 0
|
|
|
|
|
* if some error happened.
|
|
|
|
|
*/
|
|
|
|
|
double geodist(const char* key, const char* member1,
|
|
|
|
|
const char* member2, int unit = GEO_UNIT_M);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD><EFBFBD><EFBFBD>ijָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뷶Χ<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Query a sorted set representing a geospatial index to fetch
|
|
|
|
|
* members matching a given maximum distance from a point
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param longitude {double} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the longitude of the specified geospatial coordinate
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param latitude {double} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the latitude of the specified geospatial coordinate
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param radius {double} <EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>뷶Χ<EFBFBD><EFBFBD>С
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the distance from the specified coordinate
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param unit {int} radius <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the unit type of the raidus
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param with {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>壺GEO_WITH_XXX
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the serach operations, defined as GEO_WITH_XXX above
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param sort {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD>GEO_SORT_XXX
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the sorted type of the results, defined as GEO_SORT_XXX above
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {const std::vector<geo_member>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns the results according the searching conditions.
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<geo_member>& georadius(const char* key,
|
|
|
|
|
double longitude, double latitude, double radius,
|
|
|
|
|
int unit = GEO_UNIT_M,
|
|
|
|
|
int with = GEO_WITH_COORD | GEO_WITH_DIST,
|
|
|
|
|
int sort = GEO_SORT_ASC);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD><EFBFBD><EFBFBD>ijָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뷶Χ<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Query a sorted set representing a geospatial index to fetch
|
|
|
|
|
* members matching a given maximum distance from a member
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param member {const char*} ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the specified member of a geospatial index
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param radius {double} <EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>뷶Χ<EFBFBD><EFBFBD>С
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the distance from the specified coordinate
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param unit {int} radius <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the unit type of the raidus
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param with {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>壺GEO_WITH_XXX
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the serach operations, defined as GEO_WITH_XXX above
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param sort {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD>GEO_SORT_XXX
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* the sorted type of the results, defined as GEO_SORT_XXX above
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {const std::vector<geo_member>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-07-13 16:28:09 +08:00
|
|
|
|
* Returns the results according the searching conditions.
|
|
|
|
|
*/
|
|
|
|
|
const std::vector<geo_member>& georadiusbymember(const char* key,
|
|
|
|
|
const char* member, double radius,
|
|
|
|
|
int unit = GEO_UNIT_M,
|
|
|
|
|
int with = GEO_WITH_COORD | GEO_WITH_DIST,
|
|
|
|
|
int sort = GEO_SORT_ASC);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<geo_member> positions_;
|
|
|
|
|
|
|
|
|
|
void add_one_pos(const redis_result& rr);
|
|
|
|
|
static const char* get_unit(int unit);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|