Module: SmoScottishLidar
- Defined in:
- lib/smo_scottish_lidar/client.rb,
lib/smo_scottish_lidar/lister.rb,
lib/smo_scottish_lidar/version.rb,
lib/smo_scottish_lidar/constants.rb,
lib/smo_scottish_lidar/downloader.rb
Defined Under Namespace
Classes: Client, Downloader, Lister
Constant Summary collapse
- VERSION =
"0.1.0"- BUCKET =
"srsp-open-data"- BASE_PREFIX =
"lidar"- REGION =
"eu-west-2"- BASE_URL =
"https://#{BUCKET}.s3.#{REGION}.amazonaws.com"- PHASES =
Valid phases and dataset types derived from the Scottish Government Registry of Open Data on AWS documentation.
%w[phase-1 phase-2 phase-3 phase-4 phase-5 outer-hebrides].freeze
- DATASET_TYPES =
%w[dsm dtm laz].freeze
- OUTER_HEBRIDES_RESOLUTIONS =
Outer Hebrides has resolution sub-folders; all other phases do not.
{ "dsm" => %w[25cm 50cm], "dtm" => %w[25cm 50cm], "laz" => %w[4ppm 16ppm] }.freeze
Class Method Summary collapse
-
.prefix_for(phase, type, resolution: nil) ⇒ Object
Canonical S3 prefix builder.
- .resolve_outer_hebrides_resolution(type, resolution) ⇒ Object
- .validate_phase!(phase) ⇒ Object
- .validate_type!(type) ⇒ Object
Class Method Details
.prefix_for(phase, type, resolution: nil) ⇒ Object
Canonical S3 prefix builder. Returns the prefix string (no bucket). Examples:
prefix_for("phase-1", "dsm") => "lidar/phase-1/dsm/27700/gridded/"
prefix_for("outer-hebrides", "dtm", resolution: "50cm") => "lidar/outer-hebrides/2019/dtm/50cm/27700/gridded/"
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/smo_scottish_lidar/constants.rb', line 25 def self.prefix_for(phase, type, resolution: nil) validate_phase!(phase) validate_type!(type) if phase == "outer-hebrides" res = resolve_outer_hebrides_resolution(type, resolution) "#{BASE_PREFIX}/outer-hebrides/2019/#{type}/#{res}/27700/gridded/" else "#{BASE_PREFIX}/#{phase}/#{type}/27700/gridded/" end end |
.resolve_outer_hebrides_resolution(type, resolution) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/smo_scottish_lidar/constants.rb', line 49 def self.resolve_outer_hebrides_resolution(type, resolution) available = OUTER_HEBRIDES_RESOLUTIONS[type] if resolution.nil? available.first elsif available.include?(resolution) resolution else raise ArgumentError, "Resolution '#{resolution}' not available for outer-hebrides #{type}. " \ "Available: #{available.join(', ')}" end end |
.validate_phase!(phase) ⇒ Object
37 38 39 40 41 |
# File 'lib/smo_scottish_lidar/constants.rb', line 37 def self.validate_phase!(phase) return if PHASES.include?(phase) raise ArgumentError, "Unknown phase '#{phase}'. Valid: #{PHASES.join(', ')}" end |
.validate_type!(type) ⇒ Object
43 44 45 46 47 |
# File 'lib/smo_scottish_lidar/constants.rb', line 43 def self.validate_type!(type) return if DATASET_TYPES.include?(type) raise ArgumentError, "Unknown dataset type '#{type}'. Valid: #{DATASET_TYPES.join(', ')}" end |