Class GeoUtils
java.lang.Object
org.springframework.data.couchbase.repository.query.support.GeoUtils
Utility class to deal with geo/dimensional indexed data and queries.
- Author:
- Simon Baslé
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertPointsTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, boolean isBoundingBox, Point... points) Convert a sequence ofPointsdescribing a polygon to a pair ofJsonArrayranges corresponding to that polygon's bounding box, and inject the coordinates into startRange and endRange.static voidconvertShapeTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, Shape shape) Convert aShapeto a pair ofJsonArrayranges, injected into startRange and endRange.static double[]getBoundingBoxForNear(Point origin, Distance distance) Computes the bounding box approximation for a "near" query (max distance from a point of origin).
-
Constructor Details
-
GeoUtils
public GeoUtils()
-
-
Method Details
-
getBoundingBoxForNear
Computes the bounding box approximation for a "near" query (max distance from a point of origin).- Parameters:
origin- the point of origin, center for the query.distance- the max distance to search within (negative distances will be multiplied by -1).- Returns:
- the bounding box approximation for this query ([xMin, yMin, xMax, yMax]).
- Throws:
NullPointerException- if any of the origin and distance are null
-
convertPointsTo2DRanges
public static void convertPointsTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, boolean isBoundingBox, Point... points) Convert a sequence ofPointsdescribing a polygon to a pair ofJsonArrayranges corresponding to that polygon's bounding box, and inject the coordinates into startRange and endRange. If it is already equivalent to a Box (upper-left Point + lower-right Point), set isBoundingBox to true. Otherwise, this method will attempt to find the bounding box by finding the lowest and highest X and Y coordinates.- Parameters:
startRange- the startRange to populate with this shape's data.endRange- the endRange to populate with this shape's data.isBoundingBox- true to skip finding min/max X and Y coordinates and use 2 Points as aBox.points- the sequence of Points.- Throws:
IllegalArgumentException- if no points are provided, or in the case of isBoundingBox true if more or less than 2 points are provided or the 2 points are not ordered (a.x <= b.x && a.y <= b.y).
-
convertShapeTo2DRanges
public static void convertShapeTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, Shape shape) Convert aShapeto a pair ofJsonArrayranges, injected into startRange and endRange.- Parameters:
startRange- the startRange to populate with this shape's data.endRange- the endRange to populate with this shape's data.shape- the shape to extract ranges from.- Throws:
IllegalArgumentException- if theShapeis unsupported.
-