module OGR
Constants
- DRIVER_TYPES
- OGR_BASE
- VERSION
Public Class Methods
create_writer(path)
click to toggle source
# File lib/ffi-ogr.rb, line 358 def create_writer(path) raise RuntimeError.new "Path already exists: #{path}" if File.exists?(path) writer = get_writer path writer.set_output path writer end
gdal_version()
click to toggle source
# File lib/ffi-ogr.rb, line 329 def gdal_version FFIOGR.GDALVersionInfo('RELEASE_NAME') end
get_available_drivers()
click to toggle source
# File lib/ffi-ogr.rb, line 333 def get_available_drivers [].tap do |drivers| for i in 0...FFIOGR.OGRGetDriverCount drivers << FFIOGR.OGR_Dr_GetName(FFIOGR.OGRGetDriver(i)) end end end
Also aliased as: drivers
get_driver_by_extension(extension)
click to toggle source
# File lib/ffi-ogr.rb, line 366 def get_driver_by_extension(extension) driver = unless extension == 'kml' DRIVER_TYPES[extension] else drivers.include?('LIBKML') ? 'LIBKML' : 'KML' end raise RuntimeError.new "Could not find appropriate driver" if driver.nil? driver end
get_writer(source)
click to toggle source
# File lib/ffi-ogr.rb, line 352 def get_writer(source) extension = source.split('.').last driver = get_driver_by_extension extension Writer.new(driver) end
import_spatial_ref(sr_import, format = 'epsg')
click to toggle source
# File lib/ffi-ogr.rb, line 389 def import_spatial_ref(sr_import, format = 'epsg') OGR::SpatialReference.import(sr_import, format) end
Also aliased as: import_sr
read(source)
click to toggle source
# File lib/ffi-ogr.rb, line 378 def read(source) case source when /http:|https:/ HttpReader.new.read source else driver = get_driver_by_extension source.split('.').last raise RuntimeError.new "Could not determine file type" if driver.nil? Reader.new(driver).read source end end
string_to_pointer(str)
click to toggle source
# File lib/ffi-ogr.rb, line 348 def string_to_pointer(str) FFI::MemoryPointer.from_string(str) end
to_binary(data)
click to toggle source
# File lib/ffi-ogr.rb, line 342 def to_binary(data) buf = FFI::MemoryPointer.new(:char, value.size) buf.put_bytes(0, data) buf end