@Override public Distance convert(Object obj) { return new Distance((Double)obj, metric); }
@Override public Distance convert(Object obj) { return new Distance((Double)obj, metric); }
@Override public Distance convert(Object obj) { return new Distance((Double)obj, metric); }
/** * Creates a Sphere around the given center {@link Point} with the given radius. * * @param center * @param radius */ public Sphere(Point center, double radius) { this(center, new Distance(radius)); }
@Override public Distance convert(Double source) { return new Distance(source, metric); } }
@Override public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, double radius) { return geoRadiusByMember(key, member, new Distance(radius, DistanceUnit.METERS)); }
@Override public GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, double radius) { return geoRadiusByMember(key, member, new Distance(radius, DistanceUnit.METERS)); }
/** * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#FEET}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#FEET}. */ public static GeoRadiusByMemberCommand withinFeet(double distance) { return within(new Distance(distance, DistanceUnit.FEET)); }
/** * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#METERS}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#METERS}. */ public static GeoRadiusCommand withinMeters(double distance) { return within(new Distance(distance, DistanceUnit.METERS)); }
/** * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#FEET}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#FEET}. */ public static GeoRadiusCommand withinFeet(double distance) { return within(new Distance(distance, DistanceUnit.FEET)); }
/** * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#MILES}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#MILES}. */ public static GeoRadiusByMemberCommand withinMiles(double distance) { return within(new Distance(distance, DistanceUnit.MILES)); }
/** * Sets the maximum distance supplied in a given metric. Will normalize the distance but not reconfigure the query's * result {@link Metric} if one was configured before. * * @param maxDistance * @param metric must not be {@literal null}. * @return */ public NearQuery maxDistance(double maxDistance, Metric metric) { Assert.notNull(metric, "Metric must not be null!"); return maxDistance(new Distance(maxDistance, metric)); }
/** * Creates a new {@link GeoRadiusCommand} given a {@literal distance} in {@link DistanceUnit#MILES}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusCommand} for a {@literal distance} in {@link DistanceUnit#MILES}. */ public static GeoRadiusCommand withinMiles(double distance) { return within(new Distance(distance, DistanceUnit.MILES)); }
/** * Creates a new {@link GeoRadiusByMemberCommand} given a {@literal distance} in {@link DistanceUnit#KILOMETERS}. * * @param distance must not be {@literal null}. * @return a new {@link GeoRadiusByMemberCommand} for a {@literal distance} in {@link DistanceUnit#KILOMETERS}. */ public static GeoRadiusByMemberCommand withinKiometers(double distance) { return within(new Distance(distance, DistanceUnit.KILOMETERS)); }
@Override public GeoResults<GeoLocation<byte[]>> decode(List<Object> parts, State state) { List<GeoResult<GeoLocation<byte[]>>> result = new ArrayList<GeoResult<GeoLocation<byte[]>>>(); for (Object object : parts) { if (object instanceof List) { List<Object> vals = ((List<Object>) object); if (metric != null) { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), null); result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance((Double)vals.get(1), metric))); } else { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), (Point)vals.get(1)); result.add(new GeoResult<GeoLocation<byte[]>>(location, null)); } } else { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])object, null); result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance(0))); } } return new GeoResults<GeoLocation<byte[]>>(result); }
@Override public GeoResults<GeoLocation<byte[]>> decode(List<Object> parts, State state) { List<GeoResult<GeoLocation<byte[]>>> result = new ArrayList<GeoResult<GeoLocation<byte[]>>>(); for (Object object : parts) { if (object instanceof List) { List<Object> vals = ((List<Object>) object); if (metric != null) { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), null); result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance((Double)vals.get(1), metric))); } else { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])vals.get(0), (Point)vals.get(1)); result.add(new GeoResult<GeoLocation<byte[]>>(location, null)); } } else { GeoLocation<byte[]> location = new GeoLocation<byte[]>((byte[])object, null); result.add(new GeoResult<GeoLocation<byte[]>>(location, new Distance(0))); } } return new GeoResults<GeoLocation<byte[]>>(result); }
@Nullable public GeoResult<T> doWith(@Nullable Document object) { double distance = ((Double) object.get("dis")).doubleValue(); Document content = (Document) object.get("obj"); T doWith = delegate.doWith(content); return new GeoResult<>(doWith, new Distance(distance, metric)); } }
public GeoResult<T> doWith(Document object) { double distance = (Double) object.get("dis"); Document content = (Document) object.get("obj"); T doWith = delegate.doWith(content); return new GeoResult<>(doWith, new Distance(distance, metric)); } }
@Override public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, double radius) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(member, "Member must not be null!"); return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) // .map(this::readGeoResult)); }
private Converter<GeoWithin<ByteBuffer>, GeoResult<GeoLocation<ByteBuffer>>> converter(Metric metric) { return (source) -> { Point point = LettuceConverters.geoCoordinatesToPoint(source.getCoordinates()); return new GeoResult<>(new GeoLocation<>(source.getMember(), point), new Distance(source.getDistance() != null ? source.getDistance() : 0D, metric)); }; } }