aipp 2.2.2 → 2.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3071c8fa3c85350a820cf89edc762dd69f926810c5a7cc21dfcb9f050e08d04b
4
- data.tar.gz: 6c09089a9c6375b8e7840969b09d644867a41cd3a8d9a5665407c278e2ff1d64
3
+ metadata.gz: '0385e3ecea39a5901ed655b46dd7809097f5893ee48ac42a7258caefd6b143d7'
4
+ data.tar.gz: 29448f03945cea80986b719c21817dce6121b01c2eb351484ccc8185d49a5d5f
5
5
  SHA512:
6
- metadata.gz: 8bd8790d84f2170b2d9505d0b664216134fdaf471acbb2c2e55872f1b54976261b6ac8de83c4bad1cc1ba4f0e0ed92f977fb818f073fd45fbb2ab05107e61a36
7
- data.tar.gz: ca05e4eec29621ec019774d559ab81ed35d41b2c1d70aecc93e653f7a188bcc237dfa6864ada0f6f470d9b3836ed6d96f7033649afbaa32c8107ada6671a1135
6
+ metadata.gz: cc9552790fc6a1e810e12d866437bf868e64d1cec05986ac063113cf4d1170afc7827cc70e96d6001e1021efa21f86634c131eadfdd2db6c882e4b4dda1cdfcf
7
+ data.tar.gz: d86c19825cfdea27a77e9e7add2a5c5239982f9c1b38e54d3557155b44019ef12dcda6dca2076a536c44914d002348ed8f52afc314098c1c464aeb5f21aab1da
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Nothing so far
4
4
 
5
+ ## 2.3.0
6
+
7
+ #### Additions
8
+ * Include the date and time of the last upstream update for LS NOTAM and SHOOT
9
+
5
10
  ## 2.2.2
6
11
 
7
12
  #### Fix
@@ -28,7 +28,7 @@ module AIPP
28
28
  # [.json] Deserialized JSON e.g. as response to a GraphQL query
29
29
  # [.xlsx] Parsed by Roo returning an instance of {Roo::Excelx}[https://www.rubydoc.info/gems/roo/Roo/Excelx]
30
30
  # [.ods] Parsed by Roo returning an instance of {Roo::OpenOffice}[https://www.rubydoc.info/gems/roo/Roo/OpenOffice]
31
- # [.csv] Parsed by Roo returning an instance of {Roo::CSV}[https://www.rubydoc.info/gems/roo/Roo/CSV]
31
+ # [.csv] Parsed by Roo returning an instance of {Roo::CSV}[https://www.rubydoc.info/gems/roo/Roo/CSV] including the first header line
32
32
  # [.txt] Instance of +String+
33
33
  #
34
34
  # @example
@@ -162,19 +162,13 @@ module AIPP
162
162
  end
163
163
 
164
164
  def convert(file)
165
- # TODO: temporary workaround for broken CSV - see https://github.com/svoop/aipp/issues/28
166
- if file.basename.to_s == 'schiessanzeigen.csv'
167
- contents = file.read
168
- contents.gsub!(';Blindgänger Sprengung, Aufräumaktion "SÄNTIS 23";', ';"Blindgänger Sprengung, Aufräumaktion SÄNTIS 23";')
169
- file.write(contents)
170
- end
171
165
  case file.extname
172
166
  when '.xml', '.ofmx' then Nokogiri.XML(::File.open(file), &:noblanks)
173
167
  when '.html' then Nokogiri.HTML5(::File.open(file))
174
168
  when '.json' then JSON.load_file(file, symbolize_names: true)
175
169
  when '.pdf' then AIPP::PDF.new(file)
176
170
  when '.xlsx', '.ods' then Roo::Spreadsheet.open(file.to_s)
177
- when '.csv' then Roo::Spreadsheet.open(file.to_s, csv_options: { col_sep: separator(file) })
171
+ when '.csv' then Roo::Spreadsheet.open(file.to_s, csv_options: { encoding: 'bom|utf-8', headers: false, col_sep: separator(file) })
178
172
  when '.txt' then ::File.read(file)
179
173
  else fail(ArgumentError, "unrecognized file type")
180
174
  end
@@ -11,6 +11,7 @@ module AIPP
11
11
  class Notam
12
12
  Query = Client.parse <<~END
