1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

support geopos command

This commit is contained in:
Sergey Shcherbina
2016-08-22 02:32:06 +05:00
parent 909c26e76c
commit ac1c5e46f9
3 changed files with 97 additions and 0 deletions

View File

@ -806,6 +806,10 @@ type GeoLocation struct {
GeoHash int64
}
type GeoPosition struct {
Longitude, Latitude float64
}
// GeoRadiusQuery is used with GeoRadius to query geospatial index.
type GeoRadiusQuery struct {
Radius float64
@ -882,6 +886,44 @@ func (cmd *GeoLocationCmd) readReply(cn *pool.Conn) error {
return nil
}
type GeoPosCmd struct {
baseCmd
positions []*GeoPosition
}
func NewGeoPosCmd(args ...interface{}) *GeoPosCmd {
cmd := newBaseCmd(args)
return &GeoPosCmd{baseCmd: cmd}
}
func (cmd *GeoPosCmd) Val() []*GeoPosition {
return cmd.positions
}
func (cmd *GeoPosCmd) Result() ([]*GeoPosition, error) {
return cmd.Val(), cmd.Err()
}
func (cmd *GeoPosCmd) String() string {
return cmdString(cmd, cmd.positions)
}
func (cmd *GeoPosCmd) reset() {
cmd.positions = nil
cmd.err = nil
}
func (cmd *GeoPosCmd) readReply(cn *pool.Conn) error {
reply, err := cn.Rd.ReadArrayReply(newGeoPositionSliceParser())
if err != nil {
cmd.err = err
return err
}
cmd.positions = reply.([]*GeoPosition)
return nil
}
//------------------------------------------------------------------------------
type CommandInfo struct {