Class Cell
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Implements
Inherited Members
Namespace: Lucene.Net.Spatial.Prefix.Tree
Assembly: Lucene.Net.Spatial.dll
Syntax
public abstract class Cell : IComparable<Cell>
Constructors
Cell(SpatialPrefixTree, byte[], int, int)
Initializes a new instance of Cell for the
spatialPrefixTree
with the specified bytes
, offset
and length
.
Declaration
protected Cell(SpatialPrefixTree spatialPrefixTree, byte[] bytes, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
SpatialPrefixTree | spatialPrefixTree | The SpatialPrefixTree this instance belongs to. |
byte[] | bytes | The representation of this Cell. |
int | offset | The offset into |
int | length | The count of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Cell(SpatialPrefixTree, string)
Initializes a new instance of Cell for the
spatialPrefixTree
with the specified token
.
Declaration
protected Cell(SpatialPrefixTree spatialPrefixTree, string token)
Parameters
Type | Name | Description |
---|---|---|
SpatialPrefixTree | spatialPrefixTree | The SpatialPrefixTree this instance belongs to. |
string | token | The string representation of this Cell. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Fields
LEAF_BYTE
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public const byte LEAF_BYTE = 43
Field Value
Type | Description |
---|---|
byte |
m_leaf
Always false for points.
Declaration
protected bool m_leaf
Field Value
Type | Description |
---|---|
bool |
Remarks
Always false for points. Otherwise, indicate no further sub-cells are going to be provided because shapeRel is WITHIN or maxLevels or a detailLevel is hit.
m_shapeRel
When set via GetSubCells(filter), it is the relationship between this cell and the given shape filter.
Declaration
protected SpatialRelation m_shapeRel
Field Value
Type | Description |
---|---|
SpatialRelation |
m_spatialPrefixTree
LUCENENET specific - we need to set the SpatialPrefixTree before calling overridden members of this class, just in case those overridden members require it. This is not possible from the subclass because the constructor of the base class runs first. So we need to move the reference here and also set it before running the normal constructor logic.
Declaration
protected readonly SpatialPrefixTree m_spatialPrefixTree
Field Value
Type | Description |
---|---|
SpatialPrefixTree |
Properties
Center
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual IPoint Center { get; }
Property Value
Type | Description |
---|---|
IPoint |
IsLeaf
For points, this is always false.
Declaration
public virtual bool IsLeaf { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
For points, this is always false. Otherwise this is true if there are no further cells with this prefix for the shape (always true at maxLevels).
Level
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual int Level { get; }
Property Value
Type | Description |
---|---|
int |
Shape
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public abstract IShape Shape { get; }
Property Value
Type | Description |
---|---|
IShape |
ShapeRel
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual SpatialRelation ShapeRel { get; }
Property Value
Type | Description |
---|---|
SpatialRelation |
SubCellsSize
GetSubCells().Count -- usually a constant. Should be >=2
Declaration
public abstract int SubCellsSize { get; }
Property Value
Type | Description |
---|---|
int |
TokenString
Note: doesn't contain a trailing leaf byte.
Declaration
public virtual string TokenString { get; }
Property Value
Type | Description |
---|---|
string |
Methods
CompareTo(Cell?)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public virtual int CompareTo(Cell? other)
Parameters
Type | Name | Description |
---|---|---|
Cell | other | An object to compare with this instance. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
int | A value that indicates the relative order of the objects being compared. The return value has these meanings:
|
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
GetSubCell(IPoint)
Performant implementations are expected to implement this efficiently by considering the current cell's boundary.
Declaration
public abstract Cell GetSubCell(IPoint p)
Parameters
Type | Name | Description |
---|---|---|
IPoint | p |
Returns
Type | Description |
---|---|
Cell |
Remarks
Performant implementations are expected to implement this efficiently by considering the current cell's boundary. Precondition: Never called when Level == maxLevel.
Precondition: this.Shape.Relate(p) != SpatialRelation.DISJOINT.GetSubCells()
Gets the cells at the next grid cell level that cover this cell.
Declaration
protected abstract ICollection<Cell> GetSubCells()
Returns
Type | Description |
---|---|
ICollection<Cell> | A set of cells (no dups), sorted, modifiable, not empty, not null. |
Remarks
Gets the cells at the next grid cell level that cover this cell. Precondition: Never called when Level == maxLevel.
GetSubCells(IShape?)
Like GetSubCells() but with the results filtered by a shape. If
that shape is a Spatial4n.Shapes.IPoint then it must call
GetSubCell(IPoint). The returned cells
should have ShapeRel set to their relation with
shapeFilter
. In addition, IsLeaf
must be true when that relation is Spatial4n.Shapes.SpatialRelation.WITHIN.
Declaration
public virtual ICollection<Cell> GetSubCells(IShape? shapeFilter)
Parameters
Type | Name | Description |
---|---|---|
IShape | shapeFilter | an optional filter for the returned cells. |
Returns
Type | Description |
---|---|
ICollection<Cell> | A set of cells (no dups), sorted. Not Modifiable. |
GetTokenBytes()
Note: doesn't contain a trailing leaf byte.
Declaration
public virtual byte[] GetTokenBytes()
Returns
Type | Description |
---|---|
byte[] |
Reset(byte[], int, int)
Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual void Reset(byte[] bytes, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | |
int | offset | |
int | length |
SetLeaf()
Note: not supported at level 0.
NOTE: When overriding this method, be aware that the constructor of this class calls
a private method and not this virtual method. So if you need to override
the behavior during the initialization, call your own private method from the constructor
with whatever custom behavior you need.
Declaration
public virtual void SetLeaf()
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |