module AIPP::LF::Helpers::Base
Constants
- ANGLICISE_MAP
Transform French text fragments to English
- BORDERS
Map border names to OFMX
- INTERSECTIONS
Intersection points between three countries
- SURFACES
Map surface to OFMX composition, preparation and remarks
Public Instance Methods
anglicise(name:)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 106 def anglicise(name:) 107 name&.uptrans&.tap do |string| 108 ANGLICISE_MAP.each do |regexp, replacement| 109 string.gsub!(regexp, replacement) 110 end 111 end 112 end
d_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 144 def d_from(text) 145 case text 146 when nil then nil 147 when /(\d+)(\w+)/ then AIXM.d($1.to_i, $2.to_sym) 148 else fail "d `#{text}' not recognized" 149 end 150 end
elevation_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 152 def elevation_from(text) 153 value, unit = text.strip.split 154 AIXM.z(AIXM.d(value.to_i, unit).to_ft.dist, :qnh) 155 end
geometry_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 170 def geometry_from(text) 171 AIXM.geometry.tap do |geometry| 172 buffer = {} 173 text.gsub(/\s+/, ' ').strip.split(/ - /).append('end').each do |element| 174 case element 175 when /arc (anti-)?horaire .+ sur (\S+) , (\S+)/i 176 geometry.add_segment AIXM.arc( 177 xy: buffer.delete(:xy), 178 center_xy: AIXM.xy(lat: $2, long: $3), 179 clockwise: $1.nil? 180 ) 181 when /cercle de ([\d\.]+) (NM|km|m) .+ sur (\S+) , (\S+)/i 182 geometry.add_segment AIXM.circle( 183 center_xy: AIXM.xy(lat: $3, long: $4), 184 radius: AIXM.d($1.to_f, $2) 185 ) 186 when /end|(\S+) , (\S+)/ 187 geometry.add_segment AIXM.point(xy: buffer[:xy]) if buffer.has_key?(:xy) 188 buffer[:xy] = AIXM.xy(lat: $1, long: $2) if $1 189 if border = buffer.delete(:border) 190 from = border.nearest(xy: geometry.segments.last.xy) 191 to = border.nearest(xy: buffer[:xy], geometry_index: from.geometry_index) 192 geometry.add_segments border.segment(from_position: from, to_position: to).map(&:to_point) 193 end 194 when /^frontière ([\w-]+)/i, /^(\D[^(]+)/i 195 border_name = BORDERS.fetch($1.downcase.strip) 196 if borders.has_key? border_name # border from GeoJSON 197 buffer[:border] = borders[border_name] 198 else # named border 199 buffer[:xy] ||= INTERSECTIONS.fetch("#{buffer[:border_name]}|#{border_name}") 200 buffer[:border_name] = border_name 201 if border_name == 'FRANCE_SPAIN' # specify which part of this split border 202 border_name += buffer[:xy].lat < 42.55 ? '_EAST' : '_WEST' 203 end 204 geometry.add_segment AIXM.border( 205 xy: buffer.delete(:xy), 206 name: border_name 207 ) 208 end 209 else 210 fail "geometry `#{element}' not recognized" 211 end 212 end 213 end 214 end
layer_from(text_for_limit, text_for_class=nil)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 157 def layer_from(text_for_limit, text_for_class=nil) 158 above, below = text_for_limit.gsub(/ /, '').split(/\n+/).select(&:blank_to_nil).split { _1.match? '---+' } 159 AIXM.layer( 160 class: text_for_class, 161 vertical_limit: AIXM.vertical_limit( 162 upper_z: z_from(above[0]), 163 max_z: z_from(above[1]), 164 lower_z: z_from(below[0]), 165 min_z: z_from(below[1]) 166 ) 167 ) 168 end
organisation_lf()
click to toggle source
Templates
# File lib/aipp/regions/LF/helpers/base.rb 89 def organisation_lf 90 @organisation_lf ||= AIXM.organisation( 91 name: 'FRANCE', 92 type: 'S' 93 ).tap do |organisation| 94 organisation.id = 'LF' 95 end 96 end
prepare(html:)
click to toggle source
Transformations
# File lib/aipp/regions/LF/helpers/base.rb 100 def prepare(html:) 101 html.tap do |node| 102 node.css('del, *[class*="AmdtDeletedAIRAC"]').each(&:remove) # remove deleted entries 103 end 104 end
source(position:, aip_file: nil)
click to toggle source
Parsers
# File lib/aipp/regions/LF/helpers/base.rb 116 def source(position:, aip_file: nil) 117 aip_file ||= @aip 118 [ 119 options[:region], 120 aip_file.split('-').first, 121 aip_file, 122 options[:airac].date.xmlschema, 123 position 124 ].join('|') 125 end
timetable_from!(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 216 def timetable_from!(text) 217 if text.gsub!(/^\s*#{AIXM::H_RE}\s*$/, '') 218 AIXM.timetable(code: Regexp.last_match&.to_s&.strip) 219 end 220 end
xy_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 127 def xy_from(text) 128 parts = text.strip.split(/\s+/) 129 AIXM.xy(lat: parts[0], long: parts[1]) 130 end
z_from(limit)
click to toggle source
# File lib/aipp/regions/LF/helpers/base.rb 132 def z_from(limit) 133 case limit 134 when nil then nil 135 when 'SFC' then AIXM::GROUND 136 when 'UNL' then AIXM::UNLIMITED 137 when /(\d+)ftASFC/ then AIXM.z($1.to_i, :qfe) 138 when /(\d+)ftAMSL/ then AIXM.z($1.to_i, :qnh) 139 when /FL(\d+)/ then AIXM.z($1.to_i, :qne) 140 else fail "z `#{limit}' not recognized" 141 end 142 end