public class PackedQuadPrefixTree extends QuadPrefixTree
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDL Where C = Cell bits (2 per quad) D = Depth bits (5 with max of 29 levels) L = isLeaf bitIt includes a built-in "pruneLeafyBranches" setting (true by default) similar to
RecursivePrefixTreeStrategy.setPruneLeafyBranches(boolean)
although
this one only prunes at the target detail level (where it has the most effect). Usually you should disable RPT's
prune, since it is very memory in-efficient.Modifier and Type | Class and Description |
---|---|
static class |
PackedQuadPrefixTree.Factory
Factory for creating
PackedQuadPrefixTree instances with useful defaults. |
protected class |
PackedQuadPrefixTree.PackedQuadCell
See binary representation in the javadocs of
PackedQuadPrefixTree . |
protected class |
PackedQuadPrefixTree.PrefixTreeIterator
This is a streamlined version of TreeCellIterator, with built-in support to prune at detailLevel
(but not recursively upwards).
|
QuadPrefixTree.QuadCell
Modifier and Type | Field and Description |
---|---|
protected boolean |
leafyPrune |
static int |
MAX_LEVELS_POSSIBLE |
protected static byte[] |
QUAD |
DEFAULT_MAX_LEVELS, gridH, gridW, robust, xmax, xmid, xmin, ymax, ymid, ymin
ctx, maxLevels
Constructor and Description |
---|
PackedQuadPrefixTree(org.locationtech.spatial4j.context.SpatialContext ctx,
int maxLevels) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildNotRobustly(double x,
double y,
int level,
List<Cell> matches,
long term,
org.locationtech.spatial4j.shape.Shape shape,
int maxLevel) |
protected void |
checkBattenbergNotRobustly(byte quad,
double cx,
double cy,
int level,
List<Cell> matches,
long term,
org.locationtech.spatial4j.shape.Shape shape,
int maxLevel) |
Cell |
getCell(org.locationtech.spatial4j.shape.Point p,
int level)
Returns the cell containing point
p at the specified level . |
double |
getDistanceForLevel(int level)
Given a cell having the specified level, returns the distance from opposite
corners.
|
CellIterator |
getTreeCellIterator(org.locationtech.spatial4j.shape.Shape shape,
int detailLevel)
Gets the intersecting cells for the specified shape, without exceeding
detail level.
|
Cell |
getWorldCell()
Returns the level 0 cell which encompasses all spatial data.
|
boolean |
isPruneLeafyBranches() |
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. |
void |
setPruneLeafyBranches(boolean pruneLeafyBranches)
Like
RecursivePrefixTreeStrategy.setPruneLeafyBranches(boolean)
but more memory efficient and only applies to the detailLevel, where it has the most effect. |
String |
toString() |
battenberg, checkBattenbergNotRobustly, getLevelForDistance, printInfo
getMaxLevels, getSpatialContext
public static final int MAX_LEVELS_POSSIBLE
protected static final byte[] QUAD
protected boolean leafyPrune
public PackedQuadPrefixTree(org.locationtech.spatial4j.context.SpatialContext ctx, int maxLevels)
public String toString()
toString
in class SpatialPrefixTree
public Cell getWorldCell()
SpatialPrefixTree
SpatialPrefixTree.readCell(BytesRef,Cell)
with no bytes.getWorldCell
in class QuadPrefixTree
public Cell getCell(org.locationtech.spatial4j.shape.Point p, int level)
p
at the specified level
.getCell
in class QuadPrefixTree
protected void buildNotRobustly(double x, double y, int level, List<Cell> matches, long term, org.locationtech.spatial4j.shape.Shape shape, int maxLevel)
protected void checkBattenbergNotRobustly(byte quad, double cx, double cy, int level, List<Cell> matches, long term, org.locationtech.spatial4j.shape.Shape shape, int maxLevel)
public Cell readCell(BytesRef term, Cell scratch)
SpatialPrefixTree
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)
SpatialPrefixTree
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 forpublic boolean isPruneLeafyBranches()
public void setPruneLeafyBranches(boolean pruneLeafyBranches)
RecursivePrefixTreeStrategy.setPruneLeafyBranches(boolean)
but more memory efficient and only applies to the detailLevel, where it has the most effect.public double getDistanceForLevel(int level)
SpatialPrefixTree
getDistanceForLevel
in class SpatialPrefixTree
level
- [1 to maxLevels]> 0
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.