Class: Map::Gdal::MergeService

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/map/gdal/merge_service.rb

Instance Attribute Summary

Attributes included from Base

#files_to_clean

Instance Method Summary collapse

Methods included from Base

#add_to_clean, #clean, #gdal_running?, #get_file_name_with_path, #get_layer_name, #get_path_to_temp_file, #options_to_command_line, #run_command, #store_kml, #tmp_file

Constructor Details

#initialize(files) ⇒ MergeService

Returns a new instance of MergeService.



6
7
8
9
# File 'lib/map/gdal/merge_service.rb', line 6

def initialize(files)
  raise 'Files is not an array' unless files.is_a?(Array)
  @files = files
end

Instance Method Details

#call(options = []) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/map/gdal/merge_service.rb', line 11

def call(options = [])
  files = @files.select{ |file| file.downcase[/(.jp2|.tif)$/, 1].present? }.join(' ')
  out = get_path_to_temp_file('merge', 'tif')

  run_command("gdal_merge.py #{options.join(' ')} #{files} -o #{out}")

  add_to_clean(out)
  add_to_clean(out.gsub('tif', 'tfw'))

  out
end