SphericalHTM API


This is the high-level general purpose interface to HTM functions. The HTM.Cover class is used for making tables of HID ranges that cover regions. The HTM.Trixel class allows you to convert between location and HtmID. The HTM.Parser class turns text desciptions into Region objects. The HTM.Sql class provides the interface for SQL Server 2005 (Yukon).

Database programmability

When the SpatialHTM and associated extended procedures are properly loaded into SqlServer2005, there are a host of functions to manipulate spatial indexes. They are described in great detail in TBD.

As an example, to obtain the HtmID for a location RA = 30, and DEC = 34, you would issue the SQL command

select dbo.fHtmEq(30, 34)
(1 row(s) affected)

To get a list of level 20 HtmID ranges for a region that is a disk centered at geographic coordinates Lat=N39.3008, Lon=W76.610616 with a 30 arc-minute (roughly one mile) radius, use the installed table valued function fHtmCoverRegion:
select * from dbo.fHtmCoverRegion('CIRCLE LATLON 39.3008 -76.610616 30')
HtmIDStart           HtmIDEnd
-------------------- --------------------
14026624991232       14026658545663
14026675322880       14026692100095
14026725654528       14026742431743
14026759208960       14026775986175
14026960535552       14026977312767
14026994089984       14027027644415
14027094753280       14027161862143
14027245748224       14027262525439
14027312857088       14027363188735
(9 row(s) affected)
You can see them in


There are currently two libraries, Spherical and HTM. The three classes in the HTM library, Parser, Cover and Trixel are the only ones with a public interface to operate, manage and compute HhmIDs. The essential librarly of routines that manage regions, convexes and halfspaces are descibed elsewhere link TBD, but will be moved under this suite of API documents. Spherical handles all the analog stuff with convexes, whereas HTM uses Spherical to handle the digital spherical grid stuff.

HTM Overview

A better overview is in The Primer
May 27, 2007 György Fekete V 3.1.2