lib/atc-tools/airport.rb in atc-tools-1.0.1 vs lib/atc-tools/airport.rb in atc-tools-1.0.2
- old
+ new
@@ -20,11 +20,11 @@
# Params:
# :code, :name, :variance
def initialize(code = nil, **kvargs)
@code = code || (kvargs.fetch :code, '')
@name = kvargs.fetch :name, ''
- @variance = kvargs.fetch :variance, 17.0 # TODO: Detect this intelligently.
+ @variance = kvargs.fetch :variance, 20.0 # ZSE Standard Variance
end
# Airport's full name.
def name
discover_name if @name.empty?
@@ -54,12 +54,12 @@
end
# Calculate the true heading to the specified airport.
# Takes an ICAO code or Airport object.
def true_heading_to(arrival)
- @heading_uri = "http://www6.landings.com/cgi-bin/nph-dist_apt?airport1=#{@code.downcase}&airport2=#{arrival.to_s.strip.downcase}"
+ @heading_uri = "http://www.aeroplanner.com/calculators/avcalcdist.cfm?typ1=APT&Txt1=#{@code.downcase}&typ2=APT&Txt2=#{arrival.to_s.strip.downcase}&londir1=East&lond=&londir2=East&londd=&lonmm=&lonss=&calculate=Calculate"
response = Net::HTTP.get URI heading_uri
- r = response.scan /(?:heading:)\s*([\d\.]+)\s+/
+ r = response.scan /(?i:<b>\s*initial course:\s*<\/b>)\s*\b([\d\.]+)\b/
raise ATCTools::HeadingDiscoveryError, "Heading from #{@code.upcase} to #{arrival.to_s.upcase} not found." \
unless r.count > 0
true_hdg = r.flatten.first.to_f
\ No newline at end of file