aipp 0.2.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -0
  3. data/CHANGELOG.md +38 -0
  4. data/README.md +222 -88
  5. data/exe/aip2aixm +2 -2
  6. data/exe/aip2ofmx +2 -2
  7. data/lib/aipp/aip.rb +113 -31
  8. data/lib/aipp/border.rb +77 -46
  9. data/lib/aipp/debugger.rb +101 -0
  10. data/lib/aipp/downloader.rb +39 -26
  11. data/lib/aipp/executable.rb +41 -22
  12. data/lib/aipp/parser.rb +94 -21
  13. data/lib/aipp/patcher.rb +5 -2
  14. data/lib/aipp/pdf.rb +1 -1
  15. data/lib/aipp/regions/LF/README.md +49 -0
  16. data/lib/aipp/regions/LF/aerodromes.rb +223 -0
  17. data/lib/aipp/regions/LF/d_p_r_airspaces.rb +56 -0
  18. data/lib/aipp/regions/LF/dangerous_activities.rb +49 -0
  19. data/lib/aipp/regions/LF/designated_points.rb +47 -0
  20. data/lib/aipp/regions/LF/fixtures/aerodromes.yml +608 -0
  21. data/lib/aipp/regions/LF/helipads.rb +122 -0
  22. data/lib/aipp/regions/LF/helpers/base.rb +218 -0
  23. data/lib/aipp/regions/LF/helpers/surface.rb +49 -0
  24. data/lib/aipp/regions/LF/helpers/usage_limitation.rb +20 -0
  25. data/lib/aipp/regions/LF/navigational_aids.rb +85 -0
  26. data/lib/aipp/regions/LF/obstacles.rb +153 -0
  27. data/lib/aipp/regions/LF/serviced_airspaces.rb +70 -0
  28. data/lib/aipp/regions/LF/services.rb +172 -0
  29. data/lib/aipp/t_hash.rb +4 -5
  30. data/lib/aipp/version.rb +1 -1
  31. data/lib/aipp.rb +11 -5
  32. data/lib/core_ext/enumerable.rb +9 -9
  33. data/lib/core_ext/hash.rb +21 -5
  34. data/lib/core_ext/nokogiri.rb +54 -0
  35. data/lib/core_ext/string.rb +38 -66
  36. data.tar.gz.sig +2 -0
  37. metadata +180 -188
  38. metadata.gz.sig +0 -0
  39. data/.gitignore +0 -8
  40. data/.ruby-version +0 -1
  41. data/.travis.yml +0 -8
  42. data/.yardopts +0 -3
  43. data/Guardfile +0 -7
  44. data/TODO.md +0 -6
  45. data/aipp.gemspec +0 -44
  46. data/gems.rb +0 -3
  47. data/lib/aipp/airac.rb +0 -55
  48. data/lib/aipp/regions/LF/AD-1.3.rb +0 -162
  49. data/lib/aipp/regions/LF/AD-1.6.rb +0 -31
  50. data/lib/aipp/regions/LF/AD-2.rb +0 -313
  51. data/lib/aipp/regions/LF/AD-3.1.rb +0 -185
  52. data/lib/aipp/regions/LF/ENR-2.1.rb +0 -92
  53. data/lib/aipp/regions/LF/ENR-4.1.rb +0 -97
  54. data/lib/aipp/regions/LF/ENR-4.3.rb +0 -28
  55. data/lib/aipp/regions/LF/ENR-5.1.rb +0 -75
  56. data/lib/aipp/regions/LF/ENR-5.5.rb +0 -53
  57. data/lib/aipp/regions/LF/fixtures/AD-1.3.yml +0 -511
  58. data/lib/aipp/regions/LF/fixtures/AD-2.yml +0 -185
  59. data/lib/aipp/regions/LF/fixtures/AD-3.1.yml +0 -10
  60. data/lib/aipp/regions/LF/helpers/AD_radio.rb +0 -90
  61. data/lib/aipp/regions/LF/helpers/URL.rb +0 -26
  62. data/lib/aipp/regions/LF/helpers/common.rb +0 -217
  63. data/lib/core_ext/object.rb +0 -43
  64. data/rakefile.rb +0 -12
  65. data/spec/fixtures/archive.zip +0 -0
  66. data/spec/fixtures/border.geojson +0 -201
  67. data/spec/fixtures/document.pdf +0 -0
  68. data/spec/fixtures/document.pdf.json +0 -1
  69. data/spec/fixtures/new.html +0 -6
  70. data/spec/fixtures/new.pdf +0 -0
  71. data/spec/fixtures/new.txt +0 -1
  72. data/spec/lib/aipp/airac_spec.rb +0 -98
  73. data/spec/lib/aipp/border_spec.rb +0 -135
  74. data/spec/lib/aipp/downloader_spec.rb +0 -81
  75. data/spec/lib/aipp/patcher_spec.rb +0 -46
  76. data/spec/lib/aipp/pdf_spec.rb +0 -124
  77. data/spec/lib/aipp/t_hash_spec.rb +0 -44
  78. data/spec/lib/aipp/version_spec.rb +0 -7
  79. data/spec/lib/core_ext/enumberable_spec.rb +0 -76
  80. data/spec/lib/core_ext/hash_spec.rb +0 -27
  81. data/spec/lib/core_ext/integer_spec.rb +0 -15
  82. data/spec/lib/core_ext/nil_class_spec.rb +0 -11
  83. data/spec/lib/core_ext/string_spec.rb +0 -112
  84. data/spec/sounds/failure.mp3 +0 -0
  85. data/spec/sounds/success.mp3 +0 -0
  86. data/spec/spec_helper.rb +0 -28
