/** * Returns the center of the {@link Circle}. * * @return will never be {@literal null}. */ public Point getCenter() { return new Point(this.center); }
@Override public Point decode(List<Object> parts, State state) { if (parts.isEmpty()) { return null; } Double longitude = (Double)parts.get(0); Double latitude = (Double)parts.get(1); return new Point(longitude, latitude); }
@Override public Point decode(List<Object> parts, State state) { if (parts.isEmpty()) { return null; } Double longitude = (Double)parts.get(0); Double latitude = (Double)parts.get(1); return new Point(longitude, latitude); }
@Override public Point decode(List<Object> parts, State state) { if (parts.isEmpty()) { return null; } Double longitude = (Double)parts.get(0); Double latitude = (Double)parts.get(1); return new Point(longitude, latitude); }
/** * Creates a new {@link NearQuery} starting at the given coordinates using the given {@link Metric} to adapt given * values to further configuration. E.g. setting a {@link #maxDistance(double)} will be interpreted as a value of the * initially set {@link Metric}. * * @param x * @param y * @param metric must not be {@literal null}. * @return */ public static NearQuery near(double x, double y, Metric metric) { return near(new Point(x, y), metric); }
/** * Get the {@link Point} representation of given {@link ArrayNode} assuming {@code node.[0]} represents * {@literal x - coordinate} and {@code node.[1]} is {@literal y}. * * @param node can be {@literal null}. * @return {@literal null} when given a {@code null} value. */ @Nullable protected Point toPoint(@Nullable ArrayNode node) { if (node == null) { return null; } return new Point(node.get(0).asDouble(), node.get(1).asDouble()); }
public static Point toPoint(GeoPoint point) { return new Point(point.getLat(), point.getLon()); } }
@Override public Point convert(Document source) { if (source == null) { return null; } Assert.isTrue(source.keySet().size() == 2, "Source must contain 2 elements"); if (source.containsKey("type")) { return DocumentToGeoJsonPointConverter.INSTANCE.convert(source); } return new Point(toPrimitiveDoubleValue(source.get("x")), toPrimitiveDoubleValue(source.get("y"))); } }
public Point getGeoNearLocation() { int nearIndex = method.getParameters().getNearIndex(); if (nearIndex == -1) { return null; } Object value = getValue(nearIndex); if (value == null) { return null; } if (value instanceof double[]) { double[] typedValue = (double[]) value; if (typedValue.length != 2) { throw new IllegalArgumentException("The given double[] must have exactly 2 elements!"); } else { return new Point(typedValue[0], typedValue[1]); } } return (Point) value; }
lineMapper.setFieldSetMapper(fields -> { Point location = new Point(fields.readDouble("Longitude"), fields.readDouble("Latitude")); Address address = new Address(fields.readString("Street Address"), fields.readString("City"), fields.readString("Zip"), location);
/** * Returns the center of the {@link Circle}. * * @return will never be {@literal null}. */ public Point getCenter() { return new Point(this.center); }
@Override public Point toEntityAttribute(Map<String, ?> map) { Double latitude = (Double) map.get("latitude"); Double longitude = (Double) map.get("longitude"); if (latitude != null && longitude != null) { return new Point(latitude, longitude); } return null; }
/** * Creates a new {@link NearQuery} starting at the given coordinates using the given {@link Metric} to adapt given * values to further configuration. E.g. setting a {@link #maxDistance(double)} will be interpreted as a value of the * initially set {@link Metric}. * * @param x * @param y * @param metric must not be {@literal null}. * @return */ public static NearQuery near(double x, double y, Metric metric) { return near(new Point(x, y), metric); }
/** * Get the {@link Point} representation of given {@link ArrayNode} assuming {@code node.[0]} represents * {@literal x - coordinate} and {@code node.[1]} is {@literal y}. * * @param node can be {@literal null}. * @return {@literal null} when given a {@code null} value. */ @Nullable protected Point toPoint(@Nullable ArrayNode node) { if (node == null) { return null; } return new Point(node.get(0).asDouble(), node.get(1).asDouble()); }
@Override public Point convert(Document source) { if (source == null) { return null; } Assert.isTrue(source.keySet().size() == 2, "Source must contain 2 elements"); if (source.containsKey("type")) { return DocumentToGeoJsonPointConverter.INSTANCE.convert(source); } return new Point(toPrimitiveDoubleValue(source.get("x")), toPrimitiveDoubleValue(source.get("y"))); } }
public Point getGeoNearLocation() { int nearIndex = method.getParameters().getNearIndex(); if (nearIndex == -1) { return null; } Object value = getValue(nearIndex); if (value == null) { return null; } if (value instanceof double[]) { double[] typedValue = (double[]) value; if (typedValue.length != 2) { throw new IllegalArgumentException("The given double[] must have exactly 2 elements!"); } else { return new Point(typedValue[0], typedValue[1]); } } return (Point) value; }
@Override public Point toEntityAttribute(Map<String, ?> map) { Double latitude = (Double) map.get("latitude"); Double longitude = (Double) map.get("longitude"); if (latitude != null && longitude != null) { return new Point(latitude, longitude); } return null; }
@Override public org.springframework.data.geo.Point convert(String source) { String[] coordinates = source.split(","); return new org.springframework.data.geo.Point(Double.parseDouble(coordinates[0]), Double.parseDouble(coordinates[1])); }
/** * @param latitude * @param longitude * @return */ public static GeoHashFunction geohash(double latitude, double longitude) { return geohash(new Point(latitude, longitude)); }
/** * @param latitude * @param longitude * @return */ public GeoDistanceFunction to(double latitude, double longitude) { return to(new Point(latitude, longitude)); }