From bc40d5caa5d6d56f15492606933ecbf8ca615a66 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 10 Jul 2015 20:55:55 +0200 Subject: [PATCH] Remove GEOENCODE / GEODECODE commands #102 Remove commands as they were removed from Redis. So long, good bye, ciao ciao & do widzenia --- .../redis/AbstractRedisAsyncCommands.java | 15 ---- .../redis/AbstractRedisReactiveCommands.java | 15 ---- .../com/lambdaworks/redis/GeoEncoded.java | 67 ----------------- .../redis/RedisCommandBuilder.java | 19 ----- .../redis/RedisGeoAsyncConnection.java | 36 ---------- .../lambdaworks/redis/RedisGeoConnection.java | 36 ---------- .../api/async/RedisGeoAsyncCommands.java | 37 ---------- .../api/rx/RedisGeoReactiveCommands.java | 37 ---------- .../redis/api/sync/RedisGeoCommands.java | 37 ---------- .../async/NodeSelectionGeoAsyncCommands.java | 36 ---------- .../redis/output/GeoEncodedOutput.java | 72 ------------------- .../redis/api/RedisGeoCommands.java | 36 ---------- .../com/lambdaworks/redis/GeoModelTest.java | 46 ------------ .../redis/commands/GeoCommandTest.java | 44 ------------ 14 files changed, 533 deletions(-) delete mode 100644 src/main/java/com/lambdaworks/redis/GeoEncoded.java delete mode 100644 src/main/java/com/lambdaworks/redis/output/GeoEncodedOutput.java diff --git a/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java b/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java index 3b2f77a7fe..973c8cb8f2 100644 --- a/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java +++ b/src/main/java/com/lambdaworks/redis/AbstractRedisAsyncCommands.java @@ -1630,21 +1630,6 @@ public RedisFuture geodist(K key, V from, V to, GeoArgs.Unit unit) { return dispatch(commandBuilder.geodist(key, from, to, unit)); } - @Override - public RedisFuture geoencode(double longitude, double latitude) { - return dispatch(commandBuilder.geoencode(longitude, latitude, null, null)); - } - - @Override - public RedisFuture geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return dispatch(commandBuilder.geoencode(longitude, latitude, distance, unit.name())); - } - - @Override - public RedisFuture geodecode(long geohash) { - return dispatch(commandBuilder.geodecode(geohash)); - } - protected RedisFuture dispatch(CommandType type, CommandOutput output) { return dispatch(type, output, null); } diff --git a/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java b/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java index 9ee8e67886..ea3c83792a 100644 --- a/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java +++ b/src/main/java/com/lambdaworks/redis/AbstractRedisReactiveCommands.java @@ -1594,21 +1594,6 @@ public Observable geodist(K key, V from, V to, GeoArgs.Unit unit) { return createDissolvingObservable(() -> commandBuilder.geodist(key, from, to, unit)); } - @Override - public Observable geoencode(double longitude, double latitude) { - return createDissolvingObservable(() -> commandBuilder.geoencode(longitude, latitude, null, null)); - } - - @Override - public Observable geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit) { - return createDissolvingObservable(() -> commandBuilder.geoencode(longitude, latitude, distance, unit.name())); - } - - @Override - public Observable geodecode(long geohash) { - return createDissolvingObservable(() -> commandBuilder.geodecode(geohash)); - } - protected Observable createObservable(CommandType type, CommandOutput output, CommandArgs args) { return createObservable(() -> new Command<>(type, output, args)); } diff --git a/src/main/java/com/lambdaworks/redis/GeoEncoded.java b/src/main/java/com/lambdaworks/redis/GeoEncoded.java deleted file mode 100644 index ad9e7f0cb7..0000000000 --- a/src/main/java/com/lambdaworks/redis/GeoEncoded.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.lambdaworks.redis; - -/** - * Geo-encoded object. Contains: - * - *
    - *
  • the 52-bit geohash integer for your longitude/latitude
  • - *
  • the minimum corner of your geohash {@link GeoCoordinates}
  • - *
  • the maximum corner of your geohash {@link GeoCoordinates}
  • - *
  • 4: The averaged center of your geohash {@link GeoCoordinates}
  • - *
