Class: Map::Gdal::WarpService

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

Overview

gdalwarp - image reprojection and warping utility www.gdal.org/gdalwarp.html

Instance Attribute Summary collapse

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(tif) ⇒ WarpService

Returns a new instance of WarpService.



9
10
11
# File 'lib/map/gdal/warp_service.rb', line 9

def initialize(tif)
  @tif = tif
end

Instance Attribute Details

#tifObject (readonly)

Returns the value of attribute tif.



8
9
10
# File 'lib/map/gdal/warp_service.rb', line 8

def tif
  @tif
end

Instance Method Details

#call(options) ⇒ Object



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

def call(options)
  raise "Arquivo TIF inválido. [#{tif.inspect}]" unless tif && File.exist?(tif)

  out = get_path_to_temp_file(:warp, :tif)
  run_command(%{gdalwarp -q -overwrite #{options_to_command_line(options)} "#{tif}" "#{out}"})

  add_to_clean(out)
  out
end