Powers of 10 from 0 to 9 (used to speed up calculations).
Reference altitude in centimeters (see RFC 1876).
Reference lat/lon (see RFC 1876).
Conversions to/from thousandths of a degree.
Defaults (from RFC 1876, Section 3).
The version number of the representation; programs should always check this. Dnsruby currently supports only version 0.
The latitude of the center of the sphere described by the size method, in thousandths of a second of arc. 2**31 represents the equator; numbers above that are north latitude.
# File lib/Dnsruby/resource/LOC.rb, line 89
89: def dms2latlon(deg, min, sec, hem)
90: retval=0
91:
92: retval = (deg * CONV_DEG) + (min * CONV_MIN) + (sec * CONV_SEC).round;
93: retval = -retval if ((hem != nil) && ((hem == "S") || (hem == "W")));
94: retval += REFERENCE_LATLON;
95: return retval;
96: end
Returns the latitude and longitude as floating-point degrees. Positive numbers represent north latitude or east longitude; negative numbers represent south latitude or west longitude.
lat, lon = rr.latlon
system("xearth", "-pos", "fixed #{lat} #{lon}")
# File lib/Dnsruby/resource/LOC.rb, line 105
105: def latlon
106: retlat, retlon = nil
107:
108: if (@version == 0)
109: retlat = latlon2deg(@latitude);
110: retlon = latlon2deg(@longitude);
111: end
112:
113: return retlat, retlon
114: end
# File lib/Dnsruby/resource/LOC.rb, line 116
116: def latlon2deg(rawmsec)
117: deg=0;
118:
119: deg = (rawmsec - reference_latlon) / CONV_DEG;
120: return deg;
121: end
# File lib/Dnsruby/resource/LOC.rb, line 71
71: def latlon2dms(rawmsec, hems)
72: # Tried to use modulus here, but Perl dumped core if
73: # the value was >= 2**31.
74:
75: abs = (rawmsec - REFERENCE_LATLON).abs;
76: deg = (abs / CONV_DEG).round;
77: abs -= deg * CONV_DEG;
78: min = (abs / CONV_MIN).round;
79: abs -= min * CONV_MIN;
80: sec = (abs / CONV_SEC).round; # $conv_sec
81: abs -= sec * CONV_SEC;
82: msec = abs;
83:
84: hem = hems[(rawmsec >= REFERENCE_LATLON ? 0 : 1), 1]
85:
86: return sprintf("%d %02d %02d.%03d %s", deg, min, sec, msec, hem);
87: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.