public abstract class SpatialPrefixTree extends Object
| Modifier and Type | Field and Description |
|---|---|
protected com.spatial4j.core.context.SpatialContext |
ctx |
protected int |
maxLevels |
protected static Charset |
UTF8 |
| Constructor and Description |
|---|
SpatialPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
int maxLevels) |
| Modifier and Type | Method and Description |
|---|---|
abstract 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.
|
int |
getMaxLevelForPrecision(com.spatial4j.core.shape.Shape shape,
double precision)
|
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.Shape shape,
int detailLevel,
boolean inclParents)
Gets the intersecting & including cells for the specified shape, without exceeding detail level.
|
protected List<Node> |
getNodesAltPoint(com.spatial4j.core.shape.Point p,
int detailLevel,
boolean inclParents)
Subclasses might override
getNodes(com.spatial4j.core.shape.Shape, int, boolean)
and check if the argument is a shape and if so, delegate
to this implementation, which calls getNode(com.spatial4j.core.shape.Point, int) and
then calls getNode(String) repeatedly if inclParents is true. |
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() |
protected static final Charset UTF8
protected final int maxLevels
protected final com.spatial4j.core.context.SpatialContext ctx
public SpatialPrefixTree(com.spatial4j.core.context.SpatialContext ctx,
int maxLevels)
public com.spatial4j.core.context.SpatialContext getSpatialContext()
public int getMaxLevels()
public int getMaxLevelForPrecision(com.spatial4j.core.shape.Shape shape,
double precision)
SpatialArgs.getDistPrecision().
A grid level looked up via getLevelForDistance(double) is returned.precision - 0-0.5public abstract int getLevelForDistance(double dist)
dist - >= 0public 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)
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)
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 getNodesAltPoint(com.spatial4j.core.shape.Point, int, boolean).
TODO consider another approach returning an iterator -- won't build up all cells in memory.protected final List<Node> getNodesAltPoint(com.spatial4j.core.shape.Point p, int detailLevel, boolean inclParents)
getNodes(com.spatial4j.core.shape.Shape, int, boolean)
and check if the argument is a shape and if so, delegate
to this implementation, which calls getNode(com.spatial4j.core.shape.Point, int) and
then calls getNode(String) repeatedly if inclParents is true.public static List<String> nodesToTokenStrings(Collection<Node> nodes)
Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.