@@ -0,0 +1,56 @@
1
+ module AIPP
2
+ module LF
3
+
4
+ class DPRAirspaces < AIP
5
+
6
+ include AIPP::LF::Helpers::Base
7
+
8
+ # Map source types to type and optional local type
9
+ SOURCE_TYPES = {
10
+ 'D' => { type: 'D' },
11
+ 'P' => { type: 'P' },
12
+ 'R' => { type: 'R' },
13
+ 'ZIT' => { type: 'P', local_type: 'ZIT' }
14
+ }.freeze
15
+
16
+ # Radius to use for zones consisting of one point only
17
+ POINT_RADIUS = AIXM.d(1, :km).freeze
18
+
19
+ def parse
20
+ SOURCE_TYPES.each do |source_type, target|
21
+ verbose_info("processing #{source_type}")
22
+ cache.espace.css(%Q(Espace[lk^="[LF][#{source_type} "])).each do |espace_node|
23
+ # UPSTREAM: Espace[pk=300343] has no Partie/Volume (reported)
24
+ next if espace_node['pk'] == '300343'
25
+ partie_node = cache.partie.at_css(%Q(Partie:has(Espace[pk="#{espace_node['pk']}"])))
26
+ volume_node = cache.volume.at_css(%Q(Volume:has(Partie[pk="#{partie_node['pk']}"])))
27
+ name = "#{options[:region]}-#{source_type}#{espace_node.(:Nom)}".remove(/\s/)
28
+ add(
29
+ AIXM.airspace(
30
+ source: source(section: 'ENR', position: espace_node.line),
31
+ name: "#{name} #{partie_node.(:NomUsuel)}".strip,
32
+ type: target[:type],
33
+ local_type: target[:local_type]
34
+ ).tap do |airspace|
35
+ airspace.geometry = geometry_from(partie_node.(:Contour))
36
+ if airspace.geometry.point? # convert point to circle
37
+ airspace.geometry = AIXM.geometry(
38
+ AIXM.circle(
39
+ center_xy: airspace.geometry.segments.first.xy,
40
+ radius: POINT_RADIUS
41
+ )
42
+ )
43
+ end
44
+ fail("geometry is not closed") unless airspace.geometry.closed?
45
+ airspace.add_layer layer_from(volume_node)
46
+ airspace.layers.first.timetable = timetable_from(volume_node.(:HorCode))
47
+ airspace.layers.first.remarks = volume_node.(:Activite)
48
+ end
49
+ )
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,49 @@
1
+ module AIPP
2
+ module LF
3
+
4
+ class DangerousActivities < AIP
5
+
6
+ include AIPP::LF::Helpers::Base
7
+
8
+ # Map raw activities to type of activity airspace
9
+ ACTIVITIES = {
10
+ 'AP' => { activity: :other, airspace: :dangerous_activities_area },
11
+ 'Aer' => { activity: :aeromodelling, airspace: :dangerous_activities_area },
12
+ 'Bal' => { activity: :balloon, airspace: :dangerous_activities_area },
13
+ 'Pje' => { activity: :parachuting, airspace: :dangerous_activities_area },
14
+ 'TrPVL' => { activity: :glider_winch, airspace: :dangerous_activities_area },
15
+ 'TrPla' => { activity: :glider_winch, airspace: :dangerous_activities_area },
16
+ 'TrVL' => { activity: :glider_winch, airspace: :dangerous_activities_area },
17
+ 'Vol' => { activity: :acrobatics, airspace: :dangerous_activities_area }
18
+ }.freeze
19
+
20
+ def parse
21
+ ACTIVITIES.each do |code, type|
22
+ verbose_info("processing #{code}")
23
+ cache.espace.css(%Q(Espace[lk^="[LF][#{code} "])).each do |espace_node|
24
+ partie_node = cache.partie.at_css(%Q(Partie:has(Espace[pk="#{espace_node['pk']}"])))
25
+ volume_node = cache.volume.at_css(%Q(Volume:has(Partie[pk="#{partie_node['pk']}"])))
26
+ add(
27
+ AIXM.airspace(
28
+ source: source(section: 'ENR', position: espace_node.line),
29
+ id: espace_node.(:Nom),
30
+ type: type[:airspace],
31
+ local_type: code.upcase,
32
+ name: [espace_node.(:Nom), partie_node.(:NomUsuel)].join(' ')
33
+ ).tap do |airspace|
34
+ airspace.geometry = geometry_from partie_node.(:Contour)
35
+ layer_from(volume_node).then do |layer|
36
+ layer.activity = type[:activity]
37
+ airspace.add_layer layer
38
+ end
39
+ airspace.layers.first.timetable = timetable_from(volume_node.(:HorCode))
40
+ airspace.layers.first.remarks = volume_node.(:Remarque)
41
+ end
42
+ )
43
+ end
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,47 @@
1
+ module AIPP
2
+ module LF
3
+
4
+ class DesignatedPoints < AIP
5
+
6
+ include AIPP::LF::Helpers::Base
7
+
8
+ DEPENDS = %w(aerodromes)
9
+
10
+ SOURCE_TYPES = {
11
+ 'VFR' => :vfr_reporting_point,
12
+ 'WPT' => :icao
13
+ }.freeze
14
+
15
+ def parse
16
+ SOURCE_TYPES.each do |source_type, type|
17
+ verbose_info("processing #{source_type}")
18
+ cache.navfix.css(%Q(NavFix[lk^="[LF][#{source_type} "])).each do |navfix_node|
19
+ ident = navfix_node.(:Ident)
20
+ add(
21
+ AIXM.designated_point(
22
+ source: source(section: 'ENR', position: navfix_node.line),
23
+ type: type,
24
+ id: ident.split('-').last.remove(/[^a-z\d]/i), # only use last segment of ID
25
+ name: ident,
26
+ xy: xy_from(navfix_node.(:Geometrie))
27
+ ).tap do |designated_point|
28
+ designated_point.remarks = navfix_node.(:Description)
29
+ if ident.match? /-/
30
+ airport = find_by(:airport, id: "LF#{ident.split('-').first}").first
31
+ designated_point.airport = airport
32
+ end
33
+ end
34
+ )
35
+ end
36
+ end
37
+ AIXM::Memoize.method :to_uid do
38
+ aixm.features.find_by(:designated_point).duplicates.each do |duplicates|
39
+ duplicates.first.name += '/' + duplicates[1..].map(&:name).join('/')
40
+ aixm.remove_features(duplicates[1..])
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end