org.elasticsearch.common.lucene.spatial.prefix.tree
Class Node

java.lang.Object
  extended by org.elasticsearch.common.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 threadsafe, although new Cell("") (world cell) must be.


Field Summary
static byte LEAF_BYTE
           
protected  com.spatial4j.core.shape.SpatialRelation shapeRel
           
 
Constructor Summary
protected Node(SpatialPrefixTree spatialPrefixTree, byte[] bytes, int off, int len)
           
protected Node(SpatialPrefixTree spatialPrefixTree, 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()
           
 void reset(byte[] bytes, int off, int len)
           
 void setLeaf()
           
 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
Constructor Detail

Node

protected Node(SpatialPrefixTree spatialPrefixTree,
               String token)

Node

protected Node(SpatialPrefixTree spatialPrefixTree,
               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()

setLeaf

public void setLeaf()

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); 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. Not Modifiable.

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 © 2009-2012. All Rights Reserved.