Module: OGR::FFIOGR

Extended by:
FFI::Library
Included in:
DataSource, Reader, Writer
Defined in:
lib/ffi-ogr.rb

Constant Summary collapse

OGR_FUNCTIONS =
{
  GDALVersionInfo: [[:string], :string],
  CPLSetConfigOption: [[:string, :string], :void],
  CPLSetThreadLocalConfigOption: [[:string, :string], :void],

  OGRRegisterAll: [[], :void],
  OGR_Dr_GetName: [[:pointer], :string],
  OGR_Dr_Open: [[:pointer, :string, :int], :pointer],
  OGR_Dr_TestCapability: [[:pointer, :string], :int],
  OGR_Dr_CreateDataSource: [[:pointer, :string, :pointer], :pointer],
  OGR_Dr_CopyDataSource: [[:pointer, :pointer, :string, :pointer], :pointer],
  OGR_Dr_DeleteDataSource: [[:pointer, :string], :pointer],
  OGRGetDriverCount: [[], :int],
  OGRGetDriver: [[:int], :pointer],
  OGRGetDriverByName: [[:string], :pointer],
  OGROpen: [[:string, :int, :pointer], :pointer],
  OGR_DS_Destroy: [[:pointer], :void],
  OGR_DS_GetName: [[:pointer], :string],
  OGR_DS_GetLayerCount: [[:pointer], :int],
  OGR_DS_GetLayer: [[:pointer, :int], :pointer],
  OGR_DS_GetLayerByName: [[:pointer, :string], :pointer],
  OGR_DS_DeleteLayer: [[:pointer, :int], :pointer],
  OGR_DS_GetDriver: [[:pointer], :pointer],
  OGR_DS_CreateLayer: [[:pointer, :string, :pointer, :ogr_geometry_type, :pointer], :pointer],
  OGR_DS_CopyLayer: [[:pointer, :pointer, :string, :string], :pointer],
  OGR_DS_TestCapability: [[:pointer, :string], :int],
  OGR_DS_ExecuteSQL: [[:pointer, :string, :pointer, :string], :pointer],
  OGR_DS_ReleaseResultSet: [[:pointer, :pointer], :void],
  OGR_DS_SyncToDisk: [[:pointer], :pointer],
  OGR_L_GetGeomType: [[:pointer], :ogr_geometry_type],
  OGR_L_GetName: [[:pointer], :string],
  OGR_L_GetSpatialFilter: [[:pointer], :pointer],
  OGR_L_SetSpatialFilter: [[:pointer, :pointer], :void],
  OGR_L_SetSpatialFilterRect: [[:pointer, :double, :double, :double, :double], :void],
  OGR_L_SetAttributeFilter: [[:pointer, :string], :pointer],
  OGR_L_ResetReading: [[:pointer], :void],
  OGR_L_GetNextFeature: [[:pointer], :pointer],
  OGR_L_SetNextByIndex: [[:pointer, :long], :pointer],
  OGR_L_GetFeature: [[:pointer, :long], :pointer],
  OGR_L_SetFeature: [[:pointer, :pointer], :pointer],
  OGR_L_CreateFeature: [[:pointer, :pointer], :pointer],
  OGR_L_DeleteFeature: [[:pointer, :long], :pointer],
  OGR_L_GetLayerDefn: [[:pointer], :pointer],
  OGR_L_GetSpatialRef: [[:pointer], :pointer],
  OGR_L_GetFeatureCount: [[:pointer, :int], :int],
  OGR_L_GetExtent: [[:pointer, :pointer, :int], :pointer],
  OGR_L_CreateField: [[:pointer, :pointer, :int], :pointer],
  OGR_L_SyncToDisk: [[:pointer], :pointer],
  OGR_FD_GetFieldCount: [[:pointer], :int],
  OGR_FD_GetFieldDefn: [[:pointer, :int], :pointer],
  OGR_Fld_Create: [[:string, :ogr_field_type], :pointer],
  OGR_Fld_Destroy: [[:pointer], :void],
  OGR_Fld_SetName: [[:pointer, :string], :void],
  OGR_Fld_GetNameRef: [[:pointer], :string],
  OGR_Fld_GetType: [[:pointer], :ogr_field_type],
  OGR_Fld_SetType: [[:pointer, :ogr_field_type], :void],
  OGR_Fld_GetJustify: [[:pointer], :ogr_justification],
  OGR_Fld_SetJustify: [[:pointer, :ogr_justification], :void],
  OGR_Fld_GetWidth: [[:pointer], :int],
  OGR_Fld_SetWidth: [[:pointer, :int], :void],
  OGR_Fld_GetPrecision: [[:pointer], :int],
  OGR_Fld_SetPrecision: [[:pointer, :int], :void],
  OGR_Fld_Set: [[:pointer, :string, :ogr_field_type, :int, :int, :ogr_justification], :void],
  OGR_Fld_IsIgnored: [[:pointer], :int],
  OGR_Fld_SetIgnored: [[:pointer, :int], :void],
  OGR_F_Create: [[:pointer], :pointer],
  OGR_F_GetFieldAsInteger: [[:pointer, :int], :int],
  OGR_F_GetFieldAsDouble: [[:pointer, :int], :double],
  OGR_F_GetFieldAsString: [[:pointer, :int], :string],
  OGR_F_GetFieldAsIntegerList: [[:pointer, :int, :pointer], :pointer],
  OGR_F_GetFieldAsDoubleList: [[:pointer, :int, :pointer], :pointer],
  OGR_F_GetFieldAsStringList: [[:pointer, :int], :pointer],
  OGR_F_GetFieldAsBinary: [[:pointer, :int, :pointer], :pointer],
  OGR_F_GetFieldAsDateTime: [[:pointer, :int, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :pointer],
  OGR_F_SetFieldInteger: [[:pointer, :int, :int], :void],
  OGR_F_SetFieldDouble: [[:pointer, :int, :double], :void],
  OGR_F_SetFieldString: [[:pointer, :int, :string], :void],
  OGR_F_SetFieldIntegerList: [[:pointer, :int, :int, :pointer], :void],
  OGR_F_SetFieldDoubleList: [[:pointer, :int, :int, :pointer], :void],
  OGR_F_SetFieldStringList: [[:pointer, :int, :int, :pointer], :void],
  OGR_F_SetFieldRaw: [[:pointer, :int, :pointer], :void],
  OGR_F_SetFieldBinary: [[:pointer, :int, :int, :pointer], :void],
  OGR_F_SetFieldDateTime: [[:pointer, :int, :int, :int, :int, :int, :int, :int, :int], :void],
  OGR_F_GetDefnRef: [[:pointer], :pointer],
  OGR_F_GetFieldCount: [[:pointer], :int],
  OGR_F_GetFieldDefnRef: [[:pointer, :int], :pointer],
  OGR_F_GetFieldIndex: [[:pointer, :string], :int],
  OGR_F_IsFieldSet: [[:pointer, :int], :int],
  OGR_F_GetGeometryRef: [[:pointer], :pointer],
  OGR_F_GetFID: [[:pointer], :long],
  OGR_F_SetFID: [[:pointer, :long], :pointer],
  OGR_F_StealGeometry: [[:pointer], :pointer],
  OGR_F_SetGeometry: [[:pointer, :pointer], :pointer],
  OGR_F_SetGeometryDirectly: [[:pointer, :pointer], :pointer],
  OGR_G_CreateFromWkb: [[:pointer, :pointer, :pointer, :int], :pointer],
  OGR_G_CreateFromWkt: [[:pointer, :pointer, :pointer], :pointer],
  OGR_G_DestroyGeometry: [[:pointer], :void],
  OGR_G_CreateGeometry: [[:ogr_geometry_type], :pointer],
  OGR_G_ApproximateArcAngles: [[:double, :double, :double, :double, :double, :double, :double, :double, :double], :pointer],
  OGR_G_ForceToPolygon: [[:pointer], :pointer],
  #OGR_G_ForceToLineString: [[:pointer], :pointer],
  OGR_G_ForceToMultiPolygon: [[:pointer], :pointer],
  OGR_G_ForceToMultiPoint: [[:pointer], :pointer],
  OGR_G_ForceToMultiLineString: [[:pointer], :pointer],
  OGR_G_GetDimension: [[:pointer], :int],
  OGR_G_GetCoordinateDimension: [[:pointer], :int],
  OGR_G_SetCoordinateDimension: [[:pointer, :int], :void],
  OGR_G_Clone: [[:pointer], :pointer],
  OGR_G_GetEnvelope: [[:pointer, :pointer], :void],
  OGR_G_GetEnvelope3D: [[:pointer, :pointer], :void],
  OGR_G_ImportFromWkb: [[:pointer, :pointer, :int], :pointer],
  OGR_G_ExportToWkb: [[:pointer, :pointer, :pointer], :pointer],
  OGR_G_WkbSize: [[:pointer], :int],
  OGR_G_ImportFromWkt: [[:pointer, :string], :pointer],
  OGR_G_ExportToWkt: [[:pointer, :pointer], :pointer],
  OGR_G_GetGeometryType: [[:pointer], :ogr_geometry_type],
  OGR_G_GetGeometryName: [[:pointer], :string],
  OGR_G_DumpReadable: [[:pointer, :pointer, :string], :void],
  OGR_G_FlattenTo2D: [[:pointer], :void],
  OGR_G_CloseRings: [[:pointer], :void],
  OGR_G_CreateFromGML: [[:string], :pointer],
  OGR_G_ExportToGML: [[:pointer], :string],
  #OGR_G_ExportToGMLEx: [[:pointer, :pointer], :string],
  OGR_G_ExportToKML: [[:pointer, :string], :string],
  OGR_G_ExportToJson: [[:pointer], :string],
  OGR_G_ExportToJsonEx: [[:pointer, :string], :string],
  OGR_G_AssignSpatialReference: [[:pointer, :pointer], :void],
  OGR_G_GetSpatialReference: [[:pointer], :pointer],
  OGR_G_Transform: [[:pointer, :pointer], :pointer],
  OGR_G_TransformTo: [[:pointer, :pointer], :pointer],
  OGR_G_Simplify: [[:pointer, :double], :pointer],
  OGR_G_SimplifyPreserveTopology: [[:pointer, :double], :pointer],
  OGR_G_Segmentize: [[:pointer, :double], :pointer],
  OGR_G_Intersects: [[:pointer, :pointer], :int],
  OGR_G_Equals: [[:pointer, :pointer], :int],
  OGR_G_Disjoint: [[:pointer, :pointer], :int],
  OGR_G_Touches: [[:pointer, :pointer], :int],
  OGR_G_Crosses: [[:pointer, :pointer], :int],
  OGR_G_Within: [[:pointer, :pointer], :int],
  OGR_G_Contains: [[:pointer, :pointer], :int],
  OGR_G_Overlaps: [[:pointer, :pointer], :int],
  OGR_G_Boundary: [[:pointer], :pointer],
  OGR_G_ConvexHull: [[:pointer], :pointer],
  OGR_G_Buffer: [[:pointer, :double, :int], :pointer],
  OGR_G_Intersection: [[:pointer, :pointer], :pointer],
  OGR_G_Union: [[:pointer, :pointer], :pointer],
  OGR_G_UnionCascaded: [[:pointer], :pointer],
  #OGR_G_PointOnSurface: [[:pointer], :pointer],
  OGR_G_Difference: [[:pointer, :pointer], :pointer],
  OGR_G_SymDifference: [[:pointer, :pointer], :pointer],
  OGR_G_Distance: [[:pointer, :pointer], :double],
  OGR_G_Length: [[:pointer], :double],
  OGR_G_Area: [[:pointer], :double],
  OGR_G_Centroid: [[:pointer, :pointer], :int],
  OGR_G_Empty: [[:pointer], :void],
  OGR_G_IsEmpty: [[:pointer], :int],
  OGR_G_IsValid: [[:pointer], :int],
  OGR_G_IsSimple: [[:pointer], :int],
  OGR_G_IsRing: [[:pointer], :int],
  OGR_G_Polygonize: [[:pointer], :pointer],
  OGR_G_GetPointCount: [[:pointer], :int],
  OGR_G_GetPoints: [[:pointer, :pointer, :int, :pointer, :int, :pointer, :int], :int],
  OGR_G_GetX: [[:pointer, :int], :double],
  OGR_G_GetY: [[:pointer, :int], :double],
  OGR_G_GetZ: [[:pointer, :int], :double],
  OGR_G_GetPoint: [[:pointer, :int, :pointer, :pointer, :pointer], :void],
  OGR_G_SetPoint: [[:pointer, :int, :double, :double, :double], :void],
  OGR_G_SetPoint_2D: [[:pointer, :int, :double, :double], :void],
  OGR_G_AddPoint: [[:pointer, :double, :double, :double], :void],
  OGR_G_AddPoint_2D: [[:pointer, :double, :double], :void],
  OGR_G_GetGeometryCount: [[:pointer], :int],
  OGR_G_GetGeometryRef: [[:pointer, :int], :pointer],
  OGR_G_AddGeometry: [[:pointer, :pointer], :pointer],
  OGR_G_AddGeometryDirectly: [[:pointer, :pointer], :pointer],
  OGR_G_RemoveGeometry: [[:pointer, :int, :int], :pointer],
  OGR_F_Destroy: [[:pointer], :void],

  #SRS Functions

  OSRNewSpatialReference: [[:pointer], :pointer],
  OSRImportFromWkt: [[:pointer, :pointer], :pointer],
  OSRImportFromProj4: [[:pointer, :string], :pointer],
  OSRImportFromEPSG: [[:pointer, :int], :pointer],
  OSRImportFromESRI: [[:pointer, :pointer], :pointer],
  OSRExportToWkt: [[:pointer, :pointer], :pointer],
  OSRExportToPrettyWkt: [[:pointer, :pointer, :int], :pointer],
  OSRExportToProj4: [[:pointer, :pointer], :pointer],
  OSRDestroySpatialReference: [[:pointer], :void],
  OCTNewCoordinateTransformation: [[:pointer, :pointer], :pointer],
  OCTDestroyCoordinateTransformation: [[:pointer], :void]
}

Class Method Summary collapse

Class Method Details

.find_lib(lib) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/ffi-ogr.rb', line 62

def self.find_lib(lib)
  if ENV['GDAL_LIBRARY_PATH'] && File.file?(ENV['GDAL_LIBRARY_PATH'])
    ENV['GDAL_LIBRARY_PATH']
  else
    Dir.glob(search_paths.map {|path|
      File.expand_path(File.join(path, "#{lib}.#{FFI::Platform::LIBSUFFIX}"))
    }).first
  end
end

.gdal_library_pathObject



72
73
74
75
76
# File 'lib/ffi-ogr.rb', line 72

def self.gdal_library_path
  @gdal_library_path ||= begin
    find_lib('{lib,}gdal{,-?}')
  end
end

.search_pathsObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ffi-ogr.rb', line 50

def self.search_paths
  @search_paths ||= begin
    if ENV['GDAL_LIBRARY_PATH']
    elsif FFI::Platform.windows?
      ENV['PATH'].split(File::PATH_SEPARATOR)
    else
      ['/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}']
      ['/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu']
    end
  end
end