Class: Map::Gdal::GridService
- Inherits:
-
Object
- Object
- Map::Gdal::GridService
- Includes:
- Base
- Defined in:
- lib/map/gdal/grid_service.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(kml) ⇒ GridService
constructor
A new instance of GridService.
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(kml) ⇒ GridService
Returns a new instance of GridService.
6 7 8 9 |
# File 'lib/map/gdal/grid_service.rb', line 6 def initialize(kml) @kml = kml store_kml end |
Instance Method Details
#call(options = {}) ⇒ Object
11 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/grid_service.rb', line 11 def call( = {}) raise 'Invalid field' unless [:field] out = get_path_to_temp_file('out', 'kml') where = [:where] ? "-where \"#{options[:where]}\"" : '' algorithm = [:algorithm] ? "-a #{options[:algorithm]}" : '' run_command( %{ gdal_grid -q #{algorithm} #{where} -zfield "#{options[:field]}" -of GTiff -ot Float64 -l "#{get_layer_name}" #{@file} #{out} }.squish ) add_to_clean(out) out end |