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:
42
command.go
42
command.go
@ -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 {
|
||||
|
Reference in New Issue
Block a user