Class: Proj::Config
Instance Method Summary collapse
- #data_path ⇒ Object
- #db_path ⇒ Object
- #search_paths ⇒ Object
- #search_paths_pointer ⇒ Object
- #set_search_paths ⇒ Object
Instance Method Details
#data_path ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/config.rb', line 33 def data_path if ENV['PROJ_LIB'] && File.directory?(ENV['PROJ_LIB']) ENV['PROJ_LIB'] else result = self.search_paths.detect do |path| File.directory?(path) end unless result raise(Error, "Could not find Proj data directory. Please set the PROJ_LIB environmental variable to correct directory") end result end end |
#db_path ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/config.rb', line 56 def db_path result = self.search_paths.map do |path| File.join(path, 'proj.db') end.detect do |path| File.exists?(path) end unless result raise(Error, "Could not find Proj database (proj.db). Please set the PROJ_LIB environmental variable to directory that contains it") end result end |
#search_paths ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/config.rb', line 21 def search_paths ['/usr/share/proj', '/usr/local/share/proj', '/opt/share/proj', '/opt/local/share/proj', 'c:/msys64/mingw64/share/proj', 'c:/mingw64/share/proj', '/opt/local/lib/proj6/share/proj', '/opt/local/lib/proj5/share/proj', '/opt/local/lib/proj49/share/proj'] end |
#search_paths_pointer ⇒ Object
49 50 51 52 53 54 |
# File 'lib/config.rb', line 49 def search_paths_pointer p_path = FFI::MemoryPointer.from_string(self.data_path) p_paths = FFI::MemoryPointer.new(:pointer, 1) p_paths[0].write_pointer(p_path) p_paths end |
#set_search_paths ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/config.rb', line 7 def set_search_paths p_paths = self.search_paths_pointer items = p_paths.type_size/p_paths.size # Set search paths on default context - any new contexts will inherit from this if Api.method_defined?(:proj_context_set_search_paths) Api.proj_context_set_search_paths(nil, items, p_paths) end if Api.method_defined?(:pj_set_searchpath) Api.pj_set_searchpath(items, p_paths) end end |