'----------------------------- ' geoLib visual basic header ' Ver 0.4 11/20/04 ' Ver 0.5 01/08/05 - no change '----------------------------- Option Explicit '------------------------------------------------------------ ' Datum constants '------------------------------------------------------------ Global Const GEO_DATUM_DEFAULT = 0 ' Default datum (WGS84) Global Const GEO_DATUM_AA = 1 ' Datum : Airy 1830 Global Const GEO_DATUM_AN = 2 ' Datum : Australian National Global Const GEO_DATUM_BR = 3 ' Datum : Bessel 1841 Global Const GEO_DATUM_BN = 4 ' Datum : Bessel 1841 (Namibia) Global Const GEO_DATUM_CC = 5 ' Datum : Clarke 1866 Global Const GEO_DATUM_CD = 6 ' Datum : Clarke 1880 Global Const GEO_DATUM_EB = 7 ' Datum : Everest (Brunei, E. Malaysia (Sabah and Sarawak)) Global Const GEO_DATUM_EA = 8 ' Datum : Everest 1830 Global Const GEO_DATUM_EC = 9 ' Datum : Everest 1956 (India and Nepal) Global Const GEO_DATUM_EF = 10 ' Datum : Everest (Pakistan) Global Const GEO_DATUM_EE = 11 ' Datum : Everest 1948 (W. Malaysia and Singapore) Global Const GEO_DATUM_ED = 12 ' Datum : Everest 1969 (W. Malaysia) Global Const GEO_DATUM_RF = 13 ' Datum : Geodetic Reference System 1980 Global Const GEO_DATUM_HE = 14 ' Datum : Helmert 1906 Global Const GEO_DATUM_HO = 15 ' Datum : Hough 1960 Global Const GEO_DATUM_ID = 16 ' Datum : Indonesian 1974 Global Const GEO_DATUM_IN = 17 ' Datum : International 1924 Global Const GEO_DATUM_KA = 18 ' Datum : Krassovsky 1940 Global Const GEO_DATUM_AM = 19 ' Datum : Modified Airy Global Const GEO_DATUM_FA = 20 ' Datum : Modified Fischer 1960 Global Const GEO_DATUM_SA = 21 ' Datum : South American 1969 Global Const GEO_DATUM_WD = 22 ' Datum : WGS 1972 Global Const GEO_DATUM_WE = 23 ' Datum : WGS 1984 Global Const GEO_DATUM_MAX = GEO_DATUM_WE '------------------------------------------------------------ ' Most library function return one of these '------------------------------------------------------------ Global Const GEO_OK = 0 ' Geo Library return OK Global Const GEO_ERROR = 1 ' Geo Library return ERROR '------------------------------------------------------------ ' Define indices for 3-element coordinate set arrays: '------------------------------------------------------------ Global Const GEO_LAT = 0 ' Latitude Global Const GEO_LON = 1 ' Longitude Global Const GEO_HGT = 2 ' Height ( METERS ) Global Const GEO_X = 0 ' X or East coordinate of the tangential plane ( METERS ) Global Const GEO_Y = 1 ' Y or North coordinate of the tangential plane ( METERS ) Global Const GEO_Z = 2 ' Z or Up coordinate of the tangential plane ( METERS ) Global Const GEO_E = 0 ' E coordinate of Earth Fixed Geodetic coordinate ( METERS ) Global Const GEO_F = 1 ' F coordinate of Earth Fixed Geodetic coordinate ( METERS ) Global Const GEO_G = 2 ' G coordinate of Earth Fixed Geodetic coordinate ( METERS ) Global Const GEO_RNG = 0 ' Slant range ( METERS ) Global Const GEO_AZ = 1 ' Azimuth, clockwise from north Global Const GEO_EL = 2 ' Elevation, from horizon (0) up '------------------------------------------------------------ ' geoLib nice-to-haves '------------------------------------------------------------ Global Const GEO_SZ_ELLIPSOID_NAME = 82 ' Max size of the Ellipsoid name field Global Const M_PI = 3.14159265358979 Global Const DEG_TO_RAD = (M_PI / 180#) Global Const RAD_TO_DEG = (180# / M_PI) '------------------------------------------------------------ ' Test coordinates that provide known results '------------------------------------------------------------ Global Const GEO_TEST_LAT = 31.29225 ' Test latitude 31-17-32.1 Global Const GEO_TEST_LON = -85.851056 ' Test longitude 85-51-03.8 Global Const GEO_TEST_HGT = 134# ' Test height in meters Global Const GEO_TEST_DATUM = GEO_DATUM_DEFAULT ' WGS84 Datum '------------------------------------------------------------ 'GEO_LOCATION 'This structure holds all of the pertinent location, ellipsoid, ' and datum data associated with a location. '------------------------------------------------------------ Public Type GEO_LOCATION 'Geodetic coordinates lat As Double ' Site Latitude in decimal degrees lon As Double ' Site Longitude in decimal degrees hgt As Double ' Site Height above the ellipsoid in meters rlat As Double ' Radian value of latitude rlon As Double ' Radian value of longitude ' Sine and Cosine values slat As Double ' Sine of latitude clat As Double ' Cosine of latitude slon As Double ' Sine of longitude clon As Double ' Cosine of longitude tlat As Double ' Tangent of latitude ' Precomputed values (for speed) clonclat As Double ' Cos(lon) * Cos(lat) slonslat As Double ' Sin(lon) * Sin(lat) clonslat As Double ' Cos(lon) * Sin(lat) slonclat As Double ' Sin(lon) * Cos(lat) ' Geocentric coordinates e As Double ' X : Earth Fixed Geocentric (XYZ) Coordinates f As Double ' Y : Earth Fixed Geocentric (XYZ) Coordinates g As Double ' Z : Earth Fixed Geocentric (XYZ) Coordinates ' Ellipsoid values a As Double ' Major Earth axis in meters b As Double ' Minor Earth axis in meters flat As Double ' Earth flattening value e2 As Double ' Eccentricity squared e2p As Double ' Eccentricity squared prime m1e2 As Double ' 1 - eccentricity squared ' Geomagentism Related information ' Caution: this data can change daily! Declination As Double ' Geomagnetic Declination ' Misc values datum As Long ' Numeric datum value name As String ' Site Name End Type '------------------------------------------------------------ ' c lib function tm time ' - used in solar and geomag routines '------------------------------------------------------------ Public Type tm tm_sec As Long ' /* seconds after the minute - [0,59] */ tm_min As Long ' /* minutes after the hour - [0,59] */ tm_hour As Long ' /* hours since midnight - [0,23] */ tm_mday As Long ' /* day of the month - [1,31] */ tm_mon As Long ' /* months since January - [0,11] */ tm_year As Long ' /* years since 1900 */ tm_wday As Long ' /* days since Sunday - [0,6] */ tm_yday As Long ' /* days since January 1 - [0,365] */ tm_isdst As Long ' /* daylight savings time flag */ End Type '------------------------------------------------------------ ' geo function prototypes '------------------------------------------------------------ '---------------------- ' geoEllips function '---------------------- '- void geoGetEllipsoid(double *a,double *b,double *e2,double *ee2,double *f,int datum); Public Declare Sub geoGetEllipsoid Lib "geo.dll" Alias "_geoGetEllipsoid@24" _ (a As Double, b As Double, e2 As Double, ee2 As Double, f As Double, ByVal datum As Long) '- int geoInitLocation(GEO_LOCATION *l, double lat, double lon, double hgt, int datum, char *name); Public Declare Function geoInitLocation Lib "geo.dll" Alias "_geoInitLocation@36" _ (l As GEO_LOCATION, ByVal lat As Double, ByVal lon As Double, ByVal hgt As Double, _ ByVal datum As Long, name As String) As Long '---------------------- ' geoAstro functions '---------------------- '- int geoSunAzElNow(GEO_LOCATION *loc, double *az, double *el); Public Declare Function geoSunAzElNow Lib "geo.dll" Alias "_geoSunAzElNow@12" _ (loc As GEO_LOCATION, az As Double, el As Double) As Long ' int geoSunAzEltm(GEO_LOCATION *loc, double *az, double *el, struct tm *newtime); Public Declare Function geoSunAzEltm Lib "geo.dll" Alias "_geoSunAzEltm@16" _ (loc As GEO_LOCATION, az As Double, el As Double, newtime As tm) As Long '- int geoSunAzElJD(GEO_LOCATION *loc, double *az, double *el, double tjd_now); Public Declare Function geoSunAzElJD Lib "geo.dll" Alias "_geoSunAzElJD@20" _ (loc As GEO_LOCATION, az As Double, el As Double, ByVal tjd_now As Double) As Long '- int geoGetSunError(void); Public Declare Function geoGetSunError Lib "geo.dll" Alias "_geoGetSunError@0" _ () As Long ' - int geoGettm(int part) Public Declare Function geoGettm Lib "geo.dll" Alias "_geoGettm@4" _ (ByVal val As Long) As Long '---------------------- ' geoPoint functions '---------------------- '- int geoEfg2XyzDiff (GEO_LOCATION *src_desc, GEO_LOCATION *tgt_desc, double xyz_disp[]); Public Declare Function geoEfg2XyzDiff Lib "geo.dll" Alias "_geoEfg2XyzDiff@12" _ (src_desc As GEO_LOCATION, tgt_desc As GEO_LOCATION, xyz_disp() As Double) As Long '- void geoRae2Efg (GEO_LOCATION *loc, double aer_in[], double efg_out[]); Public Declare Sub geoRae2Efg Lib "geo.dll" Alias "_geoRae2Efg@12" _ (loc As GEO_LOCATION, aer_in As Double, efg_out As Double) '- void geoEfg2Llh (int datum, double efg[], double *lat, double *lon, double *hgt); Public Declare Sub geoEfg2Llh Lib "geo.dll" Alias "_geoEfg2Llh@20" _ (ByVal datum As Long, lat As Double, lon As Double, hgt As Double) '- void geoLlh2Efg (double lat, double lon, double height,int datum, double *e, double *f, double *g); Public Declare Sub geoLlh2Efg Lib "geo.dll" Alias "_geoLlh2Efg@40" _ (ByVal lat As Double, ByVal lon As Double, ByVal height As Double, ByVal datum As Long, _ e As Double, f As Double, g As Double) '- void geoXyz2Rae (double xyz_in[], double rae_out[]); Public Declare Sub geoXyz2Rae Lib "geo.dll" Alias "_geoXyz2Rae@8" _ (xyz_in As Double, rae_out As Double) '- void geoRae2Xyz (double rae_in[], double xyz_out[]); Public Declare Sub geoRae2Xyz Lib "geo.dll" Alias "_geoRae2Xyz@8" _ (rae_in As Double, xyz_out As Double) '- double geoRads2Decdms(double rads) ; Public Declare Function geoRads2Decdms Lib "geo.dll" Alias "_geoRads2Decdms@8" _ (ByVal rads As Double) As Double '- double geoDecdms2Rads(double in); Public Declare Function geoDecdms2Rads Lib "geo.dll" Alias "_geoDecdms2Rads@8" _ (ByVal inv As Double) As Double '- double geoDms2Rads(double deg, double min, double sec, char *sign); Public Declare Function geoDms2Rads Lib "geo.dll" Alias "_geoDms2Rads@28" _ (ByVal deg As Double, ByVal min As Double, ByVal sec As Double, sign As String) As Double '- void geoRads2Dms(double rads,double *deg, double *min, double *sec, double *dir); Public Declare Sub geoRads2Dms Lib "geo.dll" Alias "_geoRads2Dms@24" _ (ByVal rads As Double, deg As Double, min As Double, sec As Double, dir As Double) '---------------------- ' geoMag functions '---------------------- '- int geomg1( double alt, double glat, double glon, double time, double *dec, double *dip, double *ti, double *gv); Public Declare Function geomg1 Lib "geo.dll" Alias "_geomg1@48" _ (ByVal alt As Double, ByVal glat As Double, ByVal glon As Double, _ ByVal timeVal As Double, decVal As Double, dipVal As Double, tiVal As Double, gvVal As Double) As Long '- int geoMag( double alt, double glat, double glon, double time, double *dec, double *dip, double *ti, double *gv, '- double *adec,double *adip, double *ati, double *x, double *y, double *z, double *h, double *ax, double *ay, double *az, double *ah); Public Declare Function geoMag Lib "geo.dll" Alias "_geoMag@92" _ (ByVal alt As Double, ByVal glat As Double, ByVal glon As Double, _ ByVal timeVal As Double, dec As Double, dip As Double, ti As Double, _ gv As Double, adec As Double, adip As Double, ati As Double, _ x As Double, y As Double, z As Double, h As Double, _ ax As Double, ay As Double, az As Double, ah As Double) As Long '- int geoMagGetDec(double lat, double lon, double hgt, int month, int day, int year, double *dec); Public Declare Function geoMagGetDec Lib "geo.dll" Alias "_geoMagGetDec@40" _ (ByVal lat As Double, ByVal lon As Double, ByVal hgt As Double, _ ByVal monthVal As Long, ByVal dayVal As Long, ByVal yearVal As Long, dec As Double) As Long '- double geoMagGetDecRet(double lat, double lon, double hgt, int month, int day, int year); Public Declare Function geoMagGetDecRet Lib "geo.dll" Alias "_geoMagGetDecRet@36" _ (ByVal lat As Double, ByVal lon As Double, ByVal hgt As Double, _ ByVal monthVal As Long, ByVal dayVal As Long, ByVal yearVal As Long) As Double '- int geoMagFillDec(GEO_LOCATION *l, double *dec); Public Declare Function geoMagFillDec Lib "geo.dll" Alias "_geoMagFillDec@8" _ (l As GEO_LOCATION, dec As Double) As Long