java.lang.Object
org.springframework.data.couchbase.repository.query.support.GeoUtils

public class GeoUtils extends Object
Utility class to deal with geo/dimensional indexed data and queries.
Author:
Simon Baslé
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    convertPointsTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, boolean isBoundingBox, Point... points)
    Convert a sequence of Points describing a polygon to a pair of JsonArray ranges corresponding to that polygon's bounding box, and inject the coordinates into startRange and endRange.
    static void
    convertShapeTo2DRanges(com.couchbase.client.java.json.JsonArray startRange, com.couchbase.client.java.json.JsonArray endRange, Shape shape)
    Convert a Shape to a pair of JsonArray ranges, injected into startRange and endRange.
    static double[]
    Computes the bounding box approximation for a "near" query (max distance from a point of origin).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GeoUtils

      public GeoUtils()
  • Method Details

    • getBoundingBoxForNear

      public static double[] getBoundingBoxForNear(Point origin, Distance distance)
      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 of Points describing a polygon to a pair of JsonArray ranges 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 a Box.
      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 a Shape to a pair of JsonArray ranges, 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 the Shape is unsupported.