Class Dnsruby::RR::LOC
In: lib/Dnsruby/resource/LOC.rb
Parent: RR
Message Update ResolvError EncodeError OtherResolvError ServFail FormErr DecodeError NXRRSet YXDomain NotImp NXDomain VerifyError NotAuth YXRRSet NotZone Refused TsigError CodeMapper Types MetaTypes QTypes Nsec3HashAlgorithms Algorithms OpCode Classes ExtendedRCode Modes RCode Comparable Name RRSet TsigNotSignedResponseError Resolver SingleResolver StandardError TimeoutError ResolvTimeout DNS Dnssec Hosts RR\n[lib/Dnsruby/resource/A.rb\nlib/Dnsruby/resource/AAAA.rb\nlib/Dnsruby/resource/AFSDB.rb\nlib/Dnsruby/resource/CERT.rb\nlib/Dnsruby/resource/DHCID.rb\nlib/Dnsruby/resource/DLV.rb\nlib/Dnsruby/resource/DNSKEY.rb\nlib/Dnsruby/resource/DS.rb\nlib/Dnsruby/resource/HINFO.rb\nlib/Dnsruby/resource/HIP.rb\nlib/Dnsruby/resource/IN.rb\nlib/Dnsruby/resource/IPSECKEY.rb\nlib/Dnsruby/resource/ISDN.rb\nlib/Dnsruby/resource/KX.rb\nlib/Dnsruby/resource/LOC.rb\nlib/Dnsruby/resource/MINFO.rb\nlib/Dnsruby/resource/MX.rb\nlib/Dnsruby/resource/NAPTR.rb\nlib/Dnsruby/resource/NSAP.rb\nlib/Dnsruby/resource/NSEC.rb\nlib/Dnsruby/resource/NSEC3.rb\nlib/Dnsruby/resource/NSEC3PARAM.rb\nlib/Dnsruby/resource/OPT.rb\nlib/Dnsruby/resource/PX.rb\nlib/Dnsruby/resource/RP.rb\nlib/Dnsruby/resource/RRSIG.rb\nlib/Dnsruby/resource/RT.rb\nlib/Dnsruby/resource/SOA.rb\nlib/Dnsruby/resource/SPF.rb\nlib/Dnsruby/resource/SRV.rb\nlib/Dnsruby/resource/SSHFP.rb\nlib/Dnsruby/resource/TKEY.rb\nlib/Dnsruby/resource/TSIG.rb\nlib/Dnsruby/resource/TXT.rb\nlib/Dnsruby/resource/X25.rb\nlib/Dnsruby/resource/domain_name.rb\nlib/Dnsruby/resource/generic.rb\nlib/Dnsruby/resource/resource.rb] Recursor IPv6 IPv4 ZoneTransfer MessageDecoder MessageEncoder Question Header TheLog ValidatorThread PacketSender ResolverRuby Config KeyCache Cache SingleVerifier SelectThread Resolv ZoneReader lib/Dnsruby/DNS.rb lib/Dnsruby/dnssec.rb lib/Dnsruby/Hosts.rb lib/Dnsruby/resource/generic.rb lib/Dnsruby/Recursor.rb lib/Dnsruby/update.rb lib/Dnsruby/ipv6.rb lib/Dnsruby/ipv4.rb lib/Dnsruby/code_mapper.rb lib/Dnsruby/zone_transfer.rb lib/Dnsruby/message.rb lib/Dnsruby/TheLog.rb lib/Dnsruby/resource/resource.rb lib/Dnsruby/validator_thread.rb lib/Dnsruby/PacketSender.rb lib/Dnsruby/Resolver.rb lib/Dnsruby/Config.rb lib/Dnsruby/key_cache.rb lib/Dnsruby/Cache.rb lib/Dnsruby/single_verifier.rb lib/Dnsruby/SingleResolver.rb lib/Dnsruby/select_thread.rb lib/Dnsruby/name.rb lib/dnsruby.rb lib/Dnsruby/resource/TKEY.rb lib/Dnsruby/zone_reader.rb Dnsruby dot/m_61_0.png

Class for DNS Location (LOC) resource records. See RFC 1876 for details.

Methods

Constants

TypeValue = Types::LOC #:nodoc: all
POWEROFTEN = [1, 10, 100, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000]   Powers of 10 from 0 to 9 (used to speed up calculations).
REFERENCE_ALT = 100_000 * 100;   Reference altitude in centimeters (see RFC 1876).
REFERENCE_LATLON = 2**31;   Reference lat/lon (see RFC 1876).
CONV_SEC = 1000;   Conversions to/from thousandths of a degree.
CONV_MIN = 60 * CONV_SEC;
CONV_DEG = 60 * CONV_MIN;
DEFAULT_MIN = 0;   Defaults (from RFC 1876, Section 3).
DEFAULT_SEC = 0;
DEFAULT_SIZE = 1;
DEFAULT_HORIZ_PRE = 10_000;
DEFAULT_VERT_PRE = 10;

Attributes

altitude  [RW]  The altitude of the center of the sphere described by the size method, in centimeters, from a base of 100,000m below the WGS 84 reference spheroid used by GPS.
horiz_pre  [RW]  The horizontal precision of the data, in centimeters.
latitude  [RW]  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.
longitude  [RW]  The longitude of the center of the sphere described by the size method, in thousandths of a second of arc. 2**31 represents the prime meridian; numbers above that are east longitude.
size  [RW]  The diameter of a sphere enclosing the described entity, in centimeters.
version  [RW]  The version number of the representation; programs should always check this. Dnsruby currently supports only version 0.
vert_pre  [RW]  The vertical precision of the data, in centimeters.

Public Class methods

[Source]

     # File lib/Dnsruby/resource/LOC.rb, line 244
244:       def self.precsize_ntoval(prec)
245:         mantissa = ((prec >> 4) & 0x0f) % 10;
246:         exponent = (prec & 0x0f) % 10;
247:         return mantissa * POWEROFTEN[exponent];
248:       end

Public Instance methods

[Source]

    # 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);
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}")

[Source]

     # 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

[Source]

     # 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

[Source]

    # 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

[Source]

     # File lib/Dnsruby/resource/LOC.rb, line 250
250:       def precsize_valton(val)
251:         exponent = 0;
252:         while (val >= 10)
253:           val /= 10;
254:           exponent+=1
255:         end
256:         return (val.round << 4) | (exponent & 0x0f);
257:       end

[Validate]