org.hibernate.search.spatial.impl

## Class SpatialHelper

- java.lang.Object
- - org.hibernate.search.spatial.impl.SpatialHelper

-     public abstract class SpatialHelper
      extends Object

  Spatial fields, ids generator and geometric calculation methods for use in SpatialFieldBridge
  Author:
    Nicolas Helleringer, Mathieu Perez
  See Also:
    `SpatialFieldBridgeByHash`, `SpatialFieldBridgeByRange`

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `findBestSpatialHashLevelForSearchRange(double searchRange)` If point are searched at d distance from a point, a certain spatial hash cell level will problem spatial hash cell that are big enough to contain the search area but the smallest possible.
    `static String` | `formatFieldName(int spatialHashLevel, String fieldName)`
    `static String` | `formatLatitude(String fieldName)`
    `static String` | `formatLongitude(String fieldName)`
    `static String` | `formatSpatialHashCellId(int xIndex, int yIndex)`
    `static int` | `getCellIndex(double coordinate, double range, int spatialHashLevel)` Generate a Cell Index on one axis
    `static String` | `getSpatialHashCellId(Point point, int spatialHashLevel)` Generate a spatial hash cell id (with both cell index on both dimension in it) for a position
    `static List<String>` | `getSpatialHashCellsIds(Coordinates center, double radius, int spatialHashLevel)` Generate a spatial hash cell ids list for the bounding box of a circular search area
    `static List<String>` | `getSpatialHashCellsIds(Point lowerLeft, Point upperRight, int spatialHashLevel)` Generate a spatial hash cell ids list covered by a bounding box
    `static boolean` | `isSpatialField(String fieldName)`
    `static boolean` | `isSpatialFieldLatitude(String fieldName)`
    `static boolean` | `isSpatialFieldLongitude(String fieldName)`
    `static double[]` | `projectToIndexSpace(Point point)` Project a degree latitude/longitude point into a sinusoidal projection planar space for spatial hash cell ids computation
    `static String` | `stripSpatialFieldSuffix(String fieldName)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getCellIndex

          public static int getCellIndex(double coordinate,
                                         double range,
                                         int spatialHashLevel)

      Generate a Cell Index on one axis
      Parameters:
        `coordinate` - position to compute the Index for
        `range` - range of the axis (-pi,pi)/(-90,90) => 2*pi/180 e.g
        `spatialHashLevel` - Hox many time the range has been split in two
      Returns:
        the cell index on the axis

    - #### getSpatialHashCellId

          public static String getSpatialHashCellId(Point point,
                                                    int spatialHashLevel)

      Generate a spatial hash cell id (with both cell index on both dimension in it) for a position
      Parameters:
        `point` - position to compute the spatial hash cell id for
        `spatialHashLevel` - Hox many time the dimensions have been split in two
      Returns:
        the cell id for the point at the given spatial hash level

    - #### getSpatialHashCellsIds

          public static List<String> getSpatialHashCellsIds(Point lowerLeft,
                                                            Point upperRight,
                                                            int spatialHashLevel)

      Generate a spatial hash cell ids list covered by a bounding box
      Parameters:
        `lowerLeft` - lower left corner of the bounding box
        `upperRight` - upper right corner of the bounding box
        `spatialHashLevel` - spatial hash level of the wanted cell ids
      Returns:
        List of ids of the cells containing the point

    - #### getSpatialHashCellsIds

          public static List<String> getSpatialHashCellsIds(Coordinates center,
                                                            double radius,
                                                            int spatialHashLevel)

      Generate a spatial hash cell ids list for the bounding box of a circular search area
      Parameters:
        `center` - center of the search area
        `radius` - radius of the search area
        `spatialHashLevel` - spatial hash level of the wanted cell ids
      Returns:
        List of the ids of the cells covering the bounding box of the given search discus

    - #### findBestSpatialHashLevelForSearchRange

          public static int findBestSpatialHashLevelForSearchRange(double searchRange)

      If point are searched at d distance from a point, a certain spatial hash cell level will problem spatial hash cell that are big enough to contain the search area but the smallest possible. By returning this level we ensure 4 spatial hash cell maximum will be needed to cover the search area (2 max on each axis because of search area crossing fixed bonds of the spatial hash cells)
      Parameters:
        `searchRange` - search range to be covered by the spatial hash cells
      Returns:
        Return the best spatial hash level for a given search radius.

    - #### projectToIndexSpace

          public static double[] projectToIndexSpace(Point point)

      Project a degree latitude/longitude point into a sinusoidal projection planar space for spatial hash cell ids computation
      Parameters:
        `point` - point to be projected
      Returns:
        array of projected coordinates

    - #### formatFieldName

          public static String formatFieldName(int spatialHashLevel,
                                               String fieldName)

    - #### formatLatitude

          public static String formatLatitude(String fieldName)

    - #### formatLongitude

          public static String formatLongitude(String fieldName)

    - #### isSpatialField

          public static boolean isSpatialField(String fieldName)

    - #### isSpatialFieldLatitude

          public static boolean isSpatialFieldLatitude(String fieldName)

    - #### isSpatialFieldLongitude

          public static boolean isSpatialFieldLongitude(String fieldName)

    - #### stripSpatialFieldSuffix

          public static String stripSpatialFieldSuffix(String fieldName)

    - #### formatSpatialHashCellId

          public static String formatSpatialHashCellId(int xIndex,
                                                       int yIndex)

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved