Class: Dnsruby::RR::LOC

### Home Classes Methods

### In Files

- lib/Dnsruby/resource/LOC.rb

### Parent

Dnsruby::RR

### Methods

- ::precsize_ntoval
- #dms2latlon
- #latlon
- #latlon2deg
- #latlon2dms
- #precsize_valton

### Files

- DNSSEC
- EVENTMACHINE
- EXAMPLES
- README

### Class/Module Index

Quicksearch

- Dnsruby
- Dnsruby::Algorithms
- Dnsruby::Classes
- Dnsruby::CodeMapper
- Dnsruby::Config
- Dnsruby::DNS
- Dnsruby::DecodeError
- Dnsruby::Dnssec
- Dnsruby::Dnssec::ValidationPolicy
- Dnsruby::EncodeError
- Dnsruby::ExtendedRCode
- Dnsruby::FormErr
- Dnsruby::Header
- Dnsruby::Hosts
- Dnsruby::IPv4
- Dnsruby::IPv6
- Dnsruby::Message
- Dnsruby::Message::Section
- Dnsruby::Message::SecurityLevel
- Dnsruby::MetaTypes
- Dnsruby::Modes
- Dnsruby::NXDomain
- Dnsruby::NXRRSet
- Dnsruby::Name
- Dnsruby::Name::Label
- Dnsruby::NotAuth
- Dnsruby::NotImp
- Dnsruby::NotZone
- Dnsruby::Nsec3HashAlgorithms
- Dnsruby::OpCode
- Dnsruby::OtherResolvError
- Dnsruby::QTypes
- Dnsruby::Question
- Dnsruby::RCode
- Dnsruby::RR
- Dnsruby::RR::ANY
- Dnsruby::RR::CERT
- Dnsruby::RR::CERT::CertificateTypes
- Dnsruby::RR::CNAME
- Dnsruby::RR::DHCID
- Dnsruby::RR::DLV
- Dnsruby::RR::DNAME
- Dnsruby::RR::DNSKEY
- Dnsruby::RR::DS
- Dnsruby::RR::DS::DigestTypes
- Dnsruby::RR::DomainName
- Dnsruby::RR::Generic
- Dnsruby::RR::HINFO
- Dnsruby::RR::HIP
- Dnsruby::RR::IN
- Dnsruby::RR::IN::A
- Dnsruby::RR::IN::AAAA
- Dnsruby::RR::IN::AFSDB
- Dnsruby::RR::IN::PX
- Dnsruby::RR::IN::SRV
- Dnsruby::RR::IN::WKS
- Dnsruby::RR::IPSECKEY
- Dnsruby::RR::ISDN
- Dnsruby::RR::KX
- Dnsruby::RR::LOC
- Dnsruby::RR::MB
- Dnsruby::RR::MG
- Dnsruby::RR::MINFO
- Dnsruby::RR::MR
- Dnsruby::RR::MX
- Dnsruby::RR::NAPTR
- Dnsruby::RR::NS
- Dnsruby::RR::NSAP
- Dnsruby::RR::NSEC
- Dnsruby::RR::NSEC3
- Dnsruby::RR::NSEC3PARAM
- Dnsruby::RR::OPT
- Dnsruby::RR::PTR
- Dnsruby::RR::RP
- Dnsruby::RR::RRSIG
- Dnsruby::RR::RT
- Dnsruby::RR::SOA
- Dnsruby::RR::SPF
- Dnsruby::RR::SSHFP
- Dnsruby::RR::SSHFP::Algorithms
- Dnsruby::RR::SSHFP::FpTypes
- Dnsruby::RR::TKEY
- Dnsruby::RR::TSIG
- Dnsruby::RR::TXT
- Dnsruby::RR::X25
- Dnsruby::RRSet
- Dnsruby::Recursor
- Dnsruby::Refused
- Dnsruby::Resolv
- Dnsruby::ResolvError
- Dnsruby::ResolvTimeout
- Dnsruby::Resolver
- Dnsruby::Resolver::EventType
- Dnsruby::SelectThread
- Dnsruby::ServFail
- Dnsruby::SingleResolver
- Dnsruby::TheLog
- Dnsruby::TsigError
- Dnsruby::TsigNotSignedResponseError
- Dnsruby::Types
- Dnsruby::Update
- Dnsruby::VerifyError
- Dnsruby::YXDomain
- Dnsruby::YXRRSet
- Dnsruby::ZoneReader
- Dnsruby::ZoneReader::ParseException
- Dnsruby::ZoneSerialError
- Dnsruby::ZoneTransfer
- Dnsruby::ZoneTransfer::Delta
- Base32

No matching classes.

# Dnsruby::RR::LOC

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

### Constants

CONV_DEG
CONV_MIN
CONV_SEC

  Conversions to/from thousandths of a degree.

DEFAULT_HORIZ_PRE
DEFAULT_MIN

  Defaults (from RFC 1876, Section 3).

DEFAULT_SEC
DEFAULT_SIZE
DEFAULT_VERT_PRE
POWEROFTEN

  Powers of 10 from 0 to 9 (used to speed up calculations).

REFERENCE_ALT

  Reference altitude in centimeters (see RFC 1876).

REFERENCE_LATLON

  Reference lat/lon (see RFC 1876).

### 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

precsize_ntoval(prec) click to toggle source

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

### Public Instance Methods

dms2latlon(deg, min, sec, hem) click to toggle source

    # File lib/Dnsruby/resource/LOC.rb, line 89
    def dms2latlon(deg, min, sec, hem)
      retval=0

      retval = (deg * CONV_DEG) + (min * CONV_MIN) + (sec * CONV_SEC).round;
      retval = -retval if ((hem != nil) && ((hem == "S") || (hem == "W")));
      retval += REFERENCE_LATLON;
      return retval;
    end

latlon() click to toggle source

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
    def latlon
      retlat, retlon = nil

      if (@version == 0)
        retlat = latlon2deg(@latitude);
        retlon = latlon2deg(@longitude);
      end

      return retlat, retlon
    end

latlon2deg(rawmsec) click to toggle source

    # File lib/Dnsruby/resource/LOC.rb, line 116
    def latlon2deg(rawmsec)
      deg=0;

      deg = (rawmsec - reference_latlon) / CONV_DEG;
      return deg;
    end

latlon2dms(rawmsec, hems) click to toggle source

    # File lib/Dnsruby/resource/LOC.rb, line 71
    def latlon2dms(rawmsec, hems)
      # Tried to use modulus here, but Perl dumped core if

      # the value was >= 2**31.

      abs  = (rawmsec - REFERENCE_LATLON).abs;
      deg  = (abs / CONV_DEG).round;
      abs  -= deg * CONV_DEG;
      min  = (abs / CONV_MIN).round;
      abs -= min * CONV_MIN;
      sec  = (abs / CONV_SEC).round;  # $conv_sec

      abs -= sec * CONV_SEC;
      msec = abs;

      hem = hems[(rawmsec >= REFERENCE_LATLON ? 0 : 1), 1]

      return sprintf("%d %02d %02d.%03d %s", deg, min, sec, msec, hem);
    end

precsize_valton(val) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.