edu.jhu.htm.core
Class HTMindexImp

java.lang.Object
  |
  +--edu.jhu.htm.core.HTMindexImp
All Implemented Interfaces:
HTMindex

public class HTMindexImp
extends java.lang.Object
implements HTMindex

HTMindex is the class for the the sky indexing routines. Author: Peter Z. Kunszt initial java port by William O'Mullane 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. For a complete descrption, please go to the HTM index website

This implementation builds the index up to a specified level (maxlevel) You can specify that it should keep the first few levels in memory with the second constructor argument (buildlevel). The default buildlevel is 5.

  Current Version
  ===============
  ID:	$Id: HTMindexImp.java,v 1.2 2003/02/19 15:46:11 womullan Exp $
  Revision: 	$Revision: 1.2 $
  Date/time:	$Date: 2003/02/19 15:46:11 $
 

Version:
$Revision: 1.2 $
Author:
Peter Kunszt

Field Summary
 int addlevel_
           
 int buildlevel_
           
protected  int index_
           
protected  int lastSavedLeafIndex_
           
protected  java.util.List layers_
           
protected  int leaves_
           
 int maxlevel_
           
protected  int nNodes_
           
protected  java.util.List nodes_
           
protected  int nVertices_
           
protected  int storedleaves_
           
protected  java.util.List vertices_
           
 
Constructor Summary
HTMindexImp()
          Constructor: depth 20 - keeping 5 levels in memory by default
HTMindexImp(double degResolution)
          COnstructor for index - pass your desired resolution in degrees this will contruct a HTM of level such that the triabgle widht is just less than the desired resolution.
HTMindexImp(int maxlevel)
          Constructor: give only the level to build - keeping 5 levels in memory by default
HTMindexImp(int maxlevel, int buildlevel)
          Constructor : give the level of the index and optionally the level to build - i.e.
 
Method Summary
 double area(java.lang.String htmName)
          The area in steradians for a given index ID
 double area(Vector3d n0, Vector3d n1, Vector3d n2)
          area: routine to precompute the area of a node using AREA = 4*arctan sqrt(tan(s/2)tan((s-a)/2)tan((s-b)/2)tan((s-c)/2)) with s = (a+b+c)/2 (with many thanks to Eduard Masana @ University of Barcelona)
 Domain compliment(Domain d)
          not implemented yet
 boolean contains(Domain d, Vector3d p)
          does the domain coaintain thie given point
 double distance(long htmId1, long htmId2)
          calls HTMfunc
 double distance(java.lang.String htmName1, java.lang.String htmName2)
          calls HTMfunc
 int idByLeafNumber(int n)
          return leaf id for a certain bitlist index.
 java.lang.String idToName(long id)
          calls HTMfunc
 Vector3d idToPoint(long htmId)
          for the given id return the vector at the center of the triangle calls HTMfunc
 Vector3d idToPoint(java.lang.String htmName)
          for the given id return the vector at the center of the triangle calls HTMfunc
protected  void init(int maxlevel, int buildlevel)
           
 HTMrange intersect(Domain d)
          performs the intersection by calling domain.intersect
 Domain intersection(Domain d1, Domain d2)
          not implemented yet
 int leafCount()
          leafCount: return number of leaf nodes
 int leafNumberById(long id)
          return leaf number in bitlist for a certain ID.
 java.lang.String lookup(double ra, double dec)
          find a node by giving a ra,dec in degrees.
 java.lang.String lookup(Vector3d v)
          find a node by giving a vector.
 long lookupId(double ra, double dec)
          find a node by giving a ra,dec in degrees.
 long lookupId(Vector3d v)
          find a node by giving a vector.
 java.lang.String nameByLeafNumber(int n)
          return name for a certain leaf index This function is simply shorthand for nameById(n + leafCount()).
 long nameToId(java.lang.String name)
          This calls HTMfunc .
 int newNode(int v1, int v2, int v3, long id, int parent)
          Make a new Node: insert a new node_[] into the list.
 Vector3d[] nodeVertex(int leaf)
          nodeVertex: return the vectors of the vertices, based on a bitlist leaf index
 int[] nodeVertexIds(int idx)
          nodeVertex: return index of vertices for a node
 int nVertices()
          nVertices: return number of vertices
 void showVertices(java.io.PrintStream out)
          showVertices: print every vertex to the output stream
 Domain simplify(Domain d)
          return a HTM id number for a given position
 Domain smooth(Domain d)
          not implemented yet
 Domain union(Domain d1, Domain d2)
          creates a new domain which contains all convexces of d1 and d2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxlevel_

public int maxlevel_

buildlevel_

public int buildlevel_

addlevel_

public int addlevel_

leaves_

protected int leaves_

storedleaves_

protected int storedleaves_

nodes_

protected java.util.List nodes_

layers_

protected java.util.List layers_

vertices_

protected java.util.List vertices_

index_

protected int index_

nNodes_

protected int nNodes_

nVertices_

protected int nVertices_

lastSavedLeafIndex_

