Interface Cell
-
- All Known Subinterfaces:
CellCanPrune
- All Known Implementing Classes:
LegacyCell
,NumberRangePrefixTree.NRCell
,PackedQuadPrefixTree.PackedQuadCell
,QuadPrefixTree.QuadCell
public interface Cell
Represents a grid cell. Cell instances are generally very transient and may be re-used internally. To get an instance, you could start withSpatialPrefixTree.getWorldCell()
. And from there you could either traverse down the tree withgetNextLevelCells(org.locationtech.spatial4j.shape.Shape)
, or you could read an indexed term viaSpatialPrefixTree.readCell(org.apache.lucene.util.BytesRef,Cell)
. When a cell is read from a term, it is comprised of just the base bytes plus optionally a leaf flag.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
compareToNoLeaf(Cell fromCell)
Equivalent tothis.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null))
.int
getLevel()
Level 0 is the world (and has no parent), from then on a higher level means a smaller cell than the level before it.CellIterator
getNextLevelCells(org.locationtech.spatial4j.shape.Shape shapeFilter)
Gets the cells at the next grid cell level underneath this one, optionally filtered byshapeFilter
.org.locationtech.spatial4j.shape.Shape
getShape()
Gets the shape for this cell; typically a Rectangle.org.locationtech.spatial4j.shape.SpatialRelation
getShapeRel()
Gets the relationship this cell has with the shape from which it was filtered from, assuming it came from aCellIterator
.BytesRef
getTokenBytesNoLeaf(BytesRef result)
Returns the bytes for this cell, without a leaf set.BytesRef
getTokenBytesWithLeaf(BytesRef result)
Returns the bytes for this cell, with a leaf byte if this is a leaf cell.boolean
isLeaf()
Some cells are flagged as leaves, which are indexed as such.boolean
isPrefixOf(Cell c)
Returns if the target term is within/underneath this cell; not necessarily a direct descendant.void
setLeaf()
Set this cell to be a leaf.void
setShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel)
SeegetShapeRel()
.
-
-
-
Method Detail
-
getShapeRel
org.locationtech.spatial4j.shape.SpatialRelation getShapeRel()
Gets the relationship this cell has with the shape from which it was filtered from, assuming it came from aCellIterator
. Arguably it belongs there but it's very convenient here.
-
setShapeRel
void setShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel)
SeegetShapeRel()
.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
isLeaf
boolean isLeaf()
Some cells are flagged as leaves, which are indexed as such. A leaf cell is either within some shape or it both intersects and the cell is at an accuracy threshold such that no smaller cells for the shape will be represented.
-
setLeaf
void setLeaf()
Set this cell to be a leaf. Warning: never call on a cell initialized to reference the same bytes from termsEnum, which should be treated as immutable. Note: not supported at level 0.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
getTokenBytesWithLeaf
BytesRef getTokenBytesWithLeaf(BytesRef result)
Returns the bytes for this cell, with a leaf byte if this is a leaf cell. The result param is used to save object allocation, though its bytes aren't used.- Parameters:
result
- where the result goes, or null to create new
-
getTokenBytesNoLeaf
BytesRef getTokenBytesNoLeaf(BytesRef result)
Returns the bytes for this cell, without a leaf set. The bytes should sort beforegetTokenBytesWithLeaf(org.apache.lucene.util.BytesRef)
. The result param is used to save object allocation, though its bytes aren't used.- Parameters:
result
- where the result goes, or null to create new
-
getLevel
int getLevel()
Level 0 is the world (and has no parent), from then on a higher level means a smaller cell than the level before it.
-
getNextLevelCells
CellIterator getNextLevelCells(org.locationtech.spatial4j.shape.Shape shapeFilter)
Gets the cells at the next grid cell level underneath this one, optionally filtered byshapeFilter
. The returned cells should havegetShapeRel()
set to their relation withshapeFilter
. In addition, for non-pointsisLeaf()
must be true when that relation is WITHIN.IMPORTANT: Cells returned from this iterator can be shared, as well as the bytes.
Precondition: Never called when getLevel() == maxLevel.
- Parameters:
shapeFilter
- an optional filter for the returned cells.- Returns:
- A set of cells (no dups), sorted. Not Modifiable.
-
getShape
org.locationtech.spatial4j.shape.Shape getShape()
Gets the shape for this cell; typically a Rectangle.
-
isPrefixOf
boolean isPrefixOf(Cell c)
Returns if the target term is within/underneath this cell; not necessarily a direct descendant.- Parameters:
c
- the term
-
compareToNoLeaf
int compareToNoLeaf(Cell fromCell)
Equivalent tothis.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null))
.
-
-