org.elasticsearch.common.lucene.spatial.prefix.tree
Class GeohashPrefixTree

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

public class GeohashPrefixTree
extends SpatialPrefixTree

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


Field Summary
 
Fields inherited from class org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree
ctx, maxLevels, UTF8
 
Constructor Summary
GeohashPrefixTree(com.spatial4j.core.context.SpatialContext ctx, int maxLevels)
           
 
Method Summary
 int getLevelForDistance(double dist)
          Returns the level of the smallest grid size with a side length that is greater or equal to the provided distance.
static int getMaxLevelsPossible()
          Any more than this and there's no point (double lat & lon are the same).
 Node getNode(byte[] bytes, int offset, int len)
           
 Node getNode(com.spatial4j.core.shape.Point p, int level)
           
 Node getNode(String token)
          The cell for the specified token.
 List<Node> getNodes(com.spatial4j.core.shape.Shape shape, int detailLevel, boolean inclParents)
          Gets the intersecting & including cells for the specified shape, without exceeding detail level.
 
Methods inherited from class org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree
getMaxLevelForPrecision, getMaxLevels, getNode, getNodesAltPoint, getSpatialContext, getWorldNode, nodesToTokenStrings, 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 smallest grid size with a side length that is greater or equal to the provided distance.

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

getNode

public Node getNode(com.spatial4j.core.shape.Point p,
                    int level)
Overrides:
getNode in class SpatialPrefixTree

getNode

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

Specified by:
getNode in class SpatialPrefixTree

getNode

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

getNodes

public List<Node> getNodes(com.spatial4j.core.shape.Shape shape,
                           int detailLevel,
                           boolean inclParents)
Description copied from class: SpatialPrefixTree
Gets the intersecting & including cells for the specified shape, without exceeding detail level. The result is a set of cells (no dups), sorted. Unmodifiable.

This implementation checks if shape is a Point and if so uses an implementation that recursively calls Node.getSubCell(com.spatial4j.core.shape.Point). Cell subclasses ideally implement that method with a quick implementation, otherwise, subclasses should override this method to invoke SpatialPrefixTree.getNodesAltPoint(com.spatial4j.core.shape.Point, int, boolean). TODO consider another approach returning an iterator -- won't build up all cells in memory.

Overrides:
getNodes in class SpatialPrefixTree


Copyright © 2009-2012. All Rights Reserved.