ffi-gdal 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +57 -0
- data/ffi-gdal.gemspec +28 -0
- data/lib/ext/cpl_error_symbols.rb +37 -0
- data/lib/ext/to_bool.rb +13 -0
- data/lib/ffi/gdal/cpl_conv.rb +151 -0
- data/lib/ffi/gdal/cpl_error.rb +91 -0
- data/lib/ffi/gdal/cpl_string.rb +113 -0
- data/lib/ffi/gdal/cpl_vsi.rb +119 -0
- data/lib/ffi/gdal/gdal_color_entry.rb +13 -0
- data/lib/ffi/gdal/gdal_gcp.rb +18 -0
- data/lib/ffi/gdal/ogr_api.rb +28 -0
- data/lib/ffi/gdal/ogr_core.rb +199 -0
- data/lib/ffi/gdal/ogr_srs_api.rb +48 -0
- data/lib/ffi/gdal/version.rb +5 -0
- data/lib/ffi/gdal.rb +607 -0
- data/lib/ffi-gdal/color_table.rb +59 -0
- data/lib/ffi-gdal/dataset.rb +347 -0
- data/lib/ffi-gdal/driver.rb +151 -0
- data/lib/ffi-gdal/exceptions.rb +17 -0
- data/lib/ffi-gdal/geo_transform.rb +137 -0
- data/lib/ffi-gdal/major_object.rb +71 -0
- data/lib/ffi-gdal/raster_attribute_table.rb +78 -0
- data/lib/ffi-gdal/raster_band.rb +571 -0
- data/lib/ffi-gdal/version_info.rb +48 -0
- data/lib/ffi-gdal.rb +12 -0
- data/linkies.rb +35 -0
- data/meow.rb +144 -0
- data/readie.rb +90 -0
- data/rubby.rb +224 -0
- data/spec/ext/cpl_error_symbols_spec.rb +79 -0
- data/spec/ffi-gdal/integration/color_table_info_spec.rb +60 -0
- data/spec/ffi-gdal/integration/dataset_info_spec.rb +95 -0
- data/spec/ffi-gdal/integration/driver_info_spec.rb +60 -0
- data/spec/ffi-gdal/integration/geo_transform_info_spec.rb +66 -0
- data/spec/ffi-gdal/integration/raster_attribute_table_info_spec.rb +23 -0
- data/spec/ffi-gdal/integration/raster_band_info_spec.rb +333 -0
- data/spec/ffi-gdal/unit/version_info_spec.rb +48 -0
- data/spec/ffi-gdal_spec.rb +6 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/integration_help.rb +1 -0
- data/spec/support/shared_examples/major_object_examples.rb +68 -0
- data/things.rb +84 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f3fc9ffcfff9c381ae50a8db5dd1e478ab46500
|
4
|
+
data.tar.gz: 8ec7abeee47f6f1078e3c5e28c3082655908c129
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9298a86799585825fcf49845e2fc785ce7446f11a7c76b3bc43b151d909b12534f10fd3ae1272d7fea3e22f5416296e7f00f689bd1e6175908cd4b343e4e1ee
|
7
|
+
data.tar.gz: 105d5bfd2ff92ca1a9e18eab465e9f2bd738904edfd0ec0ac7be6a0f4cd1efa24051fe35c50deba214c81295f4f9cea7013b369e6a9354a334b11bf753d93b55
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/
|
24
|
+
spec/support/images
|
25
|
+
tags
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Steve Loveless
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
ffi-gdal
|
2
|
+
========
|
3
|
+
|
4
|
+
Ruby wrapper around GDAL, using FFI, along with some helper methods.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'ffi-gdal'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ffi-gdal
|
20
|
+
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
|
24
|
+
ffi-gdal provides two interfaces, really: the direct FFI wrapper around GDAL's
|
25
|
+
C API, and a Ruby-fied interface that uses the FFI wrapper to make use more
|
26
|
+
like using an object-oriented library instead of a functional one. Most likely
|
27
|
+
you'll just want to use the Ruby-fied library, but if for some reason that
|
28
|
+
doesn't get you what you want, direct access to the FFI wrapper (which is
|
29
|
+
really just direct access to the C API) is available.
|
30
|
+
|
31
|
+
|
32
|
+
### The Ruby-fied Library
|
33
|
+
|
34
|
+
To distinguish this gem from the already-existing gdal gem, you
|
35
|
+
`require ffi-gdal` to get access to the `GDAL` module and its children.
|
36
|
+
|
37
|
+
|
38
|
+
### The direct FFI wrapper
|
39
|
+
|
40
|
+
Following RubyGem conventions, to get access to the FFI wrapper, you
|
41
|
+
`require ffi/gdal`.
|
42
|
+
|
43
|
+
|
44
|
+
Testing
|
45
|
+
-------
|
46
|
+
|
47
|
+
You'll need some images to run the integration specs against, and instead of
|
48
|
+
keeping those as part of this repo, there's a Rake task that will pull OSGeo's
|
49
|
+
set of sample geotiffs down via FTP. Running `rake get_tifs` will pull
|
50
|
+
everything down from ftp://downloads.osgeo.org/geotiff/samples and put the
|
51
|
+
files under spec/support/images/osgeo/geotiff.
|
52
|
+
|
53
|
+
Contributing
|
54
|
+
------------
|
55
|
+
|
56
|
+
1. Fork it ( https://github.com/turboladen/ffi-gdal/fork )
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc 'Download files for running integration tests against'
|
5
|
+
task :get_tifs do
|
6
|
+
require 'net/ftp'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
base_dest_dir = 'spec/support/images/osgeo/geotiff'
|
10
|
+
|
11
|
+
Net::FTP.open('downloads.osgeo.org') do |ftp|
|
12
|
+
ftp.login
|
13
|
+
ftp.binary = true
|
14
|
+
|
15
|
+
base_dir = 'geotiff/samples'
|
16
|
+
_, dirs = files_and_dirs(base_dir, ftp)
|
17
|
+
|
18
|
+
dirs.each do |dir_name|
|
19
|
+
path = "#{base_dir}/#{dir_name}"
|
20
|
+
files, dirs = files_and_dirs(path, ftp)
|
21
|
+
dest_dir = "#{base_dest_dir}/#{dir_name}"
|
22
|
+
|
23
|
+
FileUtils.mkdir_p(dest_dir) unless Dir.exist?(dest_dir)
|
24
|
+
|
25
|
+
files.each do |file|
|
26
|
+
src_file = "#{path}/#{file}"
|
27
|
+
dest_file = "#{dest_dir}/#{file}"
|
28
|
+
|
29
|
+
puts "Getting file '#{src_file}' to '#{dest_file}'..."
|
30
|
+
ftp.get("#{src_file}", "#{dest_file}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Array{files => Array, dirs => Array}]
|
37
|
+
def files_and_dirs(in_dir, ftp)
|
38
|
+
dirs = []
|
39
|
+
files = []
|
40
|
+
|
41
|
+
puts "Getting stuff from #{in_dir}..."
|
42
|
+
|
43
|
+
ftp.list("#{in_dir}/*") do |item|
|
44
|
+
item_name = item.split(' ').last
|
45
|
+
|
46
|
+
if item.start_with? 'd'
|
47
|
+
dirs << item_name
|
48
|
+
else
|
49
|
+
files << item_name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
[files, dirs]
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
RSpec::Core::RakeTask.new
|
data/ffi-gdal.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ffi/gdal/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ffi-gdal'
|
8
|
+
spec.version = FFI::GDAL::VERSION
|
9
|
+
spec.authors = ['Steve Loveless']
|
10
|
+
spec.email = %w[steve.loveless@gmail.com]
|
11
|
+
spec.summary = %q{FFI wrapper for GDAL/OGR.}
|
12
|
+
spec.homepage = 'https://github.com/turboladen/ffi-gdal'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = %w[lib]
|
19
|
+
|
20
|
+
spec.add_dependency 'ffi'
|
21
|
+
spec.add_dependency 'log_switch'
|
22
|
+
spec.add_dependency 'multi_xml'
|
23
|
+
spec.add_dependency 'narray', '~> 0.6.0'
|
24
|
+
spec.add_dependency 'ruby-progressbar'
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../ffi-gdal/exceptions'
|
2
|
+
|
3
|
+
|
4
|
+
class ::Symbol
|
5
|
+
|
6
|
+
# When FFI interfaces with a GDAL CPLError, it returns a Symbol that
|
7
|
+
# maps to the CPLErr enum (see GDAL's cpl_error.h or cpl_error.rb docs). Since
|
8
|
+
# many of the GDAL C API's functions return these symbols _and_ because the
|
9
|
+
# symbols have some functional implications, this wrapping here is simply for
|
10
|
+
# returning Ruby-esque values when the GDAL API returns one of these symbols.
|
11
|
+
#
|
12
|
+
# The optional params let you override behavior. Passing in a block instead
|
13
|
+
# will call the block. Ex.
|
14
|
+
#
|
15
|
+
# cpl_err = GDALCopyDatasetFiles(@gdal_driver_handle, new_name, old_name)
|
16
|
+
# cpl_err.to_ruby # returns the default value
|
17
|
+
# cpl_err.to_ruby { raise 'Crap!' }
|
18
|
+
def to_ruby(none: :none, debug: :debug, warning: :warning, failure: :failure, fatal: :fatal)
|
19
|
+
case self
|
20
|
+
when :CE_None then none
|
21
|
+
when :CE_Debug then debug
|
22
|
+
when :CE_Warning then warning
|
23
|
+
when :CE_Failure then failure
|
24
|
+
when :CE_Fatal then fatal
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_bool
|
29
|
+
case self
|
30
|
+
when :CE_None then true
|
31
|
+
when :CE_Debug then true
|
32
|
+
when :CE_Warning then false
|
33
|
+
when :CE_Failure then raise GDAL::CPLErrFailure
|
34
|
+
when :CE_Fatal then raise GDAL::CPLErrFailure
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ext/to_bool.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require_relative 'cpl_error'
|
3
|
+
require_relative 'cpl_vsi'
|
4
|
+
|
5
|
+
|
6
|
+
module FFI
|
7
|
+
module GDAL
|
8
|
+
module CPLConv
|
9
|
+
extend ::FFI::Library
|
10
|
+
ffi_lib 'gdal'
|
11
|
+
|
12
|
+
include CPLError
|
13
|
+
|
14
|
+
def CPLFree(pointer)
|
15
|
+
extend CPLVSI
|
16
|
+
VSIFree(pointer)
|
17
|
+
end
|
18
|
+
|
19
|
+
#------------------------------------------------------------------------
|
20
|
+
# cpl_port Typedefs
|
21
|
+
#------------------------------------------------------------------------
|
22
|
+
typedef :int, :GInt32
|
23
|
+
typedef :uint, :GUInt32
|
24
|
+
typedef :short, :GInt16
|
25
|
+
typedef :ushort, :GUInt16
|
26
|
+
typedef :uchar, :GByte
|
27
|
+
typedef :int, :GBool
|
28
|
+
typedef :long_long, :GIntBig
|
29
|
+
typedef :ulong_long, :GUIntBig
|
30
|
+
|
31
|
+
#--------------------------------------------------------------------------
|
32
|
+
# Functions
|
33
|
+
#--------------------------------------------------------------------------
|
34
|
+
callback :CPLFileFinder, %i[string string], :string
|
35
|
+
|
36
|
+
#---------
|
37
|
+
# Config
|
38
|
+
#---------
|
39
|
+
attach_function :CPLVerifyConfiguration, %i[], :void
|
40
|
+
attach_function :CPLGetConfigOption, %i[string string], :string
|
41
|
+
attach_function :CPLSetConfigOption, %i[string string], :void
|
42
|
+
attach_function :CPLSetThreadLocalConfigOption, %i[string string], :void
|
43
|
+
attach_function :CPLFreeConfig, %i[], :void
|
44
|
+
|
45
|
+
#---------
|
46
|
+
# Memory
|
47
|
+
#---------
|
48
|
+
attach_function :CPLMalloc, %i[size_t], :pointer
|
49
|
+
attach_function :CPLCalloc, %i[size_t size_t], :pointer
|
50
|
+
attach_function :CPLRealloc, %i[pointer size_t], :pointer
|
51
|
+
|
52
|
+
#---------
|
53
|
+
# Strings
|
54
|
+
#---------
|
55
|
+
attach_function :CPLStrdup, %i[string], :string
|
56
|
+
attach_function :CPLStrlwr, %i[string], :string
|
57
|
+
attach_function :CPLFGets, %i[string int pointer], :string
|
58
|
+
attach_function :CPLReadLine, %i[pointer], :string
|
59
|
+
attach_function :CPLReadLineL, %i[pointer], :string
|
60
|
+
attach_function :CPLReadLine2L, %i[pointer int pointer], :string
|
61
|
+
attach_function :CPLAtof, %i[string], :double
|
62
|
+
attach_function :CPLAtofDelim, %i[string char], :double
|
63
|
+
attach_function :CPLStrtod, %i[string pointer], :double
|
64
|
+
attach_function :CPLStrtodDelim, %i[string pointer char], :double
|
65
|
+
attach_function :CPLStrtof, %i[string pointer], :float
|
66
|
+
attach_function :CPLStrtofDelim, %i[string pointer char], :float
|
67
|
+
attach_function :CPLAtofM, %i[string], :double
|
68
|
+
attach_function :CPLScanString, %i[string int int int], :string
|
69
|
+
attach_function :CPLScanDouble, %i[string int], :double
|
70
|
+
attach_function :CPLScanLong, %i[string int], :long
|
71
|
+
attach_function :CPLScanLong, %i[string int], :ulong
|
72
|
+
attach_function :CPLScanUIntBig, %i[string int], :GUIntBig
|
73
|
+
attach_function :CPLScanPointer, %i[string int], :pointer
|
74
|
+
attach_function :CPLPrintString, %i[string string int], :int
|
75
|
+
attach_function :CPLPrintStringFill, %i[string string int], :int
|
76
|
+
|
77
|
+
#---------
|
78
|
+
# Numbers to strings
|
79
|
+
#---------
|
80
|
+
attach_function :CPLPrintInt32, %i[string GInt32 int], :int
|
81
|
+
attach_function :CPLPrintUIntBig, %i[string GUIntBig int], :int
|
82
|
+
attach_function :CPLPrintDouble, %i[string string double string], :int
|
83
|
+
attach_function :CPLPrintTime, %i[string int string pointer string], :int
|
84
|
+
attach_function :CPLPrintPointer, %i[string pointer int], :int
|
85
|
+
attach_function :CPLGetSymbol, %i[string string], :pointer
|
86
|
+
|
87
|
+
#---------
|
88
|
+
# Files
|
89
|
+
#---------
|
90
|
+
attach_function :CPLGetExecPath, %i[string int], :int
|
91
|
+
attach_function :CPLGetPath, %i[string], :string
|
92
|
+
attach_function :CPLGetDirname, %i[string], :string
|
93
|
+
attach_function :CPLGetFilename, %i[string], :string
|
94
|
+
attach_function :CPLGetBasename, %i[string], :string
|
95
|
+
attach_function :CPLGetExtension, %i[string], :string
|
96
|
+
attach_function :CPLGetCurrentDir, [], :string
|
97
|
+
attach_function :CPLFormFilename, %i[string string string], :string
|
98
|
+
attach_function :CPLFormCIFilename, %i[string string string], :string
|
99
|
+
attach_function :CPLResetExtension, %i[string string], :string
|
100
|
+
attach_function :CPLProjectRelativeFilename, %i[string string], :string
|
101
|
+
attach_function :CPLIsFilenameRelative, %i[string], :int
|
102
|
+
attach_function :CPLExtractRelativePath, %i[string string pointer], :string
|
103
|
+
attach_function :CPLCleanTrailingSlash, %i[string], :string
|
104
|
+
attach_function :CPLCorrespondingPaths, %i[string string pointer], :pointer
|
105
|
+
attach_function :CPLCheckForFile, %i[string string], :int
|
106
|
+
attach_function :CPLGenerateTempFilename, %i[string], :string
|
107
|
+
attach_function :CPLFindFile, %i[string string], :string
|
108
|
+
attach_function :CPLDefaultFindFile, %i[string string], :string
|
109
|
+
attach_function :CPLPushFileFinder, %i[CPLFileFinder], :void
|
110
|
+
attach_function :CPLPopFileFinder, %i[], :CPLFileFinder
|
111
|
+
attach_function :CPLPushFinderLocation, %i[string], :void
|
112
|
+
attach_function :CPLPopFinderLocation, %i[], :void
|
113
|
+
attach_function :CPLFinderClean, %i[], :void
|
114
|
+
attach_function :CPLStat, %i[string pointer], :int
|
115
|
+
attach_function :CPLOpenShared, %i[string string int], :pointer
|
116
|
+
attach_function :CPLCloseShared, %i[pointer], :void
|
117
|
+
attach_function :CPLGetSharedList, %i[pointer], :pointer
|
118
|
+
attach_function :CPLDumpSharedList, %i[pointer], :void
|
119
|
+
attach_function :CPLCleanupSharedFileMutex, %i[], :void
|
120
|
+
|
121
|
+
attach_function :CPLDMSToDec, %i[string], :double
|
122
|
+
attach_function :CPLDecToDMS, %i[double string int], :string
|
123
|
+
attach_function :CPLPackedDMSToDec, %i[double], :double
|
124
|
+
attach_function :CPLDecToPackedDMS, %i[double], :string
|
125
|
+
attach_function :CPLStringToComplex, %i[string pointer pointer], :void
|
126
|
+
attach_function :CPLUnlinkTree, %i[string], :int
|
127
|
+
attach_function :CPLCopyFile, %i[string string], :int
|
128
|
+
attach_function :CPLMoveFile, %i[string string], :int
|
129
|
+
|
130
|
+
#---------
|
131
|
+
# Zip Files
|
132
|
+
#---------
|
133
|
+
attach_function :CPLCreateZip, %i[string pointer], :pointer
|
134
|
+
attach_function :CPLCreateFileInZip, %i[pointer string pointer], CPLErr
|
135
|
+
attach_function :CPLWriteFileInZip, %i[pointer pointer int], CPLErr
|
136
|
+
attach_function :CPLCloseFileInZip, %i[pointer], CPLErr
|
137
|
+
attach_function :CPLCloseZip, %i[pointer], CPLErr
|
138
|
+
attach_function :CPLZLibDeflate,
|
139
|
+
%i[pointer size_t int pointer size_t pointer],
|
140
|
+
:pointer
|
141
|
+
attach_function :CPLZLibInflate,
|
142
|
+
%i[pointer size_t pointer size_t pointer],
|
143
|
+
:pointer
|
144
|
+
|
145
|
+
attach_function :CPLValidateXML, %i[string string pointer], :int
|
146
|
+
attach_function :CPLsetlocale, %i[int string], :string
|
147
|
+
|
148
|
+
attach_function :CPLCleanupSetlocaleMutex, %i[], :void
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../../ext/cpl_error_symbols'
|
2
|
+
|
3
|
+
|
4
|
+
module FFI
|
5
|
+
module GDAL
|
6
|
+
module CPLError
|
7
|
+
extend FFI::Library
|
8
|
+
ffi_lib 'gdal'
|
9
|
+
|
10
|
+
#------------------------------------------------------------------------
|
11
|
+
# Defines
|
12
|
+
#------------------------------------------------------------------------
|
13
|
+
None = 0
|
14
|
+
AppDefined = 1
|
15
|
+
OutOfMemory = 2
|
16
|
+
FileIO = 3
|
17
|
+
OpenFailed = 4
|
18
|
+
IllegalArg = 5
|
19
|
+
NotSupported = 6
|
20
|
+
AssertionFailed = 7
|
21
|
+
NoWriteAccess = 8
|
22
|
+
UserInterrupt = 9
|
23
|
+
ObjectNull = 10
|
24
|
+
|
25
|
+
def cpla_assert(exp)
|
26
|
+
end
|
27
|
+
def validate_pointer_err(ce_failure)
|
28
|
+
end
|
29
|
+
def validate_pointer0(ptr, func)
|
30
|
+
end
|
31
|
+
def validate_pointer1(ptr, func, rc)
|
32
|
+
end
|
33
|
+
|
34
|
+
#------------------------------------------------------------------------
|
35
|
+
# Enums
|
36
|
+
#------------------------------------------------------------------------
|
37
|
+
CPLErr = enum :CE_None, 0,
|
38
|
+
:CE_Debug, 1,
|
39
|
+
:CE_Warning, 2,
|
40
|
+
:CE_Failure, 3,
|
41
|
+
:CE_Fatal, 4
|
42
|
+
|
43
|
+
callback :CPLErrorHandler, [CPLErr, :int, :string], :void
|
44
|
+
|
45
|
+
#------------------------------------------------------------------------
|
46
|
+
# Functions
|
47
|
+
#------------------------------------------------------------------------
|
48
|
+
attach_function :CPLError, [CPLErr, :int, :string], :void
|
49
|
+
attach_function :CPLErrorV, [CPLErr, :int, :string, :pointer], :void
|
50
|
+
attach_function :CPLEmergencyError, [:void], :void
|
51
|
+
attach_function :CPLErrorReset, [:void], :void
|
52
|
+
|
53
|
+
attach_function :CPLGetLastErrorNo, [:void], :int
|
54
|
+
attach_function :CPLGetLastErrorType, [:void], CPLErr
|
55
|
+
attach_function :CPLGetLastErrorMsg, [:void], :string
|
56
|
+
|
57
|
+
attach_function :CPLGetErrorHandlerUserData, [:void], :pointer
|
58
|
+
#attach_function :CPLErrorSetState,
|
59
|
+
#[CPLErr, :int, :string],
|
60
|
+
#:void
|
61
|
+
attach_function :CPLCleanupErrorMutex, [:void], :void
|
62
|
+
attach_function :CPLLoggingErrorHandler,
|
63
|
+
[CPLErr, :int, :string],
|
64
|
+
:void
|
65
|
+
attach_function :CPLDefaultErrorHandler,
|
66
|
+
[CPLErr, :int, :string],
|
67
|
+
:void
|
68
|
+
attach_function :CPLQuietErrorHandler,
|
69
|
+
[CPLErr, :int, :string],
|
70
|
+
:void
|
71
|
+
attach_function :CPLTurnFailureIntoWarning, [:int], :void
|
72
|
+
|
73
|
+
attach_function :CPLSetErrorHandler,
|
74
|
+
[:CPLErrorHandler],
|
75
|
+
:CPLErrorHandler
|
76
|
+
attach_function :CPLSetErrorHandlerEx,
|
77
|
+
[:CPLErrorHandler, :pointer],
|
78
|
+
:CPLErrorHandler
|
79
|
+
attach_function :CPLPushErrorHandler,
|
80
|
+
[:CPLErrorHandler],
|
81
|
+
:void
|
82
|
+
attach_function :CPLPushErrorHandlerEx,
|
83
|
+
[:CPLErrorHandler, :pointer],
|
84
|
+
:void
|
85
|
+
attach_function :CPLPopErrorHandler, [:void], :void
|
86
|
+
|
87
|
+
attach_function :CPLDebug, [:string, :string], :void
|
88
|
+
attach_function :_CPLAssert, [:string, :string, :int], :void
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
|
4
|
+
module FFI
|
5
|
+
module GDAL
|
6
|
+
module CPLString
|
7
|
+
extend FFI::Library
|
8
|
+
ffi_lib 'gdal'
|
9
|
+
|
10
|
+
#------------------------------------------------------------------------
|
11
|
+
# Defines
|
12
|
+
#------------------------------------------------------------------------
|
13
|
+
CSLT_HONOURSTRINGS = 0x0001
|
14
|
+
CSLT_ALLOWEMPTYTOKENS = 0x0002
|
15
|
+
CSLT_PRESERVEQUOTES = 0x0004
|
16
|
+
CSLT_PRESERVEESCAPES = 0x0008
|
17
|
+
CSLT_STRIPLEADSPACES = 0x0010
|
18
|
+
CSLT_STRIPENDSPACES = 0x0020
|
19
|
+
|
20
|
+
CPLES_BackslashQuotable = 0
|
21
|
+
CPLES_XML = 1
|
22
|
+
CPLES_URL = 2
|
23
|
+
CPLES_SQL = 3
|
24
|
+
CPLES_CSV = 4
|
25
|
+
CPLES_XML_BUT_QUOTES = 5
|
26
|
+
|
27
|
+
CPL_ENC_LOCALE = ''
|
28
|
+
CPL_ENC_UTF8 = 'UTF-8'
|
29
|
+
CPL_ENC_UTF16 = 'UTF-16'
|
30
|
+
CPL_ENC_UCS2 = 'UCS-2'
|
31
|
+
CPL_ENC_UCS4 = 'UCS-4'
|
32
|
+
CPL_ENC_ASCII = 'ASCII'
|
33
|
+
CPL_ENC_ISO8859_1 = 'ISO-8859-1'
|
34
|
+
|
35
|
+
typedef :string, :CPLString
|
36
|
+
|
37
|
+
#------------------------------------------------------------------------
|
38
|
+
# Enums
|
39
|
+
#------------------------------------------------------------------------
|
40
|
+
CPLValueType = enum :CPL_VALUE_STRING,
|
41
|
+
:CPL_VALUE_REAL,
|
42
|
+
:CPL_VALUE_INTEGER
|
43
|
+
|
44
|
+
#------------------------------------------------------------------------
|
45
|
+
# Functions
|
46
|
+
#------------------------------------------------------------------------
|
47
|
+
attach_function :CSLAddString, %i[pointer string], :pointer
|
48
|
+
attach_function :CSLCount, %i[pointer], :int
|
49
|
+
attach_function :CSLGetField, %i[pointer int], :string
|
50
|
+
attach_function :CSLDestroy, %i[pointer], :void
|
51
|
+
attach_function :CSLDuplicate, %i[pointer], :pointer
|
52
|
+
attach_function :CSLMerge, %i[pointer pointer], :pointer
|
53
|
+
attach_function :CSLTokenizeString, %i[string], :pointer
|
54
|
+
attach_function :CSLTokenizeStringComplex,
|
55
|
+
%i[string string int int],
|
56
|
+
:pointer
|
57
|
+
attach_function :CSLTokenizeString2, %i[string string int], :pointer
|
58
|
+
attach_function :CSLPrint, %i[pointer pointer], :int
|
59
|
+
attach_function :CSLLoad, %i[string], :pointer
|
60
|
+
attach_function :CSLLoad2, %i[string int int pointer], :pointer
|
61
|
+
attach_function :CSLSave, %i[pointer string], :int
|
62
|
+
attach_function :CSLInsertStrings, %i[pointer int pointer], :pointer
|
63
|
+
attach_function :CSLInsertString, %i[pointer int string], :pointer
|
64
|
+
attach_function :CSLRemoveStrings, %i[pointer int int pointer], :pointer
|
65
|
+
attach_function :CSLFindString, %i[pointer string], :int
|
66
|
+
#attach_function :CSLFindStringCaseSensitive, %i[pointer string], :int
|
67
|
+
attach_function :CSLPartialFindString, %i[pointer string], :int
|
68
|
+
attach_function :CSLFindName, %i[pointer string], :int
|
69
|
+
|
70
|
+
attach_function :CSLTestBoolean, %i[string], :int
|
71
|
+
attach_function :CSLFetchBoolean, %i[pointer string int], :int
|
72
|
+
|
73
|
+
attach_function :CPLSPrintf, %i[string varargs], :string
|
74
|
+
attach_function :CSLAppendPrintf, %i[pointer string varargs], :pointer
|
75
|
+
attach_function :CPLVASPrintf, %i[pointer string varargs], :pointer
|
76
|
+
attach_function :CPLParseNameValue, %i[string pointer], :string
|
77
|
+
|
78
|
+
attach_function :CSLFetchNameValue, %i[pointer string], :string
|
79
|
+
attach_function :CSLFetchNameValueDef, %i[pointer string string], :string
|
80
|
+
attach_function :CSLFetchNameValueMultiple, %i[pointer string], :pointer
|
81
|
+
attach_function :CSLAddNameValue, %i[pointer string string], :pointer
|
82
|
+
attach_function :CSLSetNameValue, %i[pointer string string], :pointer
|
83
|
+
attach_function :CSLSetNameValueSeparator, %i[pointer string], :void
|
84
|
+
|
85
|
+
attach_function :CPLEscapeString, %i[string int int], :string
|
86
|
+
attach_function :CPLUnescapeString, %i[string pointer int], :string
|
87
|
+
attach_function :CPLBinaryToHex, %i[int pointer], :string
|
88
|
+
attach_function :CPLHexToBinary, %i[string pointer], :pointer
|
89
|
+
attach_function :CPLBase64Encode, %i[int pointer], :string
|
90
|
+
attach_function :CPLBase64DecodeInPlace, %i[pointer], :int
|
91
|
+
|
92
|
+
attach_function :CPLGetValueType, %i[string], CPLValueType
|
93
|
+
attach_function :CPLStrlcpy, %i[string string size_t], :size_t
|
94
|
+
attach_function :CPLStrlcat, %i[string string size_t], :size_t
|
95
|
+
attach_function :CPLStrnlen, %i[string size_t], :size_t
|
96
|
+
attach_function :CPLEncodingCharSize, %i[string], :int
|
97
|
+
|
98
|
+
attach_function :CPLClearRecodeWarningFlags, [], :void
|
99
|
+
attach_function :CPLRecode, %i[string string string], :string
|
100
|
+
attach_function :CPLRecodeFromWChar, %i[string string string], :string
|
101
|
+
attach_function :CPLRecodeToWChar, %i[string string string], :string
|
102
|
+
|
103
|
+
attach_function :CPLIsUTF8, %i[string int], :int
|
104
|
+
attach_function :CPLForceToASCII, %i[string int char], :string
|
105
|
+
attach_function :CPLStrlenUTF8, %i[string], :int
|
106
|
+
|
107
|
+
#attach_function :CPLOPrintf, %i[string varargs], :CPLString
|
108
|
+
#attach_function :CPLOvPrintf, %i[string varargs], :CPLString
|
109
|
+
#attach_function :CPLURLGetValue, %i[string string], :CPLString
|
110
|
+
#attach_function :CPLURLAddKVP, %i[string string string], :CPLString
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|