/** * return a {@link org.springframework.data.elasticsearch.core.geo.GeoBox} * from a {@link org.springframework.data.geo.Box}. * * @param box {@link org.springframework.data.geo.Box} to use * @return a {@link org.springframework.data.elasticsearch.core.geo.GeoBox} */ public static GeoBox fromBox(Box box) { GeoPoint topLeft = GeoPoint.fromPoint(box.getFirst()); GeoPoint bottomRight = GeoPoint.fromPoint(box.getSecond()); return new GeoBox(topLeft, bottomRight); } }
@Override public Box convert(Document source) { if (source == null) { return null; } Point first = DocumentToPointConverter.INSTANCE.convert((Document) source.get("first")); Point second = DocumentToPointConverter.INSTANCE.convert((Document) source.get("second")); return new Box(first, second); } }
@Override public Document convert(Box source) { if (source == null) { return null; } Document result = new Document(); result.put("first", PointToDocumentConverter.INSTANCE.convert(source.getFirst())); result.put("second", PointToDocumentConverter.INSTANCE.convert(source.getSecond())); return result; } }
@Override public Box convert(Document source) { if (source == null) { return null; } Point first = DocumentToPointConverter.INSTANCE.convert((Document) source.get("first")); Point second = DocumentToPointConverter.INSTANCE.convert((Document) source.get("second")); return new Box(first, second); } }
@Override public Document convert(Box source) { if (source == null) { return null; } Document result = new Document(); result.put("first", PointToDocumentConverter.INSTANCE.convert(source.getFirst())); result.put("second", PointToDocumentConverter.INSTANCE.convert(source.getSecond())); return result; } }
public int bindBox(final Object value, final boolean shouldIgnoreCase, final int startIndex) { int index = startIndex; final Box box = (Box) ignoreArgumentCase(value, shouldIgnoreCase); final Point first = box.getFirst(); final Point second = box.getSecond(); final double minLatitude = Math.min(first.getY(), second.getY()); final double maxLatitude = Math.max(first.getY(), second.getY()); final double minLongitude = Math.min(first.getX(), second.getX()); final double maxLongitude = Math.max(first.getX(), second.getX()); bind(index++, minLatitude); bind(index++, maxLatitude); bind(index++, minLongitude); bind(index++, maxLongitude); return index; }
public int bindBox(final Object value, final boolean shouldIgnoreCase, final int startIndex) { int index = startIndex; final Box box = (Box) ignoreArgumentCase(value, shouldIgnoreCase); final Point first = box.getFirst(); final Point second = box.getSecond(); final double minLatitude = Math.min(first.getY(), second.getY()); final double maxLatitude = Math.max(first.getY(), second.getY()); final double minLongitude = Math.min(first.getX(), second.getX()); final double maxLongitude = Math.max(first.getX(), second.getX()); bind(index++, minLatitude); bind(index++, maxLatitude); bind(index++, minLongitude); bind(index++, maxLongitude); return index; }