Method: AIPP::LS::Helpers::Base#origin_for

Defined in:
lib/aipp/regions/LS/helpers/base.rb

#origin_for(document) ⇒ Object

Mandatory Interface



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
# File 'lib/aipp/regions/LS/helpers/base.rb', line 32

def origin_for(document)
  case document
  when 'ENR'
    variables = {
      region: 'LS',
      series: %w(W B),
      start: aixm.effective_at.beginning_of_day.to_i,
      end: aixm.expiration_at.to_i
    }
    verbose_info("Querying API with #{variables}")
    AIPP::Downloader::GraphQL.new(
      client: AIPP::NewayAPI::Client,
      query: AIPP::NewayAPI::Notam::Query,
      variables: variables
    )
  when 'AD'
    fail "not yet implemented"
  when 'AIP'
    AIPP::Downloader::HTTP.new(
      file: "https://snapshots.openflightmaps.org/live/#{AIRAC::Cycle.new.id}/ofmx/lsas/latest/isolated/ofmx_ls.xml"
    )
  when 'DABS'
    if aixm.effective_at.to_date == Time.now.utc.to_date   # DABS cross check works reliably for today only
      AIPP::Downloader::HTTP.new(
        file: "https://www.skybriefing.com/o/dabs?today",
        type: :pdf
      )
    end
  when 'shooting_grounds'
    AIPP::Downloader::HTTP.new(
      file: "https://data.geo.admin.ch/ch.vbs.schiessanzeigen/schiessanzeigen/schiessanzeigen.csv",
      type: :csv
    )
  when /^shooting_grounds-(\d+\.\d+)/
    AIPP::Downloader::HTTP.new(
      file: "https://api3.geo.admin.ch/rest/services/api/MapServer/ch.vbs.schiessanzeigen/#{$1}?sr=4326&geometryFormat=geojson",
      type: :json
    )
  else
    fail "document not recognized"
  end
end