Module: Proj4::FFIProj4

Extended by:
FFI::Library
Defined in:
lib/ffi-proj4.rb

Constant Summary collapse

FFI_LAYOUT =
{
  :pj_get_release => [
    :string
  ],

  :pj_transform => [
    :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
  ],

  :pj_init_plus => [
    :pointer, :string
  ],

  :pj_free => [
    :void, :pointer
  ],

  :pj_is_latlong => [
    :int, :pointer
  ],

  :pj_is_geocent => [
    :int, :pointer
  ],

  :pj_get_def => [
    :string, :pointer, :int
  ],

  :pj_latlong_from_proj => [
    :pointer, :pointer
  ],

  :pj_set_finder => [
    :void, callback([ :string ], :string)
  ],

  :pj_set_searchpath => [
    :void, :int, :pointer
  ],

  :pj_deallocate_grids => [
    :void
  ],

  :pj_strerrno => [
    :string, :int
  ],

  :pj_get_errno_ref => [
    :pointer
  ],

  :pj_fwd => [
    Proj4::ProjXY.by_value, Proj4::ProjXY.by_value, :pointer
  ],

  :pj_inv => [
    Proj4::ProjXY.by_value, Proj4::ProjXY.by_value, :pointer
  ],

  :pj_transform => [
    :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
  ],

  :pj_datum_transform => [
    :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
  ],

  :setenv => [
    :int, :string, :string, :int
  ]
}

Class Method Summary collapse

Class Method Details

.proj4_library_pathObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ffi-proj4.rb', line 23

def self.proj4_library_path
  return @proj4_library_path if defined?(@proj4_library_path)

  paths = if ENV['PROJ4_LIBRARY_PATH']
    [ ENV['PROJ4_LIBRARY_PATH'] ]
  else
    [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
  end

  lib = if FFI::Platform::IS_MAC
    'libproj.dylib'
  elsif FFI::Platform::IS_WINDOWS
    # For MinGW and the official binaries
    '{libproj-?,proj}.dll'
  else
    'libproj.so'
  end

  paths = if ENV['PROJ4_LIBRARY_PATH']
    [ ENV['PROJ4_LIBRARY_PATH'] ]
  elsif FFI::Platform::IS_WINDOWS
    ENV['PATH'].split(File::PATH_SEPARATOR)
  else
    [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
  end

  @proj4_library_path = Dir.glob(paths.collect { |path|
    File.expand_path(File.join(path, lib))
  }).first
end