- * - * @author Mark Paluch - */ -public class GeoEncoded { - - public final long geohash; - public final GeoCoordinates min; - public final GeoCoordinates max; - public final GeoCoordinates avg; - - public GeoEncoded(long geohash, GeoCoordinates min, GeoCoordinates max, GeoCoordinates avg) { - this.geohash = geohash; - this.min = min; - this.max = max; - this.avg = avg; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof GeoEncoded)) - return false; - - GeoEncoded that = (GeoEncoded) o; - - if (geohash != that.geohash) - return false; - if (min != null ? !min.equals(that.min) : that.min != null) - return false; - if (max != null ? !max.equals(that.max) : that.max != null) - return false; - return !(avg != null ? !avg.equals(that.avg) : that.avg != null); - } - - @Override - public int hashCode() { - int result = (int) (geohash ^ (geohash >>> 32)); - result = 31 * result + (min != null ? min.hashCode() : 0); - result = 31 * result + (max != null ? max.hashCode() : 0); - result = 31 * result + (avg != null ? avg.hashCode() : 0); - return result; - } - - @Override - public String toString() { - final StringBuffer sb = new StringBuffer(); - sb.append(getClass().getSimpleName()); - sb.append(" [geohash=").append(geohash); - sb.append(", min=").append(min); - sb.append(", max=").append(max); - sb.append(", avg=").append(avg); - sb.append(']'); - return sb.toString(); - } -} diff --git a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java index 707d10b5eb..2d43832fdf 100644 --- a/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java +++ b/src/main/java/com/lambdaworks/redis/RedisCommandBuilder.java @@ -64,7 +64,6 @@ import com.lambdaworks.redis.output.DateOutput; import com.lambdaworks.redis.output.DoubleOutput; import com.lambdaworks.redis.output.GeoCoordinatesListOutput; -import com.lambdaworks.redis.output.GeoEncodedOutput; import com.lambdaworks.redis.output.GeoWithinListOutput; import com.lambdaworks.redis.output.IntegerOutput; import com.lambdaworks.redis.output.KeyListOutput; @@ -1840,24 +1839,6 @@ public Command geodist(K key, V from, V to, GeoArgs.Unit unit) { } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Command geoencode(double longitude, double latitude, Double distance, String unit) { - - CommandArgs args = new CommandArgs(codec).add(longitude).add(latitude); - - if (distance != null && unit != null) { - args.add(distance).add(unit); - } - return (Command) createCommand(GEOENCODE, new GeoEncodedOutput(codec, null), args); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Command geodecode(long geohash) { - CommandArgs args = new CommandArgs(codec).add(geohash); - - return (Command) createCommand(GEODECODE, new GeoEncodedOutput(codec, geohash), args); - } - /** * Assert that a string is not empty, it must not be {@code null} and it must not be empty. * diff --git a/src/main/java/com/lambdaworks/redis/RedisGeoAsyncConnection.java b/src/main/java/com/lambdaworks/redis/RedisGeoAsyncConnection.java index a435a2aed5..b15dddf896 100644 --- a/src/main/java/com/lambdaworks/redis/RedisGeoAsyncConnection.java +++ b/src/main/java/com/lambdaworks/redis/RedisGeoAsyncConnection.java @@ -110,40 +110,4 @@ RedisFuture>> georadius(K key, double longitude, double latitu * returned. */ RedisFuture geodist(K key, V from, V to, GeoArgs.Unit unit); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - RedisFuture geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - RedisFuture geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - RedisFuture geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/RedisGeoConnection.java b/src/main/java/com/lambdaworks/redis/RedisGeoConnection.java index 930fae6039..780b46f76d 100644 --- a/src/main/java/com/lambdaworks/redis/RedisGeoConnection.java +++ b/src/main/java/com/lambdaworks/redis/RedisGeoConnection.java @@ -109,40 +109,4 @@ public interface RedisGeoConnection { * returned. */ Double geodist(K key, V from, V to, GeoArgs.Unit unit); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - GeoEncoded geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/api/async/RedisGeoAsyncCommands.java b/src/main/java/com/lambdaworks/redis/api/async/RedisGeoAsyncCommands.java index 1b4aca584d..eac06a995b 100644 --- a/src/main/java/com/lambdaworks/redis/api/async/RedisGeoAsyncCommands.java +++ b/src/main/java/com/lambdaworks/redis/api/async/RedisGeoAsyncCommands.java @@ -3,7 +3,6 @@ import com.lambdaworks.redis.GeoArgs; import com.lambdaworks.redis.GeoCoordinates; import com.lambdaworks.redis.GeoWithin; -import com.lambdaworks.redis.GeoEncoded; import java.util.List; import java.util.Set; import com.lambdaworks.redis.RedisFuture; @@ -114,40 +113,4 @@ RedisFuture>> georadius(K key, double longitude, double latitu * returned. */ RedisFuture geodist(K key, V from, V to, GeoArgs.Unit unit); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - RedisFuture geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - RedisFuture geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - RedisFuture geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/api/rx/RedisGeoReactiveCommands.java b/src/main/java/com/lambdaworks/redis/api/rx/RedisGeoReactiveCommands.java index 6d9105060d..5d31847aee 100644 --- a/src/main/java/com/lambdaworks/redis/api/rx/RedisGeoReactiveCommands.java +++ b/src/main/java/com/lambdaworks/redis/api/rx/RedisGeoReactiveCommands.java @@ -3,7 +3,6 @@ import com.lambdaworks.redis.GeoArgs; import com.lambdaworks.redis.GeoCoordinates; import com.lambdaworks.redis.GeoWithin; -import com.lambdaworks.redis.GeoEncoded; import java.util.List; import java.util.Set; import rx.Observable; @@ -114,40 +113,4 @@ Observable> georadius(K key, double longitude, double latitude, dou * returned. */ Observable geodist(K key, V from, V to, GeoArgs.Unit unit); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - Observable geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - Observable geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - Observable geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/api/sync/RedisGeoCommands.java b/src/main/java/com/lambdaworks/redis/api/sync/RedisGeoCommands.java index 0f97fa8c2c..2484cdeda9 100644 --- a/src/main/java/com/lambdaworks/redis/api/sync/RedisGeoCommands.java +++ b/src/main/java/com/lambdaworks/redis/api/sync/RedisGeoCommands.java @@ -3,7 +3,6 @@ import com.lambdaworks.redis.GeoArgs; import com.lambdaworks.redis.GeoCoordinates; import com.lambdaworks.redis.GeoWithin; -import com.lambdaworks.redis.GeoEncoded; import java.util.List; import java.util.Set; @@ -112,40 +111,4 @@ public interface RedisGeoCommands { * returned. */ Double geodist(K key, V from, V to, GeoArgs.Unit unit); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - GeoEncoded geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/cluster/api/async/NodeSelectionGeoAsyncCommands.java b/src/main/java/com/lambdaworks/redis/cluster/api/async/NodeSelectionGeoAsyncCommands.java index c6d36f063f..11c0162e58 100644 --- a/src/main/java/com/lambdaworks/redis/cluster/api/async/NodeSelectionGeoAsyncCommands.java +++ b/src/main/java/com/lambdaworks/redis/cluster/api/async/NodeSelectionGeoAsyncCommands.java @@ -3,7 +3,6 @@ import com.lambdaworks.redis.GeoArgs; import com.lambdaworks.redis.GeoCoordinates; import com.lambdaworks.redis.GeoWithin; -import com.lambdaworks.redis.GeoEncoded; import java.util.List; import java.util.Set; import com.lambdaworks.redis.RedisFuture; @@ -115,39 +114,4 @@ AsyncExecutions>> georadius(K key, double longitude, double la */ AsyncExecutions geodist(K key, V from, V to, GeoArgs.Unit unit); - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - AsyncExecutions geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - AsyncExecutions geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - AsyncExecutions geodecode(long geohash); } diff --git a/src/main/java/com/lambdaworks/redis/output/GeoEncodedOutput.java b/src/main/java/com/lambdaworks/redis/output/GeoEncodedOutput.java deleted file mode 100644 index 312469cb35..0000000000 --- a/src/main/java/com/lambdaworks/redis/output/GeoEncodedOutput.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.lambdaworks.redis.output; - -import static java.lang.Double.parseDouble; - -import java.nio.ByteBuffer; - -import com.lambdaworks.redis.GeoEncoded; -import com.lambdaworks.redis.GeoCoordinates; -import com.lambdaworks.redis.codec.RedisCodec; - -/** - * Encodes the command output to retrieve a {@link GeoEncoded} object. - * - * @author Mark Paluch - */ -public class GeoEncodedOutput extends CommandOutput { - - private Long geohash; - private GeoCoordinates min; - private GeoCoordinates max; - private GeoCoordinates avg; - - private Double x; - - public GeoEncodedOutput(RedisCodec codec, Long geohash) { - super(codec, null); - this.geohash = geohash; - } - - @Override - public void set(long integer) { - if (geohash == null) { - geohash = integer; - } - } - - @Override - public void set(ByteBuffer bytes) { - Double value = (bytes == null) ? 0 : parseDouble(decodeAscii(bytes)); - - if (x == null) { - x = value; - return; - } - - try { - if (min == null) { - min = new GeoCoordinates(x, value); - return; - } - - if (max == null) { - max = new GeoCoordinates(x, value); - return; - } - - if (avg == null) { - avg = new GeoCoordinates(x, value); - return; - } - } finally { - x = null; - } - } - - @Override - public void complete(int depth) { - if (depth == 0) { - output = new GeoEncoded(geohash, min, max, avg); - } - } -} diff --git a/src/main/templates/com/lambdaworks/redis/api/RedisGeoCommands.java b/src/main/templates/com/lambdaworks/redis/api/RedisGeoCommands.java index 84cb23a2fe..bcdc55b7e6 100644 --- a/src/main/templates/com/lambdaworks/redis/api/RedisGeoCommands.java +++ b/src/main/templates/com/lambdaworks/redis/api/RedisGeoCommands.java @@ -3,7 +3,6 @@ import com.lambdaworks.redis.GeoArgs; import com.lambdaworks.redis.GeoCoordinates; import com.lambdaworks.redis.GeoWithin; -import com.lambdaworks.redis.GeoEncoded; import java.util.List; import java.util.Set; @@ -112,39 +111,4 @@ public interface RedisGeoCommands { */ Double geodist(K key, V from, V to, GeoArgs.Unit unit); - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @return multi-bulk reply with 4 elements 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum corner - * of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: The - * averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude); - - /** - * - * Encode {@code longitude} and {@code latitude} to highest geohash accuracy. - * - * @param longitude the longitude coordinate according to WGS84 - * @param latitude the latitude coordinate according to WGS84 - * @param distance distance for geohash accuracy - * @param unit the distance unit - * @return multi-bulk reply with four components 1: the 52-bit geohash integer for your longitude/latitude, 2: The minimum - * corner of your geohash {@link GeoCoordinates}, 3: The maximum corner of your geohash {@link GeoCoordinates}, 4: - * The averaged center of your geohash {@link GeoCoordinates}. - */ - GeoEncoded geoencode(double longitude, double latitude, double distance, GeoArgs.Unit unit); - - /** - * - * Decode geohash. - * - * @param geohash geohash containing your longitude/latitude - * @return a list of {@link GeoCoordinates}s (nested multi-bulk) with 3 elements 1: minimum decoded corner, 2: maximum - * decoded corner, 3: averaged center of bounding box. - */ - GeoEncoded geodecode(long geohash); } diff --git a/src/test/java/com/lambdaworks/redis/GeoModelTest.java b/src/test/java/com/lambdaworks/redis/GeoModelTest.java index 88d0b138a5..0093626fbc 100644 --- a/src/test/java/com/lambdaworks/redis/GeoModelTest.java +++ b/src/test/java/com/lambdaworks/redis/GeoModelTest.java @@ -96,50 +96,4 @@ public void geoCoordinatesEmpty() throws Exception { assertThat(sut.hashCode()).isEqualTo(equalsToSut.hashCode()); } - @Test - public void geoEncoded() throws Exception { - - GeoEncoded sut = new GeoEncoded(1234, new GeoCoordinates(null, 1), new GeoCoordinates(1, null), - new GeoCoordinates(1, 2)); - GeoEncoded equalsToSut = new GeoEncoded(1234, new GeoCoordinates(null, 1), new GeoCoordinates(1, null), - new GeoCoordinates(1, 2)); - - Map map = ImmutableMap.of(sut, "value"); - - assertThat(map.get(sut)).isEqualTo("value"); - assertThat(sut).isEqualTo(equalsToSut); - assertThat(sut.hashCode()).isEqualTo(equalsToSut.hashCode()); - assertThat(sut.toString()).isEqualTo(equalsToSut.toString()); - - } - - @Test - public void geoEncodedSlightlyDifferent() throws Exception { - - GeoEncoded sut = new GeoEncoded(1234, new GeoCoordinates(null, 1), new GeoCoordinates(1, 555.5), new GeoCoordinates(1, - 2)); - GeoEncoded slightlyDifferent = new GeoEncoded(1234, new GeoCoordinates(null, 1), new GeoCoordinates(1, null), - new GeoCoordinates(1, 2)); - - Map map = ImmutableMap.of(sut, "value"); - - assertThat(map.get(slightlyDifferent)).isNull(); - assertThat(sut).isNotEqualTo(slightlyDifferent); - assertThat(sut).isNotEqualTo( - slightlyDifferent = new GeoEncoded(0, new GeoCoordinates(null, 1), new GeoCoordinates(1, null), - new GeoCoordinates(1, 2))); - assertThat(sut.hashCode()).isNotEqualTo(slightlyDifferent.hashCode()); - assertThat(sut.toString()).isNotEqualTo(slightlyDifferent.toString()); - - } - - @Test - public void geoEncodedEmpty() throws Exception { - - GeoEncoded sut = new GeoEncoded(0, null, null, null); - GeoEncoded equalsToSut = new GeoEncoded(0, null, null, null); - - assertThat(sut).isEqualTo(equalsToSut); - assertThat(sut.hashCode()).isEqualTo(equalsToSut.hashCode()); - } } diff --git a/src/test/java/com/lambdaworks/redis/commands/GeoCommandTest.java b/src/test/java/com/lambdaworks/redis/commands/GeoCommandTest.java index b5fda173ee..aae2d07fcd 100644 --- a/src/test/java/com/lambdaworks/redis/commands/GeoCommandTest.java +++ b/src/test/java/com/lambdaworks/redis/commands/GeoCommandTest.java @@ -151,48 +151,4 @@ public void georadiusbymemberWithNullArgs() throws Exception { redis.georadiusbymember(key, "Bahn", 1, GeoArgs.Unit.km, null); } - @Test - public void geoencode() throws Exception { - - GeoEncoded geoencoded = redis.geoencode(8.6638775, 49.5282537); - - assertThat(geoencoded.geohash).isEqualTo(3666615932941099L); - assertThat(geoencoded.min.x.doubleValue()).isEqualTo(8.6638730764389038, offset(1d)); - assertThat(geoencoded.min.y.doubleValue()).isEqualTo(49.528251210511513, offset(1d)); - - assertThat(geoencoded.max.x.doubleValue()).isEqualTo(8.6638784408569336, offset(1d)); - assertThat(geoencoded.max.y.doubleValue()).isEqualTo(49.528253745232675, offset(1d)); - - assertThat(geoencoded.avg.x.doubleValue()).isEqualTo(8.6638757586479187, offset(1d)); - assertThat(geoencoded.avg.y.doubleValue()).isEqualTo(49.528252477872094, offset(1d)); - - } - - @Test - public void geoencodeWithDistance() throws Exception { - - GeoEncoded geoencoded = redis.geoencode(8.6638775, 49.5282537, 1, GeoArgs.Unit.km); - - assertThat(geoencoded.geohash).isEqualTo(3666615929405440L); - assertThat(geoencoded.max).isNotNull(); - assertThat(geoencoded.min).isNotNull(); - assertThat(geoencoded.avg).isNotNull(); - } - - @Test - public void geoencoded() throws Exception { - - GeoEncoded geoencoded = redis.geodecode(3666615932941099L); - - assertThat(geoencoded.geohash).isEqualTo(3666615932941099L); - assertThat(geoencoded.min.x.doubleValue()).isEqualTo(8.6638730764389038, offset(1d)); - assertThat(geoencoded.min.y.doubleValue()).isEqualTo(49.528251210511513, offset(1d)); - - assertThat(geoencoded.max.x.doubleValue()).isEqualTo(8.6638784408569336, offset(1d)); - assertThat(geoencoded.max.y.doubleValue()).isEqualTo(49.528253745232675, offset(1d)); - - assertThat(geoencoded.avg.x.doubleValue()).isEqualTo(8.6638757586479187, offset(1d)); - assertThat(geoencoded.avg.y.doubleValue()).isEqualTo(49.528252477872094, offset(1d)); - - } }