Add COUNT and ASC/DESC support to RGeo.radius methods #662

pull/665/head
Nikita 8 years ago
parent 47743daf03
commit ee690f5ced

@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import org.redisson.api.GeoEntry;
import org.redisson.api.GeoOrder;
import org.redisson.api.GeoPosition;
import org.redisson.api.GeoUnit;
import org.redisson.api.RFuture;
@ -146,6 +147,39 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS, getName(), convert(longitude), convert(latitude), radius, geoUnit);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "COUNT", count);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, geoOrder);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "COUNT", count, geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit) {
@ -155,7 +189,44 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", distanceDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude), radius, geoUnit, "WITHDIST");
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST");
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", distanceDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", "COUNT", count);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", distanceDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", distanceDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
}
@Override
@ -168,6 +239,42 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", postitionDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude), radius, geoUnit, "WITHCOORD");
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", postitionDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", "COUNT", count);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", postitionDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUS", postitionDecoder);
return commandExecutor.readAsync(getName(), codec, command, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit) {
@ -179,6 +286,36 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER, getName(), member, radius, geoUnit);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER, getName(), member, radius, geoUnit, "COUNT", count);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER, getName(), member, radius, geoUnit, geoOrder);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER, getName(), member, radius, geoUnit, "COUNT", count, geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit) {
return get(radiusWithDistanceAsync(member, radius, geoUnit));
@ -190,6 +327,39 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHDIST");
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, int count) {
RedisCommand command = new RedisCommand("GEORADIUSBYMEMBER", distanceDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHDIST", "COUNT", count);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
RedisCommand command = new RedisCommand("GEORADIUSBYMEMBER", distanceDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHDIST", geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
RedisCommand command = new RedisCommand("GEORADIUSBYMEMBER", distanceDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit) {
return get(radiusWithPositionAsync(member, radius, geoUnit));
@ -200,4 +370,38 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER", postitionDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHCOORD");
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithPositionAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER", postitionDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHCOORD", "COUNT", count);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithPositionAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER", postitionDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHCOORD", geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusWithPositionAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER", postitionDecoder, 2);
return commandExecutor.readAsync(getName(), codec, command, getName(), member, radius, geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
}
}

@ -15,6 +15,11 @@
*/
package org.redisson.api;
/**
*
* @author Nikita Koksharov
*
*/
public class GeoEntry {
private final double longitude;

@ -0,0 +1,25 @@
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.api;
/**
*
* @author Nikita Koksharov
*
*/
public enum GeoOrder {
ASC, DESC
}

@ -15,6 +15,11 @@
*/
package org.redisson.api;
/**
*
* @author Nikita Koksharov
*
*/
public class GeoPosition {
private final double longitude;

@ -15,6 +15,11 @@
*/
package org.redisson.api;
/**
*
* @author Nikita Koksharov
*
*/
public enum GeoUnit {
METERS {

@ -89,6 +89,53 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
*/
List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return list of objects
*/
List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @return list of objects
*/
List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @param count - result limit
* @return list of objects
*/
List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
@ -104,6 +151,56 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
*/
Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count.
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @param count - result limit
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
@ -119,6 +216,56 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
*/
Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
@ -132,6 +279,50 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
*/
List<V> radius(V member, double radius, GeoUnit geoUnit);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return list of objects
*/
List<V> radius(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return list of objects
*/
List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return list of objects
*/
List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
@ -146,6 +337,53 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
*/
Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return distance mapped by object
*/
Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
@ -159,5 +397,52 @@ public interface RGeo<V> extends RScoredSortedSet<V>, RGeoAsync<V> {
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return geo position mapped by object
*/
Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
}

@ -87,6 +87,53 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @return list of objects
*/
RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return list of objects
*/
RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @return list of objects
*/
RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @param count - result limit
* @return list of objects
*/
RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the distance mapped by member, distance between member and the location.
@ -103,6 +150,56 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count.
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the distance mapped by member, distance between member and the location.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - order of result
* @param count - result limit
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
@ -117,6 +214,56 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the center location
* and the maximum distance from the center (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param longitude - longitude of object
* @param latitude - latitude of object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the members of a sorted set, which are within the
@ -130,6 +277,49 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @return list of objects
*/
RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return list of objects
*/
RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return list of objects
*/
RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return list of objects
*/
RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
@ -145,6 +335,52 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the distance mapped by member, distance between member and the defined member location.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo
* @return distance mapped by object
*/
RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
@ -158,5 +394,52 @@ public interface RGeoAsync<V> extends RScoredSortedSetAsync<V> {
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param count - result limit
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, int count);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder);
/**
* Returns the geo-position mapped by member.
* Members of a sorted set, which are within the
* borders of the area specified with the defined member location
* and the maximum distance from the defined member location (the radius)
* in <code>GeoUnit</code> units with <code>GeoOrder</code>
* and limited by count
*
* @param member - object
* @param radius - radius in geo units
* @param geoUnit - geo unit
* @param geoOrder - geo order
* @param count - result limit
* @return geo position mapped by object
*/
RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count);
}

@ -39,13 +39,10 @@ import org.redisson.client.protocol.convertor.TrueReplayConvertor;
import org.redisson.client.protocol.convertor.TypeConvertor;
import org.redisson.client.protocol.convertor.VoidReplayConvertor;
import org.redisson.client.protocol.decoder.ClusterNodesDecoder;
import org.redisson.client.protocol.decoder.FlatNestedMultiDecoder;
import org.redisson.client.protocol.decoder.KeyValueObjectDecoder;
import org.redisson.client.protocol.decoder.ListMultiDecoder;
import org.redisson.client.protocol.decoder.ListResultReplayDecoder;
import org.redisson.client.protocol.decoder.ListScanResult;
import org.redisson.client.protocol.decoder.ListScanResultReplayDecoder;
import org.redisson.client.protocol.decoder.LongMultiDecoder;
import org.redisson.client.protocol.decoder.MapScanResult;
import org.redisson.client.protocol.decoder.MapScanResultReplayDecoder;
import org.redisson.client.protocol.decoder.NestedMultiDecoder;

@ -15,7 +15,7 @@
*/
package org.redisson.client.protocol.decoder;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -32,7 +32,7 @@ public class GeoMapReplayDecoder implements MultiDecoder<Map<Object, Object>> {
@Override
public Map<Object, Object> decode(List<Object> parts, State state) {
Map<Object, Object> result = new HashMap<Object, Object>(parts.size());
Map<Object, Object> result = new LinkedHashMap<Object, Object>(parts.size());
for (Object object : parts) {
List<Object> vals = ((List<Object>) object);
result.put(vals.get(0), vals.get(1));

@ -1,16 +1,17 @@
package org.redisson;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
import org.redisson.api.GeoEntry;
import org.redisson.api.GeoOrder;
import org.redisson.api.GeoPosition;
import org.redisson.api.GeoUnit;
import org.redisson.api.RGeo;
@ -101,6 +102,32 @@ public class RedissonGeoTest extends BaseTest {
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
}
@Test
public void testRadiusCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS, 1)).containsExactly("Catania");
}
@Test
public void testRadiusOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC)).containsExactly("Palermo", "Catania");
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC)).containsExactly("Catania", "Palermo");
}
@Test
public void testRadiusOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).containsExactly("Palermo");
assertThat(geo.radius(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).containsExactly("Catania");
}
@Test
public void testRadiusEmpty() {
RGeo<String> geo = redisson.getGeo("test");
@ -118,7 +145,52 @@ public class RedissonGeoTest extends BaseTest {
expected.put("Catania", 56.4413);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusWithDistanceCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> expected = new HashMap<String, Double>();
expected.put("Catania", 56.4413);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, 1)).isEqualTo(expected);
}
@Test
public void testRadiusWithDistanceOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
descExpected.put("Palermo", 190.4424);
descExpected.put("Catania", 56.4413);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet())
.containsExactlyElementsOf(descExpected.entrySet());
Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
ascExpected.put("Catania", 56.4413);
ascExpected.put("Palermo", 190.4424);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet())
.containsExactlyElementsOf(ascExpected.entrySet());
}
@Test
public void testRadiusWithDistanceOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
descExpected.put("Palermo", 190.4424);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet())
.containsExactlyElementsOf(descExpected.entrySet());
Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
ascExpected.put("Catania", 56.4413);
assertThat(geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet())
.containsExactlyElementsOf(ascExpected.entrySet());
}
@Test
public void testRadiusWithDistanceHugeAmount() {
RGeo<String> geo = redisson.getGeo("test");
@ -191,6 +263,49 @@ public class RedissonGeoTest extends BaseTest {
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusWithPositionCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(expected.entrySet().removeAll(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
assertThat(expected).hasSize(1);
}
@Test
public void testRadiusWithPositionOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
}
@Test
public void testRadiusWithPositionOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
}
@Test
public void testRadiusWithPositionEmpty() {
@ -207,6 +322,33 @@ public class RedissonGeoTest extends BaseTest {
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS)).containsExactly("Palermo", "Catania");
}
@Test
public void testRadiusMemberCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, 1)).containsExactly("Palermo");
}
@Test
public void testRadiusMemberOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC)).containsExactly("Catania", "Palermo");
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC)).containsExactly("Palermo", "Catania");
}
@Test
public void testRadiusMemberOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1)).containsExactly("Catania");
assertThat(geo.radius("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1)).containsExactly("Palermo");
}
@Test
public void testRadiusMemberEmpty() {
RGeo<String> geo = redisson.getGeo("test");
@ -225,6 +367,48 @@ public class RedissonGeoTest extends BaseTest {
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusMemberWithDistanceCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> expected = new HashMap<String, Double>();
expected.put("Palermo", 0.0);
expected.put("Catania", 166.2742);
assertThat(expected.entrySet().removeAll(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
assertThat(expected).hasSize(1);
}
@Test
public void testRadiusMemberWithDistanceOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
ascExpected.put("Palermo", 0.0);
ascExpected.put("Catania", 166.2742);
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
descExpected.put("Catania", 166.2742);
descExpected.put("Palermo", 0.0);
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
@Test
public void testRadiusMemberWithDistanceOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, Double> ascExpected = new LinkedHashMap<String, Double>();
ascExpected.put("Palermo", 0.0);
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
Map<String, Double> descExpected = new LinkedHashMap<String, Double>();
descExpected.put("Catania", 166.2742);
assertThat(geo.radiusWithDistance("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
@Test
public void testRadiusMemberWithDistanceEmpty() {
RGeo<String> geo = redisson.getGeo("test");
@ -242,6 +426,48 @@ public class RedissonGeoTest extends BaseTest {
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS)).isEqualTo(expected);
}
@Test
public void testRadiusMemberWithPositionCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> expected = new HashMap<String, GeoPosition>();
expected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
expected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(expected.entrySet().removeAll(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, 1).entrySet())).isTrue();
assertThat(expected).hasSize(1);
}
@Test
public void testRadiusMemberWithPositionOrder() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
ascExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
descExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
@Test
public void testRadiusMemberWithPositionOrderCount() {
RGeo<String> geo = redisson.getGeo("test");
geo.add(new GeoEntry(13.361389, 38.115556, "Palermo"), new GeoEntry(15.087269, 37.502669, "Catania"));
Map<String, GeoPosition> ascExpected = new LinkedHashMap<String, GeoPosition>();
ascExpected.put("Palermo", new GeoPosition(13.361389338970184, 38.115556395496299));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.ASC, 1).entrySet()).containsExactlyElementsOf(ascExpected.entrySet());
Map<String, GeoPosition> descExpected = new LinkedHashMap<String, GeoPosition>();
descExpected.put("Catania", new GeoPosition(15.087267458438873, 37.50266842333162));
assertThat(geo.radiusWithPosition("Palermo", 200, GeoUnit.KILOMETERS, GeoOrder.DESC, 1).entrySet()).containsExactlyElementsOf(descExpected.entrySet());
}
@Test
public void testRadiusMemberWithPositionEmpty() {

Loading…
Cancel
Save