|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree
public abstract class SpatialPrefixTree
A spatial Prefix Tree, or Trie, which decomposes shapes into prefixed strings at variable lengths corresponding to variable precision. Each string corresponds to a rectangular spatial region. This approach is also referred to "Grids", "Tiles", and "Spatial Tiers".
Implementations of this class should be thread-safe and immutable once initialized.
Field Summary | |
---|---|
protected com.spatial4j.core.context.SpatialContext |
ctx
|
protected int |
maxLevels
|
protected static Charset |
UTF8
|
Constructor Summary | |
---|---|
SpatialPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
int maxLevels)
|
Method Summary | |
---|---|
abstract 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). |
int |
getMaxLevels()
|
abstract Node |
getNode(byte[] bytes,
int offset,
int len)
|
Node |
getNode(byte[] bytes,
int offset,
int len,
Node target)
|
protected Node |
getNode(com.spatial4j.core.shape.Point p,
int level)
|
abstract Node |
getNode(String token)
The cell for the specified token. |
List<Node> |
getNodes(com.spatial4j.core.shape.Point p,
int detailLevel,
boolean inclParents)
A Point-optimized implementation of getNodes(com.spatial4j.core.shape.Shape, int, boolean, boolean) . |
List<Node> |
getNodes(com.spatial4j.core.shape.Shape shape,
int detailLevel,
boolean inclParents,
boolean simplify)
Gets the intersecting cells for the specified shape, without exceeding detail level. |
com.spatial4j.core.context.SpatialContext |
getSpatialContext()
|
Node |
getWorldNode()
Returns the level 0 cell which encompasses all spatial data. |
static List<String> |
nodesToTokenStrings(Collection<Node> nodes)
Will add the trailing leaf byte for leaves. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Charset UTF8
protected final int maxLevels
protected final com.spatial4j.core.context.SpatialContext ctx
Constructor Detail |
---|
public SpatialPrefixTree(com.spatial4j.core.context.SpatialContext ctx, int maxLevels)
Method Detail |
---|
public com.spatial4j.core.context.SpatialContext getSpatialContext()
public int getMaxLevels()
public String toString()
toString
in class Object
public abstract int getLevelForDistance(double dist)
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.
dist
- >= 0
public Node getWorldNode()
getNode(String)
with "".
This cell is threadsafe, just like a spatial prefix grid is, although cells aren't
generally threadsafe.
TODO rename to getTopCell or is this fine?
public abstract Node getNode(String token)
getWorldNode()
.
Precondition: Never called when token length > maxLevel.
public abstract Node getNode(byte[] bytes, int offset, int len)
public final Node getNode(byte[] bytes, int offset, int len, Node target)
protected Node getNode(com.spatial4j.core.shape.Point p, int level)
public List<Node> getNodes(com.spatial4j.core.shape.Shape shape, int detailLevel, boolean inclParents, boolean simplify)
getNodes(com.spatial4j.core.shape.Point, int, boolean)
.
shape
- the shape; non-nulldetailLevel
- the maximum detail level to get cells forinclParents
- if true then all parent cells of leaves are returned
too. The top world cell is never returned.simplify
- for non-point shapes, this will simply/aggregate sets of
complete leaves in a cell to its parent, resulting in
~20-25% fewer cells.
public List<Node> getNodes(com.spatial4j.core.shape.Point p, int detailLevel, boolean inclParents)
getNodes(com.spatial4j.core.shape.Shape, int, boolean, boolean)
. That
method in facts calls this for points.
This implementation depends on getNode(String)
being fast, as its
called repeatedly when incPlarents is true.
public static List<String> nodesToTokenStrings(Collection<Node> nodes)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |