SpatialIndex Class Reference

#include <SpatialIndex.h>

Collaboration diagram for SpatialIndex:
Collaboration graph

List of all members.


struct  Layer
struct  QuadNode

Public Member Functions

size_t getMaxlevel ()
size_t getBildLevel ()
 SpatialIndex ()
 SpatialIndex (size_t maxlevel, size_t buildlevel=5)
uint32 leafNumberById (uint64 ID) const
uint64 idByLeafNumber (uint32 n) const
char * nameByLeafNumber (uint32 n, char *name=0) const
void pointById (SpatialVector &vector, uint64 ID) const
uint64 idByPoint (SpatialVector &vector) const
uint64 idByPoint (const float64 &ra, const float64 &dec) const
 find a node by giving a ra,dec in degrees.
char * nameByPoint (SpatialVector &vector, char *s=NULL) const
 find a node by giving a vector.
char * nameByPoint (const float64 &ra, const float64 &dec, char *s=NULL) const
 find a node by giving a ra,dec in degrees.
uint64 leafCount () const
 return number of leaf nodes
size_t nVertices () const
 return number of vertices
float64 area (uint64 ID) const
 The area in steradians for a given index ID.
float64 area (const SpatialVector &v1, const SpatialVector &v2, const SpatialVector &v3) const
 The area in steradians for a given spatial triangle.
void nodeVertex (const uint64 id, SpatialVector &v1, SpatialVector &v2, SpatialVector &v3) const
 return the actual vertex vectors
void nodeVertex (const size_t idx, size_t &v1, size_t &v2, size_t &v3) const
 return index of vertices for a node
void showVertices (ostream &out) const
 print all vertices to output stream
void setMaxlevel (int level)
 set the maximum depth of the layer

Static Public Member Functions

static uint64 idByName (const char *)
 NodeName conversion to integer ID.
static char * nameById (uint64 ID, char *name=0)

Private Types

typedef std::vector< QuadNodeValueVectorQuad
typedef std::vector
< SpatialVector

Private Member Functions

uint64 newNode (size_t v1, size_t v2, size_t v3, uint64 id, uint64 parent)
void makeNewLayer (size_t oldlayer)
void vMax (size_t *nodes, size_t *vertices)
void sortIndex ()
bool isInside (const SpatialVector &v, const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2) const

Private Attributes

size_t maxlevel_
size_t buildlevel_
uint64 leaves_
uint64 storedleaves_
ValueVectorQuad nodes_
std::vector< Layerlayers_
ValueVectorSpvec vertices_
uint64 index_


class SpatialEdge
class SpatialConvex
class RangeConvex
class SpatialDomain
class htmInterface

Detailed Description

The Spatial Index is a quad tree of spherical triangles. The tree is built in the following way: Start out with 8 triangles on the sphere using the 3 main circles to determine them. Then, every triangle can be decomposed into 4 new triangles by drawing main circles between midpoints of its edges:

.                            /\
.                           /  \
.                          /____\
.                         /\    /\
.                        /  \  /  \
.                       /____\/____\

This is how the quad tree is built up to a certain level by decomposing every triangle again and again.

Member Typedef Documentation

typedef std::vector<QuadNode> SpatialIndex::ValueVectorQuad [private]
typedef std::vector<SpatialVector> SpatialIndex::ValueVectorSpvec [private]

Constructor & Destructor Documentation

SpatialIndex::SpatialIndex (  )  [inline]

Constructor. Give the level of the index and optionally the level to build - i.e. the depth to keep in memory. if maxlevel - buildlevel > 0 , that many levels are generated on the fly each time the index is called.

