Class: Map::Gdal::ConstrastStretchService
- Inherits:
-
Object
- Object
- Map::Gdal::ConstrastStretchService
- Includes:
- Base
- Defined in:
- lib/map/gdal/contrast_stretch_service.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Attributes included from Base
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(file) ⇒ ConstrastStretchService
constructor
A new instance of ConstrastStretchService.
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) ⇒ ConstrastStretchService
Returns a new instance of ConstrastStretchService.
7 8 9 10 |
# File 'lib/map/gdal/contrast_stretch_service.rb', line 7 def initialize(file) raise 'File does not exist' unless File.exist?(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/map/gdal/contrast_stretch_service.rb', line 6 def file @file end |
Instance Method Details
#call(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/map/gdal/contrast_stretch_service.rb', line 12 def call( = {}) file_out = get_path_to_temp_file(:gdal_contrast_stretch, :tif) add_to_clean(file_out) ['percentile-range'] = '0.02 0.98' if .empty? result = run_command(%{gdal_contrast_stretch #{()} "#{file}" "#{file_out}"}) found_min_max = result.match(/src_range=\[(.+), (.+)\]/) { file: file_out, min: found_min_max[1].to_f, max: found_min_max[2].to_f, } end |