org.apache.lucene.spatial.prefix.tree
Class Node

java.lang.Object
  extended by org.apache.lucene.spatial.prefix.tree.Node
All Implemented Interfaces:
Comparable<Node>

public abstract class Node
extends Object
implements Comparable<Node>

Represents a grid cell. These are not necessarily thread-safe, although new Cell("") (world cell) must be.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
protected  boolean leaf
          Always false for points.
static byte LEAF_BYTE
           
protected  com.spatial4j.core.shape.SpatialRelation shapeRel
          When set via getSubCells(filter), it is the relationship between this cell and the given shape filter.
 
Constructor Summary
protected Node(byte[] bytes, int off, int len)
           
protected Node(String token)
           
 
Method Summary
 int compareTo(Node o)
           
 boolean equals(Object obj)
           
 com.spatial4j.core.shape.Point getCenter()
           
 int getLevel()
           
abstract  com.spatial4j.core.shape.Shape getShape()
           
 com.spatial4j.core.shape.SpatialRelation getShapeRel()
           
abstract  Node getSubCell(com.spatial4j.core.shape.Point p)
          Performant implementations are expected to implement this efficiently by considering the current cell's boundary.
protected abstract  Collection<Node> getSubCells()
          Gets the cells at the next grid cell level that cover this cell.
 Collection<Node> getSubCells(com.spatial4j.core.shape.Shape shapeFilter)
          Like getSubCells() but with the results filtered by a shape.
abstract  int getSubCellsSize()
          getSubCells().size() -- usually a constant.
 byte[] getTokenBytes()
          Note: doesn't contain a trailing leaf byte.
 String getTokenString()
          Note: doesn't contain a trailing leaf byte.
 int hashCode()
           
 boolean isLeaf()
          For points, this is always false.
 void reset(byte[] bytes, int off, int len)
           
 void setLeaf()
          Note: not supported at level 0.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LEAF_BYTE

public static final byte LEAF_BYTE
See Also:
Constant Field Values

shapeRel

protected com.spatial4j.core.shape.SpatialRelation shapeRel
When set via getSubCells(filter), it is the relationship between this cell and the given shape filter.


leaf

protected boolean leaf
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.

Constructor Detail

Node

protected Node(String token)

Node

protected Node(byte[] bytes,
               int off,
               int len)
Method Detail

reset

public void reset(byte[] bytes,
                  int off,
                  int len)

getShapeRel

public com.spatial4j.core.shape.SpatialRelation getShapeRel()

isLeaf

public boolean isLeaf()
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).


setLeaf

public void setLeaf()
Note: not supported at level 0.


getTokenString

public String getTokenString()
Note: doesn't contain a trailing leaf byte.


getTokenBytes

public byte[] getTokenBytes()
Note: doesn't contain a trailing leaf byte.


getLevel

public int getLevel()

getSubCells

public Collection<Node> getSubCells(com.spatial4j.core.shape.Shape shapeFilter)
Like getSubCells() but with the results filtered by a shape. If that shape is a Point then it must call getSubCell(com.spatial4j.core.shape.Point). The returned cells should have getShapeRel() set to their relation with shapeFilter. In addition, isLeaf() must be true when that relation is WITHIN.

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.

getSubCell

public abstract Node getSubCell(com.spatial4j.core.shape.Point p)
Performant implementations are expected to implement this efficiently by considering the current cell's boundary. Precondition: Never called when getLevel() == maxLevel.

Precondition: this.getShape().relate(p) != DISJOINT.


getSubCells

protected abstract Collection<Node> getSubCells()
Gets the cells at the next grid cell level that cover this cell. Precondition: Never called when getLevel() == maxLevel.

Returns:
A set of cells (no dups), sorted, modifiable, not empty, not null.

getSubCellsSize

public abstract int getSubCellsSize()
getSubCells().size() -- usually a constant. Should be >=2


getShape

public abstract com.spatial4j.core.shape.Shape getShape()

getCenter

public com.spatial4j.core.shape.Point getCenter()

compareTo

public int compareTo(Node o)
Specified by:
compareTo in interface Comparable<Node>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.