org.apache.lucene.spatial.prefix.tree
Class QuadPrefixTree
java.lang.Object
org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree
org.apache.lucene.spatial.prefix.tree.QuadPrefixTree
public class QuadPrefixTree
- extends SpatialPrefixTree
A SpatialPrefixTree
which uses a
quad tree in which an
indexed term will be generated for each node, 'A', 'B', 'C', 'D'.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
Constructor Summary |
QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx)
|
QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
int maxLevels)
|
QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
com.spatial4j.core.shape.Rectangle bounds,
int maxLevels)
|
Method Summary |
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). |
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. |
void |
printInfo(PrintStream out)
|
MAX_LEVELS_POSSIBLE
public static final int MAX_LEVELS_POSSIBLE
- See Also:
- Constant Field Values
DEFAULT_MAX_LEVELS
public static final int DEFAULT_MAX_LEVELS
- See Also:
- Constant Field Values
gridH
public final double gridH
QuadPrefixTree
public QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
com.spatial4j.core.shape.Rectangle bounds,
int maxLevels)
QuadPrefixTree
public QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx)
QuadPrefixTree
public QuadPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
int maxLevels)
printInfo
public void printInfo(PrintStream out)
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]
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 © 2000-2012 Apache Software Foundation. All Rights Reserved.