Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c066565

Browse files
author
kimyonghwa
committed
modify command geo
1 parent c828f3a commit c066565

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎src/test/java/com/redis/cluster/RedisClusterTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,29 @@ public void opsSortedSet() {
138138
public void opsGeo() {
139139
GeoOperations<String, String> geoOps = redisTemplate.opsForGeo();
140140
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)}};
142143
String cacheKey = "valueGeo";
144+
145+
// previous key delete
146+
redisTemplate.delete(cacheKey);
147+
143148
for (int x = 0; x < cities.length; x++) {
144-
for (int y = 0; y < gu.length / 2; y++) {
145-
geoOps.add(cacheKey, newPoint(x, y), gu[x * y]);
149+
for (int y = 0; y < 5; y++) {
150+
geoOps.add(cacheKey, pointGu[x][y], gu[x][y]);
146151
}
147152
}
153+
148154
log.info("##### opsGeo #####");
149155
Distance distance = geoOps.distance(cacheKey, "강남구", "동작구");
150156
assertNotNull(distance);
157+
assertEquals(4469610.0767, distance.getValue(), 4);
151158
log.info("Distance : {}", distance.getValue());
152159
List<Point> position = geoOps.position(cacheKey, "동작구");
153160
assertNotNull(position);
154161
for (Point point : position) {
162+
assertEquals(14.000001847743988d, point.getX(), 4);
163+
assertEquals(30.000000249977013d, point.getY(), 4);
155164
log.info("Position : {} x {}", point.getX(), point.getY());
156165
}
157166
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /