Sha256: 0908a332cede4a9f1d83cfabc84f3b513332cecae339e90cdf4c7882a3290faa

Contents?: true

Size: 696 Bytes

Versions: 8

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

class Map::Gdal::TranslateService
  include Map::Gdal::Base

  def initialize(file)
    @file = file
  end

  def to_png(options = {})
    self.call(options.merge({
      of: 'PNG',
      co: 'worldfile=yes',
      scale: '',
      ot: 'Byte'
    }))
  end

  def to_jpeg(options = {})
    self.call(options.merge({
      of: 'JPEG',
      co: 'worldfile=yes'
    }))
  end

  def call(options = {})
    out = get_path_to_temp_file(:translate, options[:of])

    run_command("gdal_translate #{options_to_command_line(options)} #{@file} #{out}")

    add_to_clean(out)
    add_to_clean("#{out}.aux.xml")
    add_to_clean(out.gsub('.jpg', '.wld'))

    out
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
aqila-mapas-0.4.12 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.11 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.9 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.8 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.7 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.6 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.5 lib/map/gdal/translate_service.rb
aqila-mapas-0.4.4 lib/map/gdal/translate_service.rb