
io.lettuce.core.GeoSearch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lettuce-core Show documentation
Show all versions of lettuce-core Show documentation
Advanced and thread-safe Java Redis client for synchronous, asynchronous, and
reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs
and much more.
The newest version!
package io.lettuce.core;
import io.lettuce.core.internal.LettuceAssert;
import io.lettuce.core.protocol.CommandArgs;
/**
* Utility to create {@link GeoPredicate} and {@link GeoRef} objects to be used with {@code GEOSEARCH}.
*
* @author Mark Paluch
* @since 6.1
*/
public final class GeoSearch {
// TODO: Should be V
/**
* Create a {@link GeoRef} from a Geo set {@code member}.
*
* @param member the Geo set member to use as search reference starting point.
* @return the {@link GeoRef}.
*/
public static GeoRef fromMember(K member) {
LettuceAssert.notNull(member, "Reference member must not be null");
return new FromMember<>(member);
}
/**
* Create a {@link GeoRef} from WGS84 coordinates {@code longitude} and {@code latitude}.
*
* @param longitude the longitude coordinate according to WGS84.
* @param latitude the latitude coordinate according to WGS84.
* @return the {@link GeoRef}.
*/
public static GeoRef fromCoordinates(double longitude, double latitude) {
return (GeoRef) new FromCoordinates(longitude, latitude);
}
/**
* Create a {@link GeoPredicate} by specifying a radius {@code distance} and {@link GeoArgs.Unit}.
*
* @param distance the radius.
* @param unit size unit.
* @return the {@link GeoPredicate} for the specified radius.
*/
public static GeoPredicate byRadius(double distance, GeoArgs.Unit unit) {
return new Radius(distance, unit);
}
/**
* Create a {@link GeoPredicate} by specifying a box of the size {@code width}, {@code height} and {@link GeoArgs.Unit}.
*
* @param width box width.
* @param height box height.
* @param unit size unit.
* @return the {@link GeoPredicate} for the specified box.
*/
public static GeoPredicate byBox(double width, double height, GeoArgs.Unit unit) {
return new Box(width, height, unit);
}
/**
* Geo reference specifying a search starting point.
*
* @param
*/
public interface GeoRef extends CompositeArgument {
}
static class FromMember implements GeoRef {
final K member;
public FromMember(K member) {
this.member = member;
}
@Override
@SuppressWarnings("unchecked")
public void build(CommandArgs args) {
args.add("FROMMEMBER").addKey((K) member);
}
}
static class FromCoordinates implements GeoRef
© 2015 - 2025 Weber Informatics LLC | Privacy Policy