Class: Map::Gdal::RasterService
- Inherits:
-
Object
- Object
- Map::Gdal::RasterService
- Includes:
- Base
- Defined in:
- lib/map/gdal/raster_service.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #call(options) ⇒ Object
-
#initialize(file_input) ⇒ RasterService
constructor
A new instance of RasterService.
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(file_input) ⇒ RasterService
Returns a new instance of RasterService.
6 7 8 9 10 |
# File 'lib/map/gdal/raster_service.rb', line 6 def initialize(file_input) raise 'File does not exist' unless File.exist?(file_input) @file = file_input end |
Instance Method Details
#call(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/map/gdal/raster_service.rb', line 12 def call() out = get_path_to_temp_file(:raster, [:format]) add_to_clean(out) add_to_clean("#{out}.aux.xml") format_out = if [:format] == 'tif' 'GTiff' else [:format].upcase end begin run_command(%{gdal_rasterize -q -of #{format_out} #{options_to_command_line(options, :format)} -l "#{get_layer_name}" "#{@file}" "#{out}"}) rescue RuntimeError => re if re..include?('Failed to find field') cpg_iso = "#{get_file_name_with_path(@file)}.cpg" run_command(%{echo 885910 > "#{cpg_iso}"}) retry elsif raise re end end out end |