Class: Map::Gdal::GdalInfoService
- Inherits:
-
Object
- Object
- Map::Gdal::GdalInfoService
- Includes:
- Base
- Defined in:
- lib/map/gdal/gdal_info_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
- #get_json(options = {}) ⇒ Object
-
#initialize(file) ⇒ GdalInfoService
constructor
A new instance of GdalInfoService.
- #same_min_max? ⇒ Boolean
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) ⇒ GdalInfoService
Returns a new instance of GdalInfoService.
7 8 9 10 |
# File 'lib/map/gdal/gdal_info_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/gdal_info_service.rb', line 6 def file @file end |
Instance Method Details
#call(options = {}) ⇒ Object
29 30 31 |
# File 'lib/map/gdal/gdal_info_service.rb', line 29 def call( = {}) run_command(%{gdalinfo #{options_to_command_line(options)} "#{file}"}) end |
#get_json(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/map/gdal/gdal_info_service.rb', line 20 def get_json( = {}) result = call(.merge({ mm: '', json: '' })) JSON.parse(result) end |
#same_min_max? ⇒ Boolean
12 13 14 15 16 17 18 |
# File 'lib/map/gdal/gdal_info_service.rb', line 12 def same_min_max? json_info = get_json min = json_info['bands'].first['computedMin'].to_f max = json_info['bands'].first['computedMax'].to_f min == max end |