proj4rb 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +34 -8
- data/README.rdoc +24 -25
- data/Rakefile +1 -0
- data/lib/api/api.rb +118 -0
- data/lib/api/api_4_9.rb +31 -0
- data/lib/api/api_5_0.rb +301 -0
- data/lib/api/api_5_1.rb +7 -0
- data/lib/api/api_5_2.rb +5 -0
- data/lib/api/api_6_0.rb +42 -0
- data/lib/api/api_6_1.rb +5 -0
- data/lib/api/api_6_2.rb +7 -0
- data/lib/{area.rb → proj/area.rb} +32 -32
- data/lib/{config.rb → proj/config.rb} +69 -69
- data/lib/{context.rb → proj/context.rb} +102 -102
- data/lib/{coordinate.rb → proj/coordinate.rb} +197 -197
- data/lib/{crs.rb → proj/crs.rb} +204 -206
- data/lib/{ellipsoid.rb → proj/ellipsoid.rb} +41 -41
- data/lib/{error.rb → proj/error.rb} +17 -17
- data/lib/{operation.rb → proj/operation.rb} +42 -42
- data/lib/{pj_object.rb → proj/pj_object.rb} +80 -82
- data/lib/{point.rb → proj/point.rb} +72 -72
- data/lib/{prime_meridian.rb → proj/prime_meridian.rb} +39 -39
- data/lib/{projection.rb → proj/projection.rb} +206 -206
- data/lib/{transformation.rb → proj/transformation.rb} +60 -60
- data/lib/{unit.rb → proj/unit.rb} +53 -53
- data/lib/proj.rb +31 -31
- data/proj4rb.gemspec +5 -3
- data/test/context_test.rb +81 -81
- data/test/crs_test.rb +1 -1
- data/test/proj_test.rb +5 -5
- data/test/projection_test.rb +183 -181
- metadata +58 -22
data/lib/proj.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative 'api/api'
|
4
|
-
require_relative '
|
5
|
-
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
8
|
-
require_relative '
|
9
|
-
require_relative '
|
10
|
-
require_relative '
|
11
|
-
require_relative '
|
12
|
-
require_relative '
|
13
|
-
require_relative '
|
14
|
-
|
15
|
-
require_relative '
|
16
|
-
require_relative '
|
17
|
-
require_relative '
|
18
|
-
require_relative '
|
19
|
-
require_relative '
|
20
|
-
|
21
|
-
module Proj
|
22
|
-
def self.info
|
23
|
-
Api.proj_info
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.version
|
27
|
-
self.info[:version]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Proj::Config.instance.set_search_paths
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'api/api'
|
4
|
+
require_relative 'proj/config'
|
5
|
+
|
6
|
+
require_relative 'proj/area'
|
7
|
+
require_relative 'proj/context'
|
8
|
+
require_relative 'proj/coordinate'
|
9
|
+
require_relative 'proj/ellipsoid'
|
10
|
+
require_relative 'proj/error'
|
11
|
+
require_relative 'proj/point'
|
12
|
+
require_relative 'proj/prime_meridian'
|
13
|
+
require_relative 'proj/unit'
|
14
|
+
|
15
|
+
require_relative 'proj/pj_object'
|
16
|
+
require_relative 'proj/operation'
|
17
|
+
require_relative 'proj/crs'
|
18
|
+
require_relative 'proj/projection'
|
19
|
+
require_relative 'proj/transformation'
|
20
|
+
|
21
|
+
module Proj
|
22
|
+
def self.info
|
23
|
+
Api.proj_info
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.version
|
27
|
+
self.info[:version]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Proj::Config.instance.set_search_paths
|
data/proj4rb.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'proj4rb'
|
3
|
-
spec.version = '
|
3
|
+
spec.version = '3.0.0'
|
4
4
|
spec.summary = 'Ruby bindings for the Proj.4 Carthographic Projection library'
|
5
5
|
spec.description = <<-EOF
|
6
6
|
Proj4rb is a ruby binding for the Proj.4 Carthographic Projection library, that supports conversions between a very large number of geographic coordinate systems and datumspec.
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
9
9
|
spec.authors = ['Guilhem Vellut', 'Jochen Topf', 'Charlie Savage']
|
10
10
|
spec.homepage = 'https://github.com/cfis/proj4rb'
|
11
|
-
spec.required_ruby_version = '>= 2.4.
|
11
|
+
spec.required_ruby_version = '>= 2.4.1'
|
12
12
|
spec.license = 'MIT'
|
13
13
|
|
14
14
|
spec.requirements << 'Proj (Proj4) Library'
|
@@ -19,13 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
'proj4rb.gemspec',
|
20
20
|
'Rakefile',
|
21
21
|
'README.rdoc',
|
22
|
-
'lib
|
22
|
+
'lib/**/*.rb',
|
23
23
|
'test/*.rb']
|
24
24
|
|
25
25
|
spec.test_files = Dir["test/test_*.rb"]
|
26
26
|
|
27
27
|
spec.add_dependency "ffi"
|
28
28
|
|
29
|
+
spec.add_development_dependency('bundler')
|
30
|
+
spec.add_development_dependency('rake')
|
29
31
|
spec.add_development_dependency('minitest')
|
30
32
|
spec.add_development_dependency('yard')
|
31
33
|
end
|
data/test/context_test.rb
CHANGED
@@ -1,82 +1,82 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative './abstract_test'
|
4
|
-
|
5
|
-
class ContextTest < AbstractTest
|
6
|
-
def test_create
|
7
|
-
context = Proj::Context.new
|
8
|
-
assert(context.to_ptr)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_finalize
|
12
|
-
500.times do
|
13
|
-
context = Proj::Context.new
|
14
|
-
assert(context.to_ptr)
|
15
|
-
GC.start
|
16
|
-
end
|
17
|
-
assert(true)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_one_per_thread
|
21
|
-
context_1 = Proj::Context.current
|
22
|
-
context_2 = Proj::Context.current
|
23
|
-
assert_same(context_1, context_2)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_database_path
|
27
|
-
refute_nil(Proj::Context.current.database_path)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_log_level
|
31
|
-
assert_equal(:PJ_LOG_NONE, Proj::Context.current.log_level)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_set_log_level
|
35
|
-
context = Proj::Context.new
|
36
|
-
context.log_level = :PJ_LOG_ERROR
|
37
|
-
assert_equal(:PJ_LOG_ERROR, context.log_level)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_invalid_database_path
|
41
|
-
path = '/wrong'
|
42
|
-
error = assert_raises(Proj::Error) do
|
43
|
-
Proj::Context.current.database_path = path
|
44
|
-
end
|
45
|
-
# TODO - if you run this test on its own you get a useful error message, if you run all tests
|
46
|
-
# at once you get a useless error message. Not sure what is causing the difference
|
47
|
-
assert_match(/No such file or directory|generic error of unknown origin/, error.to_s)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_set_log_function
|
51
|
-
context = Proj::Context.new
|
52
|
-
called = false
|
53
|
-
|
54
|
-
data = FFI::MemoryPointer.new(:int)
|
55
|
-
data.write_int(5)
|
56
|
-
|
57
|
-
context.set_log_function(data) do |pointer, int, message|
|
58
|
-
called = true
|
59
|
-
refute(pointer.null?)
|
60
|
-
assert_equal(5, pointer.read_int)
|
61
|
-
assert_equal(1, int)
|
62
|
-
assert_equal('proj_context_set_database_path: Open of /wrong failed', message)
|
63
|
-
end
|
64
|
-
|
65
|
-
begin
|
66
|
-
context.database_path = '/wrong'
|
67
|
-
rescue
|
68
|
-
end
|
69
|
-
|
70
|
-
assert(called)
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_use_proj4_init_rules
|
74
|
-
refute(Proj::Context.current.use_proj4_init_rules)
|
75
|
-
|
76
|
-
Proj::Context.current.use_proj4_init_rules = true
|
77
|
-
assert(Proj::Context.current.use_proj4_init_rules)
|
78
|
-
|
79
|
-
Proj::Context.current.use_proj4_init_rules = false
|
80
|
-
refute(Proj::Context.current.use_proj4_init_rules)
|
81
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class ContextTest < AbstractTest
|
6
|
+
def test_create
|
7
|
+
context = Proj::Context.new
|
8
|
+
assert(context.to_ptr)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_finalize
|
12
|
+
500.times do
|
13
|
+
context = Proj::Context.new
|
14
|
+
assert(context.to_ptr)
|
15
|
+
GC.start
|
16
|
+
end
|
17
|
+
assert(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_one_per_thread
|
21
|
+
context_1 = Proj::Context.current
|
22
|
+
context_2 = Proj::Context.current
|
23
|
+
assert_same(context_1, context_2)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_database_path
|
27
|
+
refute_nil(Proj::Context.current.database_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_log_level
|
31
|
+
assert_equal(:PJ_LOG_NONE, Proj::Context.current.log_level)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_set_log_level
|
35
|
+
context = Proj::Context.new
|
36
|
+
context.log_level = :PJ_LOG_ERROR
|
37
|
+
assert_equal(:PJ_LOG_ERROR, context.log_level)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_invalid_database_path
|
41
|
+
path = '/wrong'
|
42
|
+
error = assert_raises(Proj::Error) do
|
43
|
+
Proj::Context.current.database_path = path
|
44
|
+
end
|
45
|
+
# TODO - if you run this test on its own you get a useful error message, if you run all tests
|
46
|
+
# at once you get a useless error message. Not sure what is causing the difference
|
47
|
+
assert_match(/No such file or directory|generic error of unknown origin/, error.to_s)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_set_log_function
|
51
|
+
context = Proj::Context.new
|
52
|
+
called = false
|
53
|
+
|
54
|
+
data = FFI::MemoryPointer.new(:int)
|
55
|
+
data.write_int(5)
|
56
|
+
|
57
|
+
context.set_log_function(data) do |pointer, int, message|
|
58
|
+
called = true
|
59
|
+
refute(pointer.null?)
|
60
|
+
assert_equal(5, pointer.read_int)
|
61
|
+
assert_equal(1, int)
|
62
|
+
assert_equal('proj_context_set_database_path: Open of /wrong failed', message)
|
63
|
+
end
|
64
|
+
|
65
|
+
begin
|
66
|
+
context.database_path = '/wrong'
|
67
|
+
rescue
|
68
|
+
end
|
69
|
+
|
70
|
+
assert(called)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_use_proj4_init_rules
|
74
|
+
refute(Proj::Context.current.use_proj4_init_rules)
|
75
|
+
|
76
|
+
Proj::Context.current.use_proj4_init_rules = true
|
77
|
+
assert(Proj::Context.current.use_proj4_init_rules)
|
78
|
+
|
79
|
+
Proj::Context.current.use_proj4_init_rules = false
|
80
|
+
refute(Proj::Context.current.use_proj4_init_rules)
|
81
|
+
end
|
82
82
|
end
|
data/test/crs_test.rb
CHANGED
@@ -221,7 +221,7 @@ class CrsTest < AbstractTest
|
|
221
221
|
crs = Proj::Crs.new('EPSG:26915')
|
222
222
|
expected = <<~EOS
|
223
223
|
{
|
224
|
-
"$schema": "https://proj.org/schemas/v0.
|
224
|
+
"$schema": "https://proj.org/schemas/v0.2/projjson.schema.json",
|
225
225
|
"type": "ProjectedCRS",
|
226
226
|
"name": "NAD83 / UTM zone 15N",
|
227
227
|
"base_crs": {
|
data/test/proj_test.rb
CHANGED
@@ -5,11 +5,11 @@ require_relative './abstract_test'
|
|
5
5
|
class ProjTest < AbstractTest
|
6
6
|
def test_info
|
7
7
|
info = Proj.info
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
assert([4,6,7,8].include?(info[:major]))
|
9
|
+
assert([0,1,2,3].include?(info[:minor]))
|
10
|
+
assert([0,1,2,3].include?(info[:patch]))
|
11
|
+
refute_nil(info[:release])
|
12
|
+
assert_match(/\d\.\d\.\d/, info[:version])
|
13
13
|
refute_nil(info[:searchpath])
|
14
14
|
refute(info[:paths].null?)
|
15
15
|
assert_equal(1, info[:path_count])
|