Class NumberRangePrefixTree.NRCell
java.lang.Object
org.apache.lucene.spatial.prefix.tree.CellIterator
org.apache.lucene.spatial.prefix.tree.NumberRangePrefixTree.NRCell
- All Implemented Interfaces:
Cloneable,Comparable<NumberRangePrefixTree.UnitNRShape>,Iterator<Cell>,Cell,NumberRangePrefixTree.NRShape,NumberRangePrefixTree.UnitNRShape,org.locationtech.spatial4j.shape.Shape
- Enclosing class:
NumberRangePrefixTree
protected class NumberRangePrefixTree.NRCell
extends CellIterator
implements Cell, NumberRangePrefixTree.UnitNRShape
Most of the PrefixTree implementation is in this one class, which is both the Cell, the
CellIterator, and the Shape to reduce object allocation. It's implemented as a re-used
array/stack of Cells at adjacent levels, that all have a reference back to the cell array to
traverse. They also share a common BytesRef for the term.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
Fields inherited from class org.apache.lucene.spatial.prefix.tree.CellIterator
nextCell, thisCell -
Method Summary
Modifier and TypeMethodDescriptionclone()Deep cloneintintcompareToNoLeaf(Cell fromCell) Equivalent tothis.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null)).booleandoublegetArea(org.locationtech.spatial4j.context.SpatialContext ctx) org.locationtech.spatial4j.shape.Rectangleorg.locationtech.spatial4j.shape.ShapegetBuffered(double distance, org.locationtech.spatial4j.context.SpatialContext ctx) org.locationtech.spatial4j.shape.Pointorg.locationtech.spatial4j.context.SpatialContextintgetLevel()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(org.locationtech.spatial4j.shape.Shape shapeFilter) Gets the cells at the next grid cell level underneath this one, optionally filtered byshapeFilter.getShape()Gets the shape for this cell; typically a Rectangle.getShapeAtLevel(int level) Gets an ancestor at the specified level.org.locationtech.spatial4j.shape.SpatialRelationGets the relationship this cell has with the shape from which it was filtered from, assuming it came from aCellIterator.getTokenBytesNoLeaf(BytesRef result) Returns the bytes for this cell, without a leaf set.getTokenBytesWithLeaf(BytesRef result) Returns the bytes for this cell, with a leaf byte if this is a leaf cell.intgetValAtLevel(int level) Gets the value at the specified level of this unit.booleanhasArea()inthashCode()booleanhasNext()booleanisEmpty()booleanisLeaf()Some cells are flagged as leaves, which are indexed as such.booleanisPrefixOf(Cell c) Returns if the target term is within/underneath this cell; not necessarily a direct descendant.org.locationtech.spatial4j.shape.SpatialRelationrelate(NumberRangePrefixTree.SpanUnitsNRShape spanShape) org.locationtech.spatial4j.shape.SpatialRelationorg.locationtech.spatial4j.shape.SpatialRelationrelate(org.locationtech.spatial4j.shape.Shape shape) roundToLevel(int targetLevel) Returns this shape rounded to the target level.voidsetLeaf()Set this cell to be a leaf.voidsetShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel) SeeCell.getShapeRel().toString()The result should be parseable byNumberRangePrefixTree.parseShape(String).Configure your IDE to use this.Methods inherited from class org.apache.lucene.spatial.prefix.tree.CellIterator
next, nextFrom, remove, thisCellMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Method Details
-
getLevel
public int getLevel()Description copied from interface:CellLevel 0 is the world (and has no parent), from then on a higher level means a smaller cell than the level before it.- Specified by:
getLevelin interfaceCell- Specified by:
getLevelin interfaceNumberRangePrefixTree.UnitNRShape
-
getShapeRel
public org.locationtech.spatial4j.shape.SpatialRelation getShapeRel()Description copied from interface:CellGets 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.- Specified by:
getShapeRelin interfaceCell
-
setShapeRel
public void setShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel) Description copied from interface:CellSeeCell.getShapeRel().- Specified by:
setShapeRelin interfaceCell
-
isLeaf
public boolean isLeaf()Description copied from interface:CellSome 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
public void setLeaf()Description copied from interface:CellSet 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. -
getShape
Description copied from interface:CellGets the shape for this cell; typically a Rectangle. -
getTokenBytesNoLeaf
Description copied from interface:CellReturns the bytes for this cell, without a leaf set. The bytes should sort beforeCell.getTokenBytesWithLeaf(org.apache.lucene.util.BytesRef). The result param is used to save object allocation, though its bytes aren't used.- Specified by:
getTokenBytesNoLeafin interfaceCell- Parameters:
result- where the result goes, or null to create new
-
getTokenBytesWithLeaf
Description copied from interface:CellReturns 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.- Specified by:
getTokenBytesWithLeafin interfaceCell- Parameters:
result- where the result goes, or null to create new
-
isPrefixOf
Description copied from interface:CellReturns if the target term is within/underneath this cell; not necessarily a direct descendant.- Specified by:
isPrefixOfin interfaceCell- Parameters:
c- the term
-
compareToNoLeaf
Description copied from interface:CellEquivalent tothis.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null)).- Specified by:
compareToNoLeafin interfaceCell
-
getNextLevelCells
Description copied from interface:CellGets the cells at the next grid cell level underneath this one, optionally filtered byshapeFilter. The returned cells should haveCell.getShapeRel()set to their relation withshapeFilter. In addition, for non-pointsCell.isLeaf()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.
- Specified by:
getNextLevelCellsin interfaceCell- Parameters:
shapeFilter- an optional filter for the returned cells.- Returns:
- A set of cells (no dups), sorted. Not Modifiable.
-
hasNext
public boolean hasNext() -
getValAtLevel
public int getValAtLevel(int level) Description copied from interface:NumberRangePrefixTree.UnitNRShapeGets the value at the specified level of this unit. level must be >= 0 and <= getLevel().- Specified by:
getValAtLevelin interfaceNumberRangePrefixTree.UnitNRShape
-
getShapeAtLevel
Description copied from interface:NumberRangePrefixTree.UnitNRShapeGets an ancestor at the specified level. It shares state, so you may want to clone() it.- Specified by:
getShapeAtLevelin interfaceNumberRangePrefixTree.UnitNRShape
-
roundToLevel
Description copied from interface:NumberRangePrefixTree.NRShapeReturns this shape rounded to the target level. If we are already more course than the level then the shape is simply returned. The result may refer to internal state of the argument so you may want to clone it.- Specified by:
roundToLevelin interfaceNumberRangePrefixTree.NRShape- Specified by:
roundToLevelin interfaceNumberRangePrefixTree.UnitNRShape
-
relate
public org.locationtech.spatial4j.shape.SpatialRelation relate(org.locationtech.spatial4j.shape.Shape shape) - Specified by:
relatein interfaceorg.locationtech.spatial4j.shape.Shape
-
relate
public org.locationtech.spatial4j.shape.SpatialRelation relate(NumberRangePrefixTree.UnitNRShape lv) -
relate
public org.locationtech.spatial4j.shape.SpatialRelation relate(NumberRangePrefixTree.SpanUnitsNRShape spanShape) -
clone
Description copied from interface:NumberRangePrefixTree.UnitNRShapeDeep clone- Specified by:
clonein interfaceNumberRangePrefixTree.UnitNRShape- Overrides:
clonein classObject
-
compareTo
- Specified by:
compareToin interfaceComparable<NumberRangePrefixTree.UnitNRShape>
-
getBoundingBox
public org.locationtech.spatial4j.shape.Rectangle getBoundingBox()- Specified by:
getBoundingBoxin interfaceorg.locationtech.spatial4j.shape.Shape
-
hasArea
public boolean hasArea()- Specified by:
hasAreain interfaceorg.locationtech.spatial4j.shape.Shape
-
getArea
public double getArea(org.locationtech.spatial4j.context.SpatialContext ctx) - Specified by:
getAreain interfaceorg.locationtech.spatial4j.shape.Shape
-
getCenter
public org.locationtech.spatial4j.shape.Point getCenter()- Specified by:
getCenterin interfaceorg.locationtech.spatial4j.shape.Shape
-
getBuffered
public org.locationtech.spatial4j.shape.Shape getBuffered(double distance, org.locationtech.spatial4j.context.SpatialContext ctx) - Specified by:
getBufferedin interfaceorg.locationtech.spatial4j.shape.Shape
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceorg.locationtech.spatial4j.shape.Shape
-
equals
-
getContext
public org.locationtech.spatial4j.context.SpatialContext getContext()- Specified by:
getContextin interfaceorg.locationtech.spatial4j.shape.Shape
-
hashCode
public int hashCode() -
toString
Description copied from interface:NumberRangePrefixTree.NRShapeThe result should be parseable byNumberRangePrefixTree.parseShape(String).- Specified by:
toStringin interfaceNumberRangePrefixTree.NRShape- Overrides:
toStringin classObject
-
toStringDebug
Configure your IDE to use this.
-