Sha256: 5960f5b1c03806bb0e2aede1600e7f66123595b7c63892b7a5dd3c9e1d07e80a

Contents?: true

Size: 1.91 KB

Versions: 8

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

require_relative 'ffi-gdal'
require_relative 'ffi/gdal'

module GDAL
  class << self
    # Use when you want something quick and easy for when you need something
    # quick for a +FFI::GDAL::GDALProgressFunc+. Outputs the duration and
    # percentage completed.
    #
    # @return [Proc] A Proc that works for a +GDALProgressFunc+ callback.
    def simple_progress_formatter
      start = Time.now

      lambda do |d, _, _|
        print "Duration: #{(Time.now - start).to_f.round(2)}s\t| #{(d * 100).round(2)}%\r"
        true
      end
    end

    private

    def gdal_require(path)
      File.expand_path(path, __dir__)
    end
  end

  # Autoload just the core GDAL object types.
  autoload :ColorTable,           gdal_require('gdal/color_table')
  autoload :Dataset,              gdal_require('gdal/dataset')
  autoload :DataType,             gdal_require('gdal/data_type')
  autoload :Driver,               gdal_require('gdal/driver')
  autoload :GeoTransform,         gdal_require('gdal/geo_transform')
  autoload :Logger,               gdal_require('gdal/logger')
  autoload :MajorObject,          gdal_require('gdal/major_object')
  autoload :Options,              gdal_require('gdal/options')
  autoload :RasterAttributeTable, gdal_require('gdal/raster_attribute_table')
  autoload :RasterBand,           gdal_require('gdal/raster_band')
end

require_relative 'gdal/exceptions'
require_relative 'gdal/version_info'
require_relative 'gdal/environment_methods'
require_relative 'gdal/internal_helpers'
require_relative 'gdal/cpl_error_handler'

module GDAL
  extend VersionInfo
  extend EnvironmentMethods
  include InternalHelpers

  # Register all drivers!
  ::FFI::GDAL::GDAL.GDALAllRegister

  # We define our own error handler so we can turn GDAL errors into Ruby
  # exceptions.
  FFI_GDAL_ERROR_HANDLER = GDAL::CPLErrorHandler.handle_error
  ::FFI::CPL::Error.CPLSetErrorHandler(FFI_GDAL_ERROR_HANDLER)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ffi-gdal-1.0.2 lib/gdal.rb
ffi-gdal-1.0.1 lib/gdal.rb
ffi-gdal-1.0.0 lib/gdal.rb
ffi-gdal-1.0.0.beta16 lib/gdal.rb
ffi-gdal-1.0.0.beta15 lib/gdal.rb
ffi-gdal-1.0.0.beta14 lib/gdal.rb
ffi-gdal-1.0.0.beta13 lib/gdal.rb
ffi-gdal-1.0.0.beta12 lib/gdal.rb