13
13
  query ($region: String!, $series: [String!], $start: Int!, $end: Int!) {
14
+ latestUpdate,
14
15
  queryNOTAMs(
15
16
  filter: {region: $region, series: $series, start: $start, end: $end}
16
17
  ) {
@@ -11,6 +11,7 @@ module AIPP::LS::NOTAM
11
11
  json = read
12
12
  fail "malformed JSON received from API" unless json.has_key?(:queryNOTAMs)
13
13
  added_notam_ids = []
14
+ aixm.sourced_at = Time.at(json[:latestUpdate])
14
15
  json[:queryNOTAMs].each do |row|
15
16
  next unless row[:notamRaw].match? /^Q\) LS/ # only parse national NOTAM
16
17
 
@@ -12,28 +12,40 @@ module AIPP::LS::SHOOT
12
12
  effective_date = AIPP.options.local_effective_at.strftime('%Y%m%d')
13
13
  airac_date = AIRAC::Cycle.new(aixm.effective_at).to_s('%Y-%m-%d')
14
14
  shooting_grounds = {}
15
+ spl_rows = 0
15
16
  read.each_with_index do |row, line|
16
- type, id, date, no_shooting = row[0], row[1], row[2], (row[17] == "1")
17
- next unless type == 'BSZ'
18
- next if no_shooting || date != effective_date
19
- next if AIPP.options.id && AIPP.options.id != id
20
- # TODO: Several BSZ lines may exist for the same shooting area with
21
- # different location codes (aka: partial activations). The geometries
22
- # of those location codes are not currently available, we therefore
23
- # have to merge the data into one record. The geometries should become
24
- # available by the end of 2023 which will make it possible to map
25
- # each line to one geometry and remove the merging logic.
26
- upper_z = row[15] ? AIXM.z(AIXM.d(row[15].to_i + SAFETY, :m).to_ft.dim.round, :qfe) : DEFAULT_Z
27
- (shooting_grounds[id] ||= { schedules: [], upper_z: AIXM::GROUND }).then do |s|
28
- s[:feature] ||= read("shooting_grounds-#{id}").fetch(:feature)
29
- s[:csv_line] ||= line
30
- s[:url] ||= row[10].blank_to_nil
31
- s[:details] = [s[:details], row[6].blank_to_nil].compact.join("\n")
32
- s[:dabs] ||= (row[16] == '1')
33
- s[:upper_z] = upper_z if upper_z.alt > s[:upper_z].alt
34
- s[:schedules] += schedules_for(row)
17
+ case row[0].strip
18
+ when 'TOT'
19
+ date, spl_count = row[1], row[2].to_i
20
+ fail "malformed CSV: #{spl_count} SPL records announced but #{spl_rows} SPL records found" unless spl_count == spl_rows
21
+ aixm.sourced_at = [date, TZInfo::Timezone.get('Europe/Zurich').abbr].join(' ')
22
+ next
23
+ when 'SPL'
24
+ spl_rows += 1
25
+ next
26
+ when 'BSZ'
27
+ id, date, no_shooting = row[1], row[2], (row[17] == "1")
28
+ next if no_shooting || date != effective_date
29
+ next if AIPP.options.id && AIPP.options.id != id
30
+ # TODO: Several BSZ lines may exist for the same shooting area with
31
+ # different location codes (aka: partial activations). The geometries
32
+ # of those location codes are not currently available, we therefore
33
+ # have to merge the data into one record. The geometries should become
34
+ # available by the end of 2023 which will make it possible to map
35
+ # each line to one geometry and remove the merging logic.
36
+ upper_z = row[15] ? AIXM.z(AIXM.d(row[15].to_i + SAFETY, :m).to_ft.dim.round, :qfe) : DEFAULT_Z
37
+ (shooting_grounds[id] ||= { schedules: [], upper_z: AIXM::GROUND }).then do |s|
38
+ s[:feature] ||= read("shooting_grounds-#{id}").fetch(:feature)
39
+ s[:csv_line] ||= line
40
+ s[:url] ||= row[10].blank_to_nil
41
+ s[:details] = [s[:details], row[6].blank_to_nil].compact.join("\n")
42
+ s[:dabs] ||= (row[16] == '1')
43
+ s[:upper_z] = upper_z if upper_z.alt > s[:upper_z].alt
44
+ s[:schedules] += schedules_for(row)
45
+ end
35
46
  end
36
47
  end
48
+ fail "malformed CSV: TOT record missing" unless aixm.sourced_at
37
49
  shooting_grounds.each do |id, data|
38
50
  data in csv_line:, details:, url:, upper_z:, schedules:, dabs:, feature: { geometry: polygons, properties: { bezeichnung: name, infobezeichnung: contact, infotelefonnr: phone, infoemail: email } }
39
51
  schedules = consolidate(schedules)
data/lib/aipp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AIPP
2
- VERSION = "2.2.2".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -27,7 +27,7 @@ cert_chain:
27
27
  k/QvZU05f6HMYBrPogJgIzHC/C5N/yeE4BVEuBDn+10Zb1iu3aDk8sd0uMgukCY8
28
28
  TUmlP5A6NeGdeDJIoLgromAKs+nvI7TWzhQq9ODs51XhxgUFRCvBqUTpjTQigw==
29
29
  -----END CERTIFICATE-----
30
- date: 2024-05-30 00:00:00.000000000 Z
30
+ date: 2024-09-10 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: airac
@@ -58,7 +58,7 @@ dependencies:
58
58
  version: '1'
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.5.2
61
+ version: 1.5.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '1'
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 1.5.2
71
+ version: 1.5.3
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: notam
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,20 @@ dependencies:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 1.1.5
92
+ - !ruby/object:Gem::Dependency
93
+ name: ostruct
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
92
106
  - !ruby/object:Gem::Dependency
93
107
  name: activesupport
94
108
  requirement: !ruby/object:Gem::Requirement
@@ -474,7 +488,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
474
488
  - !ruby/object:Gem::Version
475
489
  version: '0'
476
490
  requirements: []
477
- rubygems_version: 3.5.11
491
+ rubygems_version: 3.5.18
478
492
  signing_key:
479
493
  specification_version: 4
480
494
  summary: Parser for aeronautical information publications
metadata.gz.sig CHANGED
Binary file