public abstract class SpatialPrefixTree extends Object
Implementations of this class should be thread-safe and immutable once initialized.
Modifier and Type | Field and Description |
---|---|
protected org.locationtech.spatial4j.context.SpatialContext |
ctx |
protected int |
maxLevels |
Constructor and Description |
---|
SpatialPrefixTree(org.locationtech.spatial4j.context.SpatialContext ctx,
int maxLevels) |
Modifier and Type | Method and Description |
---|---|
abstract double |
getDistanceForLevel(int level)
Given a cell having the specified level, returns the distance from opposite
corners.
|
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() |
org.locationtech.spatial4j.context.SpatialContext |
getSpatialContext() |
CellIterator |
getTreeCellIterator(org.locationtech.spatial4j.shape.Shape shape,
int detailLevel)
Gets the intersecting cells for the specified shape, without exceeding
detail level.
|
abstract Cell |
getWorldCell()
Returns the level 0 cell which encompasses all spatial data.
|
abstract Cell |
readCell(BytesRef term,
Cell scratch)
This creates a new Cell (or re-using
scratch if provided), initialized to the state as read
by the bytes. |
String |
toString() |
protected final int maxLevels
protected final org.locationtech.spatial4j.context.SpatialContext ctx
public SpatialPrefixTree(org.locationtech.spatial4j.context.SpatialContext ctx, int maxLevels)
public org.locationtech.spatial4j.context.SpatialContext getSpatialContext()
public int getMaxLevels()
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 abstract double getDistanceForLevel(int level)
level
- [1 to maxLevels]> 0
public abstract Cell getWorldCell()
readCell(BytesRef,Cell)
with no bytes.public abstract Cell readCell(BytesRef term, Cell scratch)
scratch
if provided), initialized to the state as read
by the bytes.
Warning: An implementation may refer to the same byte array (no copy). If Cell.setLeaf()
is
subsequently called, it would then modify these bytes.public CellIterator getTreeCellIterator(org.locationtech.spatial4j.shape.Shape shape, int detailLevel)
IMPORTANT: Cells returned from the iterator can be re-used for cells at the same level. So you can't simply iterate to subsequent cells and still refer to the former cell nor the bytes returned from the former cell, unless you know the former cell is a parent.
shape
- the shape; possibly null but the caller should liberally call
remove()
if so.detailLevel
- the maximum detail level to get cells forCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.