Class: Map::Gdal::OgriInfoService

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

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(file) ⇒ OgriInfoService

Returns a new instance of OgriInfoService.



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

def initialize(file)
  raise 'File does not exist' unless File.exist?(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/map/gdal/ogri_info_service.rb', line 6

def file
  @file
end

Instance Method Details

#layer_nameObject



12
13
14
15
16
# File 'lib/map/gdal/ogri_info_service.rb', line 12

def layer_name
  # quando é um shapefile a informação vem seguida do tipo de dado
  # Exemplo: Campinho (Point)
  call(q: '').gsub(/\d+:/, '').gsub(/\s\(.+$/, '').strip
end

#limitsObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/map/gdal/ogri_info_service.rb', line 18

def limits
  # Saída de exemplo Extent: (-52.726602, -27.567020) - (-52.714728, -27.554208)
  # O match retorna[1] (-52.726602, -27.567020) - (-52.714728, -27.554208)
  # O primeiro gsub retorna (-52.726602, -27.567020) (-52.714728, -27.554208)
  # O segundo gsub retorna -52.726602 -27.567020 -52.714728 -27.554208
  call({}, layer_name)
    .match(/Extent: (.+)/)[1]
    .gsub(/\s-\s/, ' ')
    .gsub(/[^0-9\.\s-]/, '')
end