Class: OGR::Reader

Inherits:
Object
  • Object
show all
Includes:
FFIOGR
Defined in:
lib/ffi-ogr/reader.rb

Constant Summary collapse

TF_MAP =
{
  true => 1,
  false => 0,
  1 => true,
  0 => false
}

Constants included from FFIOGR

FFIOGR::OGR_FUNCTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FFIOGR

find_lib, gdal_library_path, search_paths

Constructor Details

#initialize(driver_name) ⇒ Reader

Returns a new instance of Reader.


14
15
16
17
18
19
# File 'lib/ffi-ogr/reader.rb', line 14

def initialize(driver_name)
  OGRRegisterAll()
  @driver = OGRGetDriverByName(driver_name)
  raise RuntimeError.new "Invalid driver name" if @driver.null?
  @type = driver_name
end

Instance Attribute Details

#typeObject

Returns the value of attribute type


5
6
7
# File 'lib/ffi-ogr/reader.rb', line 5

def type
  @type
end

Instance Method Details

#read(file_path, writeable = false) ⇒ Object


21
22
23
24
# File 'lib/ffi-ogr/reader.rb', line 21

def read(file_path, writeable=false)
  ds = OGR_Dr_Open(@driver, File.expand_path(file_path), TF_MAP[writeable])
  OGR::Tools.cast_data_source(ds)
end