mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-15 09:20:52 +08:00
331 lines
10 KiB
C++
331 lines
10 KiB
C++
|
#pragma once
|
|||
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|||
|
#include <vector>
|
|||
|
#include <map>
|
|||
|
#include "acl_cpp/stdlib/string.hpp"
|
|||
|
#include "acl_cpp/redis/redis_command.hpp"
|
|||
|
|
|||
|
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);
|
|||
|
~geo_member();
|
|||
|
|
|||
|
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 redis_client;
|
|||
|
|
|||
|
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);
|
|||
|
|
|||
|
/**
|
|||
|
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
|
|||
|
*/
|
|||
|
redis_geo(redis_client_cluster* cluster, size_t max_conns);
|
|||
|
virtual ~redis_geo();
|
|||
|
|
|||
|
/////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
/**
|
|||
|
* <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>
|
|||
|
* Add the specified geospatial item (latitude, logitude, name)
|
|||
|
* to the specified key.
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param member {const char*} <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ʶ<EFBFBD><EFBFBD>
|
|||
|
* the geospatial's identifier
|
|||
|
* @param loginitude {double} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the geospatial's loginitude
|
|||
|
* @param latitude {double} γ<EFBFBD><EFBFBD>
|
|||
|
* the geospatial's latitude
|
|||
|
* @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>
|
|||
|
* 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);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Add the specified geospatial items (latitude, logitude, name)
|
|||
|
* to the specified key.
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param size {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the array's size
|
|||
|
* @param memebers {const char* []} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
|||
|
* the members array, which's length was specified by size parameter
|
|||
|
* @param longitudes {const double[]} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
|||
|
* the logintitudes array, which's length was specifed by size parameter
|
|||
|
* @param latitudes {const double[]} γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD>䳤<EFBFBD><EFBFBD><EFBFBD><EFBFBD> size ָ<EFBFBD><EFBFBD>
|
|||
|
* the lattitudes array, which's length was specifed by size parameter
|
|||
|
* @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>
|
|||
|
* return the successfully added members's count:
|
|||
|
* > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* represent the successfully added memebers's count
|
|||
|
* 0: <EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the members's belong the key already existing
|
|||
|
* -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>
|
|||
|
* some error happened, the result_error function can be used
|
|||
|
* to find the error's reason
|
|||
|
*/
|
|||
|
int geoadd(const char* key, size_t size, const char* memebers[],
|
|||
|
const double longitudes[], const double latitudes[]);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַλ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Add the specified geospatial items (latitude, logitude, name)
|
|||
|
* to the specified key.
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param memebers {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the members array
|
|||
|
* @param longitudes {const std::vector<double>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the logintitudes array
|
|||
|
* @param latitudes {const std::vector<double>&} γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the lattitudes array
|
|||
|
* @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>
|
|||
|
* return the successfully added members's count:
|
|||
|
* > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* represent the successfully added memebers's count
|
|||
|
* 0: <EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the members's belong the key already existing
|
|||
|
* -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>
|
|||
|
* some error happened, the result_error function can be used
|
|||
|
* to find the error's reason
|
|||
|
* ע<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>
|
|||
|
* 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);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD> GEOHASH ֵ
|
|||
|
* Returns members of a geospatial index as standard geohash strings.
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param memebers {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the members array
|
|||
|
* @param results {std::vector<string>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* store the result
|
|||
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* if the operation was successful.
|
|||
|
*/
|
|||
|
bool geohash(const char* key, const std::vector<string>& members,
|
|||
|
std::vector<string>& results);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD> GEOHASH ֵ
|
|||
|
* Returns members of a geospatial index as standard geohash strings.
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param memeber {const char*} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>
|
|||
|
* the member of a geospatial index
|
|||
|
* @param result {std::vector<string>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* store the result
|
|||
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* if the operation was successful.
|
|||
|
*/
|
|||
|
bool geohash(const char* key, const char* member, string& result);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Returns longitude and latitude of members of a geospatial index
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param memebers {const std::vector<string>&} <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the members array
|
|||
|
* @param results {std::vector<std::pair<double, double> >&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* store the results
|
|||
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* if the operation was successful.
|
|||
|
*/
|
|||
|
bool geopos(const char* key, const std::vector<string>& members,
|
|||
|
std::vector<std::pair<double, double> >& results);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Returns longitude and latitude of the one member of
|
|||
|
* a geospatial index
|
|||
|
* @param key {const char*} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
* the specifed key
|
|||
|
* @param member {const char*} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>
|
|||
|
* the specified member
|
|||
|
* @param result {std::pair<double, double>&} <EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* store the result of longitude and latitude of the member
|
|||
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* if the operation was successful.
|
|||
|
*/
|
|||
|
bool geopos(const char* key, const char* member,
|
|||
|
std::pair<double, double>& result);
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Returns the distance between two members of a geospatial index
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param member1 {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
|||
|
* one member of a geospatial index
|
|||
|
* @param member2 {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
|||
|
* another member of a geospatial index
|
|||
|
* @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>
|
|||
|
* 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);
|
|||
|
|
|||
|
/**
|
|||
|
* <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>
|
|||
|
* Query a sorted set representing a geospatial index to fetch
|
|||
|
* members matching a given maximum distance from a point
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param longitude {double} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
* the longitude of the specified geospatial coordinate
|
|||
|
* @param latitude {double} ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD>ֵ
|
|||
|
* the latitude of the specified geospatial coordinate
|
|||
|
* @param radius {double} <EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>뷶Χ<EFBFBD><EFBFBD>С
|
|||
|
* the distance from the specified coordinate
|
|||
|
* @param unit {int} radius <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the unit type of the raidus
|
|||
|
* @param with {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>壺GEO_WITH_XXX
|
|||
|
* the serach operations, defined as GEO_WITH_XXX above
|
|||
|
* @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
|
|||
|
* the sorted type of the results, defined as GEO_SORT_XXX above
|
|||
|
* @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>
|
|||
|
* 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);
|
|||
|
|
|||
|
/**
|
|||
|
* <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>
|
|||
|
* Query a sorted set representing a geospatial index to fetch
|
|||
|
* members matching a given maximum distance from a member
|
|||
|
* @param key {const char*} <EFBFBD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD>ֵ
|
|||
|
* the specified key
|
|||
|
* @param member {const char*} ij<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
|
|||
|
* the specified member of a geospatial index
|
|||
|
* @param radius {double} <EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>뷶Χ<EFBFBD><EFBFBD>С
|
|||
|
* the distance from the specified coordinate
|
|||
|
* @param unit {int} radius <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* the unit type of the raidus
|
|||
|
* @param with {int} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>μ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>壺GEO_WITH_XXX
|
|||
|
* the serach operations, defined as GEO_WITH_XXX above
|
|||
|
* @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
|
|||
|
* the sorted type of the results, defined as GEO_SORT_XXX above
|
|||
|
* @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>
|
|||
|
* 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
|