org.apache.lucene.spatial.prefix.tree
Class GeohashPrefixTree

java.lang.Object
  extended by org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree
      extended by org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree

public class GeohashPrefixTree
extends SpatialPrefixTree

A SpatialPrefixTree based on Geohashes. Uses GeohashUtils to do all the geohash work.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Nested Class Summary
static class GeohashPrefixTree.Factory
          Factory for creating GeohashPrefixTree instances with useful defaults
 
Field Summary
 
Fields inherited from class org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree
ctx, maxLevels, UTF8
 
Constructor Summary
GeohashPrefixTree(com.spatial4j.core.context.SpatialContext ctx, int maxLevels)
           
 
Method Summary
 Cell getCell(byte[] bytes, int offset, int len)
           
 Cell getCell(com.spatial4j.core.shape.Point p, int level)
          Returns the cell containing point p at the specified level.
 Cell getCell(String token)
          The cell for the specified token.
 int getLevelForDistance(double dist)
          Returns the level of the largest grid in which its longest side is less than or equal to the provided distance (in degrees).
static int getMaxLevelsPossible()
          Any more than this and there's no point (double lat & lon are the same).
 
Methods inherited from class org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree
cellsToTokenStrings, getCell, getCells, getCells, getDistanceForLevel, getMaxLevels, getSpatialContext, getWorldCell, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeohashPrefixTree

public GeohashPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
                         int maxLevels)
Method Detail

getMaxLevelsPossible

public static int getMaxLevelsPossible()
Any more than this and there's no point (double lat & lon are the same).


getLevelForDistance

public int getLevelForDistance(double dist)
Description copied from class: SpatialPrefixTree
Returns the level of the largest grid in which its longest side is less than or equal to the provided distance (in degrees). Consequently dist acts as an error epsilon declaring the amount of detail needed in the grid, such that you can get a grid with just the right amount of precision.

Specified by:
getLevelForDistance in class SpatialPrefixTree
Parameters:
dist - >= 0
Returns:
level [1 to maxLevels]

getCell

public Cell getCell(com.spatial4j.core.shape.Point p,
                    int level)
Description copied from class: SpatialPrefixTree
Returns the cell containing point p at the specified level.

Overrides:
getCell in class SpatialPrefixTree

getCell

public Cell getCell(String token)
Description copied from class: SpatialPrefixTree
The cell for the specified token. The empty string should be equal to SpatialPrefixTree.getWorldCell(). Precondition: Never called when token length > maxLevel.

Specified by:
getCell in class SpatialPrefixTree

getCell

public Cell getCell(byte[] bytes,
                    int offset,
                    int len)
Specified by:
getCell in class SpatialPrefixTree


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.