8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/aipp/regions/LS/notam/ENR.rb', line 8
def parse
AIPP.cache.aip ||= read('AIP').css('Ase')
AIPP.cache.dabs ||= read('DABS')
json = read
fail "malformed JSON received from API" unless json.has_key?(:queryNOTAMs)
added_notam_ids = []
json[:queryNOTAMs].each do |row|
next unless row[:notamRaw].match? /^Q\) LS/
if row[:notamRaw].match? /\AW/
year = Time.now.year
if row[:notamRaw].gsub!(/\s*(?:#{year}|#{year+1})\s*(#{NOTAM::Schedule::MONTH_RE})/, ' \1')
warn("HACK: removed braindead years from D item")
end
end
(notam = notam_for(row[:notamRaw])) or next
if respect? notam
next if notam.data[:five_day_schedules] == []
added_notam_ids << notam.data[:id]
add(
case notam.data[:content]
when /\A[DR].AREA.+ACT/, /TMA.+ACT/
if fragment = fragment_for(notam)
AIXM.generic(fragment: fragment_for(notam)).tap do |airspace|
element = airspace.fragment.children.first
element.prepend_child(['<!--', notam.text ,'-->'].join("\n"))
content = ["NOTAM #{notam.data[:id]}", element.at_css('txtName').content].join(": ").strip
element.at_css('txtName').content = content
content = [element.at_css('txtRmk')&.text, notam.data[:translated_content]].join("\n").strip
element.find_or_add_child('txtRmk').content = content
if schedule = notam.data[:five_day_schedules]
timetable = timetable_from(schedule)
element
.find_or_add_child('Att', before_css: %w(codeSelAvbl txtRmk))
.replace(timetable.to_xml(as: :Att).chomp)
end
end
else
warn "no feature found for `#{notam.data[:content]}' - fallback to point and radius"
airspace_from(notam).tap do |airspace|
airspace.geometry = geometry_from_q_item(notam)
end
end
when /\ATEMPO [DR].AREA.+(?:ACT|EST|ESTABLISHED) WI AREA/
airspace_from(notam).tap do |airspace|
airspace.geometry = geometry_from_content(notam)
end
else
airspace_from(notam).tap do |airspace|
airspace.geometry = geometry_from_q_item(notam)
end
end
)
else
verbose_info("Skipping NOTAM #{notam.data[:id]}")
end
end
dabs_cross_check(added_notam_ids)
end
|