SpatialIndex.h

Classes
- SpatialIndex -- Spatial Index class (full description)
Interface
- Public Members
- SpatialIndex(size_t maxlevel, size_t buildlevel =2)
- static uint32 idByName(const char *)
- static char * nameById(uint32 ID, char * name = 0)
- size_t leafNumberById(uint32 ID) const
- uint32 idByLeafNumber(size_t n) const
- char * nameByLeafNumber(size_t n, char * name = 0) const
- uint32 idByPoint(SpatialVector & vector) const
- uint32 idByPoint(const float64 & ra, const float64 & dec) const
- char* nameByPoint(SpatialVector & vector) const
- char* nameByPoint(const float64 & ra, const float64 & dec) const
- size_t leafCount() const
- size_t nVertices() const
- float64 area(uint32 ID) const
- float64 area(const SpatialVector & v1, const SpatialVector & v2, const SpatialVector & v3) const
- void nodeVertex(const size_t leaf, SpatialVector & v1, SpatialVector & v2, SpatialVector & v3) const
- void nodeVertex(const size_t idx, size_t & v1, size_t & v2, size_t & v3) const
- void showVertices(ostream & out) const
- Private Members
- size_t newNode(size_t v1, size_t v2,size_t v3,size_t id,size_t 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
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 Description
SpatialIndex(size_t maxlevel, size_t buildlevel =2)
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.
static uint32 idByName(const char *)
astrostring conversion to int32
static char * nameById(uint32 ID, char * name = 0)
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...
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().
return leaf id for a certain bitlist index. Same as the function above
char * nameByLeafNumber(size_t n, char * name = 0) const
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()).
find a node by giving a vector. The ID of the node is returned.
uint32 idByPoint(const float64 & ra, const float64 & dec) const
find a node by giving a ra,dec in degrees.
find a node by giving a vector. The ID of the node is returned.
char* nameByPoint(const float64 & ra, const float64 & dec) const
find a node by giving a ra,dec in degrees.
return number of leaf nodes
return number of vertices
float64 area(uint32 ID) const
The area in steradians for a given index ID
The area in steradians for a given spatial triangle
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
size_t newNode(size_t v1, size_t v2,size_t v3,size_t id,size_t parent)
FUNCTIONS
insert a new node_[] into the list. The vertex indices are given by
v1,v2,v3 and the id of the node is set.
make new nodes in a new layer.
void vMax(size_t *nodes, size_t *vertices)
return the total number of nodes and vertices
sort the index so that the leaf nodes are at the beginning
Test whether a vector v is inside a triangle v0,v1,v2. Input
triangle has to be sorted in a counter-clockwise direction.
©
Copyright
The Johns Hopkins University 1999, All Rights Reserved.
Peter Z. Kunszt,