protected int lastSavedLeafIndex_
Constructor Detail

HTMindexImp

public HTMindexImp(double degResolution)
            throws HTMException
COnstructor for index - pass your desired resolution in degrees this will contruct a HTM of level such that the triabgle widht is just less than the desired resolution. Starts at level 5 2.8 degrees.


HTMindexImp

public HTMindexImp()
Constructor: depth 20 - keeping 5 levels in memory by default


HTMindexImp

public HTMindexImp(int maxlevel)
Constructor: give only the level to build - keeping 5 levels in memory by default


HTMindexImp

public HTMindexImp(int maxlevel,
                   int buildlevel)
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.

Method Detail

init

protected void init(int maxlevel,
                    int buildlevel)

showVertices

public void showVertices(java.io.PrintStream out)
showVertices: print every vertex to the output stream


nodeVertexIds

public int[] nodeVertexIds(int idx)
nodeVertex: return index of vertices for a node


nodeVertex

public Vector3d[] nodeVertex(int leaf)
nodeVertex: return the vectors of the vertices, based on a bitlist leaf index


newNode

public int newNode(int v1,
                   int v2,
                   int v3,
                   long id,
                   int parent)
Make a new Node: insert a new node_[] into the list. The vertex indices are given by v1,v2,v3 and the id of the node is set.


area

public double area(java.lang.String htmName)
The area in steradians for a given index ID

Specified by:
area in interface HTMindex

area

public double area(Vector3d n0,
                   Vector3d n1,
                   Vector3d n2)
area: routine to precompute the area of a node using AREA = 4*arctan sqrt(tan(s/2)tan((s-a)/2)tan((s-b)/2)tan((s-c)/2)) with s = (a+b+c)/2 (with many thanks to Eduard Masana @ University of Barcelona)


nameToId

public long nameToId(java.lang.String name)
              throws HTMException
This calls HTMfunc .

Specified by:
nameToId in interface HTMindex
HTMException

idToName

public java.lang.String idToName(long id)
                          throws HTMException
calls HTMfunc

Specified by:
idToName in interface HTMindex
HTMException

lookupId

public long lookupId(Vector3d v)
              throws HTMException
find a node by giving a vector. The ID of the node is returned.

Specified by:
lookupId in interface HTMindex
HTMException

lookup

public java.lang.String lookup(Vector3d v)
                        throws HTMException
find a node by giving a vector. The Name of the node is returned.

Specified by:
lookup in interface HTMindex
HTMException

leafCount

public int leafCount()
leafCount: return number of leaf nodes


nVertices

public int nVertices()
nVertices: return number of vertices


leafNumberById

public int leafNumberById(long id)
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().


idByLeafNumber

public int idByLeafNumber(int n)
return leaf id for a certain bitlist index. Same as the function above


nameByLeafNumber

public java.lang.String nameByLeafNumber(int n)
return name for a certain leaf index This function is simply shorthand for nameById(n + leafCount()).


lookup

public java.lang.String lookup(double ra,
                               double dec)
                        throws HTMException
find a node by giving a ra,dec in degrees.

Specified by:
lookup in interface HTMindex
HTMException

lookupId

public long lookupId(double ra,
                     double dec)
              throws HTMException
find a node by giving a ra,dec in degrees.

Specified by:
lookupId in interface HTMindex
HTMException

idToPoint

public Vector3d idToPoint(long htmId)
                   throws HTMException
for the given id return the vector at the center of the triangle calls HTMfunc

Specified by:
idToPoint in interface HTMindex
HTMException

idToPoint

public Vector3d idToPoint(java.lang.String htmName)
                   throws HTMException
for the given id return the vector at the center of the triangle calls HTMfunc

Specified by:
idToPoint in interface HTMindex
HTMException

simplify

public Domain simplify(Domain d)
Description copied from interface: HTMindex
return a HTM id number for a given position

Specified by:
simplify in interface HTMindex

contains

public boolean contains(Domain d,
                        Vector3d p)
Description copied from interface: HTMindex
does the domain coaintain thie given point

Specified by:
contains in interface HTMindex

distance

public double distance(long htmId1,
                       long htmId2)
                throws HTMException
calls HTMfunc

Specified by:
distance in interface HTMindex
HTMException

distance

public double distance(java.lang.String htmName1,
                       java.lang.String htmName2)
                throws HTMException
calls HTMfunc

Specified by:
distance in interface HTMindex
HTMException

intersect

public HTMrange intersect(Domain d)
performs the intersection by calling domain.intersect

Specified by:
intersect in interface HTMindex

intersection

public Domain intersection(Domain d1,
                           Domain d2)
not implemented yet

Specified by:
intersection in interface HTMindex

union

public Domain union(Domain d1,
                    Domain d2)
creates a new domain which contains all convexces of d1 and d2

Specified by:
union in interface HTMindex

compliment

public Domain compliment(Domain d)
not implemented yet

Specified by:
compliment in interface HTMindex

smooth

public Domain smooth(Domain d)
not implemented yet

Specified by:
smooth in interface HTMindex