Class: Map::ShapeToTifService

Inherits:
Object
  • Object
show all
Defined in:
lib/map/shape_to_tif_service.rb

Overview

Converte um shape file para tif

  1. Rasteriza o shape

  2. Faz resample

  3. Aplica escala de cores

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shape_file) ⇒ ShapeToTifService

Returns a new instance of ShapeToTifService.



10
11
12
13
# File 'lib/map/shape_to_tif_service.rb', line 10

def initialize(shape_file)
  @shape_file = shape_file
  @services = []
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#shape_fileObject (readonly)

Returns the value of attribute shape_file.



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

def shape_file
  @shape_file
end

Instance Method Details

#call(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/map/shape_to_tif_service.rb', line 15

def call(options)
  @options = options
  color_result = color
  crop_service = Map::Gdal::CropService.new(color_result[:file])
  original_file = color_result[:file]
  color_result[:file] = crop_service.call({
    reference: IO.read(options[:kml]),
    s_srs: 'WGS84'
  })
  FileUtils.rm_rf(original_file)
  color_result
ensure
  clean_services
end