SpatialIndex::SpatialIndex ( size_t  maxlevel,
size_t  buildlevel = 5 

Member Function Documentation

float64 SpatialIndex::area ( const SpatialVector v1,
const SpatialVector v2,
const SpatialVector v3 
) const

The area in steradians for a given spatial triangle.

References area().

float64 SpatialIndex::area ( uint64  ID  )  const

The area in steradians for a given index ID.

References nodeVertex().

Referenced by area().

size_t SpatialIndex::getBildLevel (  )  [inline]
size_t SpatialIndex::getMaxlevel (  )  [inline]
uint64 SpatialIndex::idByLeafNumber ( uint32  n  )  const [inline]

Return leaf id for a certain bitlist index. Same as the function above

References leafCount().

Referenced by nameByLeafNumber().

uint64 SpatialIndex::idByName ( const char *  name  )  [static]

NodeName conversion to integer ID.

References HTMNAMEMAX.

Referenced by idByPoint().

uint64 SpatialIndex::idByPoint ( const float64 ra,
const float64 dec 
) const [inline]

find a node by giving a ra,dec in degrees.

References idByPoint().

uint64 SpatialIndex::idByPoint ( SpatialVector vector  )  const

find a node by giving a vector. The ID of the node is returned.

References buildlevel_, gEpsilon, HTMNAMEMAX, ICHILD, idByName(), isInside(), maxlevel_, N, nameById(), nodes_, SpatialVector::normalize(), pointById(), and V.

Referenced by idByPoint(), and nameByPoint().

bool SpatialIndex::isInside ( const SpatialVector v,
const SpatialVector v0,
const SpatialVector v1,
const SpatialVector v2 
) const [private]

References gEpsilon.

Referenced by idByPoint().

uint64 SpatialIndex::leafCount (  )  const [inline]

return number of leaf nodes

References leaves_.

Referenced by idByLeafNumber(), and leafNumberById().

uint32 SpatialIndex::leafNumberById ( uint64  ID  )  const [inline]

Return leaf number in bitlist for a certain ID. Since the ID here means the number computed from the name, this is simply returning ID -leafCount(). Bitlists only work until level 14.

References HTMMAXBIT, leafCount(), and maxlevel_.

void SpatialIndex::makeNewLayer ( size_t  oldlayer  )  [private]

References ICHILD, index_, IV, IW, layers_, N, and newNode().

Referenced by SpatialIndex().

char * SpatialIndex::nameById ( uint64  ID,
char *  name = 0 
) [static]

int32 conversion to a string (name of database). WARNING: if name is already allocated, a size of at least 17 is required. The conversion is done by directly calculating the name from a number. To calculate the name of a certain level, the mechanism is that the name is given by (of nodes in that level) + (id of node). So for example, for the first level, there are 8 nodes, and we get the names from numbers 8 through 15 giving S0,S1,S2,S3,N0,N1,N2,N3. The order is always ascending starting from S0000.. to N3333...


Referenced by idByPoint(), nameByLeafNumber(), nameByPoint(), and pointById().

char * SpatialIndex::nameByLeafNumber ( uint32  n,
char *  name = 0 
) const [inline]

return name for a certain leaf index (to be used for name lookup from a bitlist). This function is simply shorthand for nameById(n + leafCount()).

References idByLeafNumber(), and nameById().

char * SpatialIndex::nameByPoint ( const float64 ra,
const float64 dec,
char *  s = NULL 
) const [inline]

find a node by giving a ra,dec in degrees.

References idByPoint(), and nameById().

char * SpatialIndex::nameByPoint ( SpatialVector vector,
char *  s = NULL 
) const [inline]

find a node by giving a vector.

The ID of the node is returned.

References idByPoint(), and nameById().

uint64 SpatialIndex::newNode ( size_t  v1,
size_t  v2,
size_t  v3,
uint64  id,
uint64  parent 
) [private]

References ICHILD_, index_, IV_, IW_, and N.

Referenced by makeNewLayer(), and SpatialIndex().

void SpatialIndex::nodeVertex ( const size_t  idx,
size_t &  v1,
size_t &  v2,
size_t &  v3 
) const

return index of vertices for a node

References nodes_.

void SpatialIndex::nodeVertex ( const uint64  id,
SpatialVector v1,
SpatialVector v2,
SpatialVector v3 
) const

return the actual vertex vectors

References buildlevel_, IOFFSET, maxlevel_, nodes_, SpatialVector::normalize(), storedleaves_, and vertices_.

Referenced by area(), and pointById().

size_t SpatialIndex::nVertices (  )  const [inline]

return number of vertices

References vertices_.

void SpatialIndex::pointById ( SpatialVector vector,
uint64  ID 
) const

find the vector to the centroid of a triangle represented by the ID

References HTMNAMEMAX, nameById(), nodeVertex(), SpatialVector::x_, SpatialVector::y_, and SpatialVector::z_.

Referenced by idByPoint().

void SpatialIndex::setMaxlevel ( int  level  )  [inline]

set the maximum depth of the layer

References maxlevel_.

void SpatialIndex::showVertices ( ostream &  out  )  const

print all vertices to output stream

References vertices_.

void SpatialIndex::sortIndex (  )  [private]

References IOFFSET, N, nodes_, and ON.

Referenced by SpatialIndex().

void SpatialIndex::vMax ( size_t *  nodes,
size_t *  vertices 
) [private]

References buildlevel_, leaves_, maxlevel_, and storedleaves_.

Referenced by SpatialIndex().

Friends And Related Function Documentation

friend class htmInterface [friend]
friend class RangeConvex [friend]
friend class SpatialConvex [friend]
friend class SpatialDomain [friend]
friend class SpatialEdge [friend]

Member Data Documentation

size_t SpatialIndex::buildlevel_ [private]

Referenced by makeNewLayer(), newNode(), and SpatialIndex().

std::vector<Layer> SpatialIndex::layers_ [private]

Referenced by makeNewLayer(), and SpatialIndex().

Referenced by leafCount(), and vMax().

size_t SpatialIndex::maxlevel_ [private]

Referenced by nodeVertex(), and vMax().

The documentation for this class was generated from the following files:
Generated on Mon Oct 4 10:39:48 2010 for HtmSrc by  doxygen 1.6.3