33
44namespace ServiceStack . Redis
55{
6- public struct RedisGeo
6+ public class RedisGeo
77 {
8- public double Longitude ;
9- public double Latitude ;
10- public string Member ;
11-
12- public RedisGeo ( double longitude , double latitude , string member )
13- {
14- Longitude = longitude ;
15- Latitude = latitude ;
16- Member = member ;
17- }
18-
19- public RedisGeo ( string geoString ) : this ( )
20- {
21- if ( string . IsNullOrEmpty ( geoString ) )
22- throw new ArgumentNullException ( "geoString" ) ;
23-
24- var pos1 = geoString . IndexOf ( ' ' ) ;
25- if ( pos1 == - 1 )
26- throw new ArgumentException ( "Invalid geoString: " + geoString ) ;
27- Longitude = double . Parse ( geoString . Substring ( 0 , pos1 ) ) ;
28-
29- var pos2 = geoString . IndexOf ( ' ' , pos1 + 1 ) ;
30- if ( pos2 == - 1 )
31- throw new ArgumentException ( "Invalid geoString: " + geoString ) ;
32- Latitude = double . Parse ( geoString . Substring ( pos1 , pos2 - pos1 ) ) ;
33-
34- Member = geoString . Substring ( pos2 + 1 ) ;
35- }
36-
37- public override string ToString ( )
38- {
39- return Longitude . ToString ( CultureInfo . InvariantCulture )
40- + " "
41- + Latitude . ToString ( CultureInfo . InvariantCulture )
42- + " "
43- + Member ;
44- }
45-
46- public bool Equals ( RedisGeo other )
47- {
48- return Longitude . Equals ( other . Longitude )
49- && Latitude . Equals ( other . Latitude )
50- && string . Equals ( Member , other . Member ) ;
51- }
52-
53- public override bool Equals ( object obj )
54- {
55- if ( ReferenceEquals ( null , obj ) ) return false ;
56- return obj is RedisGeo && Equals ( ( RedisGeo ) obj ) ;
57- }
8+ public double Longitude { get ; set ; }
9+ public double Latitude { get ; set ; }
10+ public string Member { get ; set ; }
11+ }
5812
59- public override int GetHashCode ( )
60- {
61- unchecked
62- {
63- var hashCode = Longitude . GetHashCode ( ) ;
64- hashCode = ( hashCode * 397 ) ^ Latitude . GetHashCode ( ) ;
65- hashCode = ( hashCode * 397 ) ^ ( Member != null ? Member . GetHashCode ( ) : 0 ) ;
66- return hashCode ;
67- }
68- }
13+ public class RedisGeoResult
14+ {
15+ public string Member { get ; set ; }
16+ public double ? Longitude { get ; set ; }
17+ public double ? Latitude { get ; set ; }
18+ public string Hash { get ; set ; }
19+ public string Unit { get ; set ; }
20+ public double ? Distance { get ; set ; }
6921 }
7022}
0 commit comments