org.hibernate.search.spatial.impl
Class SpatialHelper

java.lang.Object
  extended by 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:
SpatialFieldBridgeByQuadTree, SpatialFieldBridgeByRange

Method Summary
static int findBestQuadTreeLevelForSearchRange(double searchRange)
          If point are searched at d distance from a point, a certain quad tree cell level will problem quad tree cell that are big enough to contain the search area but the smallest possible.
static String formatFieldName(int quadTreeLevel, String fieldName)
           
static String formatLatitude(String fieldName)
           
static String formatLongitude(String fieldName)
           
static String formatQuadTreeCellId(int xIndex, int yIndex)
           
static int getCellIndex(double coordinate, double range, int quadTreeLevel)
          Generate a Cell Index on one axis
static String getQuadTreeCellId(Point point, int quadTreeLevel)
          Generate a Quad Tree Cell Id (with both Cell Index on both dimension in it) for a position
static List<String> getQuadTreeCellsIds(Point center, double radius, int quadTreeLevel)
          Generate a Quad Tree Cell Ids List for the bounding box of a circular search area
static List<String> getQuadTreeCellsIds(Point lowerLeft, Point upperRight, int quadTreeLevel)
          Generate a Quad Tree Cell Ids List covered by a bounding box
static double[] projectToIndexSpace(Point point)
          Project a degree latitude/longitude point into a sinusoidal projection planar space for quad tree cell ids computation
 
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 quadTreeLevel)
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
quadTreeLevel - Hox many time the range has been split in two
Returns:
the cell index on the axis

getQuadTreeCellId

public static String getQuadTreeCellId(Point point,
                                       int quadTreeLevel)
Generate a Quad Tree Cell Id (with both Cell Index on both dimension in it) for a position

Parameters:
point - position to compute the Quad Tree Cell Id for
quadTreeLevel - Hox many time the dimensions have been split in two
Returns:
the cell id for the point at the given quad tree level

getQuadTreeCellsIds

public static List<String> getQuadTreeCellsIds(Point lowerLeft,
                                               Point upperRight,
                                               int quadTreeLevel)
Generate a Quad Tree 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
quadTreeLevel - quad tree level of the wanted cell ids
Returns:
List of ids of the cells containing the point

getQuadTreeCellsIds

public static List<String> getQuadTreeCellsIds(Point center,
                                               double radius,
                                               int quadTreeLevel)
Generate a Quad Tree 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
quadTreeLevel - Quad Tree level of the wanted cell ids
Returns:
List of the ids of the cells covering the bounding box of the given search discus

findBestQuadTreeLevelForSearchRange

public static int findBestQuadTreeLevelForSearchRange(double searchRange)
If point are searched at d distance from a point, a certain quad tree cell level will problem quad tree cell that are big enough to contain the search area but the smallest possible. By returning this level we ensure 4 Quad Tree Cell maximum will be needed to cover the search area (2 max on each axis because of search area crossing fixed bonds of the quad tree cells)

Parameters:
searchRange - search range to be covered by the quad tree cells
Returns:
Return the best Quad Tree 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 quad tree cell ids computation

Parameters:
point - point to be projected
Returns:
array of projected coordinates

formatFieldName

public static String formatFieldName(int quadTreeLevel,
                                     String fieldName)

formatLatitude

public static String formatLatitude(String fieldName)

formatLongitude

public static String formatLongitude(String fieldName)

formatQuadTreeCellId

public static String formatQuadTreeCellId(int xIndex,
                                          int yIndex)


Copyright © 2006-2013 Red Hat Middleware, LLC. All Rights Reserved