metar-parser 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/metar/station.rb +7 -4
- data/lib/metar.rb +1 -1
- metadata +2 -2
data/lib/metar/station.rb
CHANGED
@@ -49,13 +49,15 @@ module Metar
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_longitude(s)
|
52
|
-
s =~ /^(\d+)-(\d+)([EW])/ or return nil
|
53
|
-
|
52
|
+
s =~ /^(\d+)-(\d+)(-(\d+))?([EW])/ or return nil
|
53
|
+
seconds = $4 ? $4.to_f / 3600.0 : 0.0
|
54
|
+
($5 == 'E' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0 + seconds)
|
54
55
|
end
|
55
56
|
|
56
57
|
def to_latitude(s)
|
57
|
-
s =~ /^(\d+)-(\d+)([SN])/ or return nil
|
58
|
-
|
58
|
+
s =~ /^(\d+)-(\d+)(-(\d+))?([SN])/ or return nil
|
59
|
+
seconds = $4 ? $4.to_f / 3600.0 : 0.0
|
60
|
+
($3 == 'N' ? 1.0 : -1.0) * ($1.to_f + $2.to_f / 60.0 + seconds)
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
@@ -159,6 +161,7 @@ module Metar
|
|
159
161
|
|
160
162
|
# Get data from the NOAA data file (very slow on first call!)
|
161
163
|
def load!
|
164
|
+
return if @loaded
|
162
165
|
noaa_data = Station.find_data_by_cccc(@cccc)
|
163
166
|
raise "Station identifier '#{ @cccc }' not found" if noaa_data.nil?
|
164
167
|
@name = noaa_data[:name]
|
data/lib/metar.rb
CHANGED