@@ -138,20 +138,29 @@ public void opsSortedSet() {
138
138
public void opsGeo () {
139
139
GeoOperations <String , String > geoOps = redisTemplate .opsForGeo ();
140
140
String [] cities = {"서울" , "부산" };
141
- String [] gu = {"강남구" , "서초구" , "관악구" , "동작구" , "마포구" , "사하구" , "해운대구" , "영도구" , "동래구" , "수영구" };
141
+ String [][] gu = {{"강남구" , "서초구" , "관악구" , "동작구" , "마포구" }, {"사하구" , "해운대구" , "영도구" , "동래구" , "수영구" }};
142
+ Point [][] pointGu = {{new Point (10 , -10 ), new Point (11 , -20 ), new Point (13 , 10 ), new Point (14 , 30 ), new Point (15 , 40 )}, {new Point (-100 , 10 ), new Point (-110 , 20 ), new Point (-130 , 80 ), new Point (-140 , 60 ), new Point (-150 , 30 )}};
142
143
String cacheKey = "valueGeo" ;
144
+
145
+ // previous key delete
146
+ redisTemplate .delete (cacheKey );
147
+
143
148
for (int x = 0 ; x < cities .length ; x ++) {
144
- for (int y = 0 ; y < gu . length / 2 ; y ++) {
145
- geoOps .add (cacheKey , new Point ( x , y ) , gu [x * y ]);
149
+ for (int y = 0 ; y < 5 ; y ++) {
150
+ geoOps .add (cacheKey , pointGu [ x ][ y ] , gu [x ][ y ]);
146
151
}
147
152
}
153
+
148
154
log .info ("##### opsGeo #####" );
149
155
Distance distance = geoOps .distance (cacheKey , "강남구" , "동작구" );
150
156
assertNotNull (distance );
157
+ assertEquals (4469610.0767 , distance .getValue (), 4 );
151
158
log .info ("Distance : {}" , distance .getValue ());
152
159
List <Point > position = geoOps .position (cacheKey , "동작구" );
153
160
assertNotNull (position );
154
161
for (Point point : position ) {
162
+ assertEquals (14.000001847743988d , point .getX (), 4 );
163
+ assertEquals (30.000000249977013d , point .getY (), 4 );
155
164
log .info ("Position : {} x {}" , point .getX (), point .getY ());
156
165
}
157
166
}
0 commit comments