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
@@ -1,82 +1,80 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
module Proj
|
3
|
-
class PjObject
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@pointer
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Proj
|
3
|
+
class PjObject
|
4
|
+
def self.finalize(pointer)
|
5
|
+
proc do
|
6
|
+
Api.proj_destroy(pointer)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(pointer, context=nil)
|
11
|
+
@pointer = pointer
|
12
|
+
@context = context
|
13
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_ptr
|
17
|
+
@pointer
|
18
|
+
end
|
19
|
+
|
20
|
+
def context
|
21
|
+
@context || Context.current
|
22
|
+
end
|
23
|
+
|
24
|
+
def proj_type
|
25
|
+
Api.proj_get_type(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def info
|
29
|
+
Api.proj_pj_info(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def id
|
33
|
+
self.info[:id]
|
34
|
+
end
|
35
|
+
|
36
|
+
def name
|
37
|
+
Api.proj_get_name(self).force_encoding('UTF-8')
|
38
|
+
end
|
39
|
+
|
40
|
+
def auth_name(index=0)
|
41
|
+
Api.proj_get_id_auth_name(self, index).force_encoding('UTF-8')
|
42
|
+
end
|
43
|
+
|
44
|
+
def auth_code(index=0)
|
45
|
+
Api.proj_get_id_code(self, index)
|
46
|
+
end
|
47
|
+
|
48
|
+
def auth(index=0)
|
49
|
+
"#{self.auth_name(index)}:#{self.auth_code(index)}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def description
|
53
|
+
self.info[:description] ? self.info[:description].force_encoding('UTF-8') : nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def definition
|
57
|
+
self.info[:definition] ? self.info[:definition].force_encoding('UTF-8') : nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def has_inverse?
|
61
|
+
self.info[:has_inverse] == 1 ? true : false
|
62
|
+
end
|
63
|
+
|
64
|
+
def accuracy
|
65
|
+
self.info[:accuracy]
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_proj_string(string_type=:PJ_PROJ_4)
|
69
|
+
Api.proj_as_proj_string(self.context, self, string_type, nil).force_encoding('UTF-8')
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_json
|
73
|
+
Api.proj_as_projjson(self.context, self, nil).force_encoding('UTF-8')
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_wkt(wkt_type=:PJ_WKT2_2018)
|
77
|
+
Api.proj_as_wkt(self.context, self, wkt_type, nil).force_encoding('UTF-8')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,72 +1,72 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Proj
|
4
|
-
# @deprecated This class is *DEPRECATED.* It will be removed when Proj 7 is released and removes the
|
5
|
-
# underlying API's this class uses. Code should be ported to use Coordinate objects.
|
6
|
-
class Point
|
7
|
-
def self.from_pointer(pointer)
|
8
|
-
result = self.allocate
|
9
|
-
result.instance_variable_set(:@struct, pointer)
|
10
|
-
result
|
11
|
-
end
|
12
|
-
|
13
|
-
# Create new Point object from coordinates.
|
14
|
-
def initialize(x, y)
|
15
|
-
@struct = Api::ProjUV.new
|
16
|
-
@struct[:u] = x
|
17
|
-
@struct[:v] = y
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_ptr
|
21
|
-
@struct.to_ptr
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_radians
|
25
|
-
self.class.new(Api.proj_torad(self.x), Api.proj_torad(self.y))
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_degrees
|
29
|
-
self.class.new(Api.proj_todeg(self.x), Api.proj_todeg(self.y))
|
30
|
-
end
|
31
|
-
|
32
|
-
# Get x coordinate.
|
33
|
-
def x
|
34
|
-
@struct[:u]
|
35
|
-
end
|
36
|
-
|
37
|
-
# Set x coordinate.
|
38
|
-
def x=(value)
|
39
|
-
@struct[:u] = value
|
40
|
-
end
|
41
|
-
|
42
|
-
# Get y coordinate.
|
43
|
-
def y
|
44
|
-
@struct[:v]
|
45
|
-
end
|
46
|
-
|
47
|
-
# Set y coordinate.
|
48
|
-
def y=(value)
|
49
|
-
@struct[:v] = value
|
50
|
-
end
|
51
|
-
|
52
|
-
# Get longitude/x coordinate.
|
53
|
-
def lon
|
54
|
-
@struct[:u]
|
55
|
-
end
|
56
|
-
|
57
|
-
# Set longitude/x coordinate.
|
58
|
-
def lon=(value)
|
59
|
-
@struct[:u] = value
|
60
|
-
end
|
61
|
-
|
62
|
-
# Get latitude/y coordinate.
|
63
|
-
def lat
|
64
|
-
@struct[:v]
|
65
|
-
end
|
66
|
-
|
67
|
-
# Set latitude/y coordinate.
|
68
|
-
def lat=(value)
|
69
|
-
@struct[:v] = value
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Proj
|
4
|
+
# @deprecated This class is *DEPRECATED.* It will be removed when Proj 7 is released and removes the
|
5
|
+
# underlying API's this class uses. Code should be ported to use Coordinate objects.
|
6
|
+
class Point
|
7
|
+
def self.from_pointer(pointer)
|
8
|
+
result = self.allocate
|
9
|
+
result.instance_variable_set(:@struct, pointer)
|
10
|
+
result
|
11
|
+
end
|
12
|
+
|
13
|
+
# Create new Point object from coordinates.
|
14
|
+
def initialize(x, y)
|
15
|
+
@struct = Api::ProjUV.new
|
16
|
+
@struct[:u] = x
|
17
|
+
@struct[:v] = y
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_ptr
|
21
|
+
@struct.to_ptr
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_radians
|
25
|
+
self.class.new(Api.proj_torad(self.x), Api.proj_torad(self.y))
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_degrees
|
29
|
+
self.class.new(Api.proj_todeg(self.x), Api.proj_todeg(self.y))
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get x coordinate.
|
33
|
+
def x
|
34
|
+
@struct[:u]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Set x coordinate.
|
38
|
+
def x=(value)
|
39
|
+
@struct[:u] = value
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get y coordinate.
|
43
|
+
def y
|
44
|
+
@struct[:v]
|
45
|
+
end
|
46
|
+
|
47
|
+
# Set y coordinate.
|
48
|
+
def y=(value)
|
49
|
+
@struct[:v] = value
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get longitude/x coordinate.
|
53
|
+
def lon
|
54
|
+
@struct[:u]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Set longitude/x coordinate.
|
58
|
+
def lon=(value)
|
59
|
+
@struct[:u] = value
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get latitude/y coordinate.
|
63
|
+
def lat
|
64
|
+
@struct[:v]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Set latitude/y coordinate.
|
68
|
+
def lat=(value)
|
69
|
+
@struct[:v] = value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,40 +1,40 @@
|
|
1
|
-
module Proj
|
2
|
-
class PrimeMeridian
|
3
|
-
attr_reader :id, :defn
|
4
|
-
|
5
|
-
def self.list
|
6
|
-
pointer_to_array = FFI::Pointer.new(Api::PJ_PRIME_MERIDIANS, Api.proj_list_prime_meridians)
|
7
|
-
result = Array.new
|
8
|
-
0.step do |i|
|
9
|
-
prime_meridian_info = Api::PJ_PRIME_MERIDIANS.new(pointer_to_array[i])
|
10
|
-
break result if prime_meridian_info[:id].nil?
|
11
|
-
result << self.new(prime_meridian_info[:id], prime_meridian_info[:defn])
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.get(id)
|
16
|
-
self.list.find {|ellipsoid| ellipsoid.id == id}
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(id, defn)
|
20
|
-
@id = id
|
21
|
-
@defn = defn
|
22
|
-
end
|
23
|
-
|
24
|
-
def <=>(other)
|
25
|
-
self.id <=> other.id
|
26
|
-
end
|
27
|
-
|
28
|
-
def ==(other)
|
29
|
-
self.id == other.id
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_s
|
33
|
-
self.id
|
34
|
-
end
|
35
|
-
|
36
|
-
def inspect
|
37
|
-
"#<#{self.class} id=\"#{id}\", defn=\"#{defn}\">"
|
38
|
-
end
|
39
|
-
end
|
1
|
+
module Proj
|
2
|
+
class PrimeMeridian
|
3
|
+
attr_reader :id, :defn
|
4
|
+
|
5
|
+
def self.list
|
6
|
+
pointer_to_array = FFI::Pointer.new(Api::PJ_PRIME_MERIDIANS, Api.proj_list_prime_meridians)
|
7
|
+
result = Array.new
|
8
|
+
0.step do |i|
|
9
|
+
prime_meridian_info = Api::PJ_PRIME_MERIDIANS.new(pointer_to_array[i])
|
10
|
+
break result if prime_meridian_info[:id].nil?
|
11
|
+
result << self.new(prime_meridian_info[:id], prime_meridian_info[:defn])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get(id)
|
16
|
+
self.list.find {|ellipsoid| ellipsoid.id == id}
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(id, defn)
|
20
|
+
@id = id
|
21
|
+
@defn = defn
|
22
|
+
end
|
23
|
+
|
24
|
+
def <=>(other)
|
25
|
+
self.id <=> other.id
|
26
|
+
end
|
27
|
+
|
28
|
+
def ==(other)
|
29
|
+
self.id == other.id
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
self.id
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect
|
37
|
+
"#<#{self.class} id=\"#{id}\", defn=\"#{defn}\">"
|
38
|
+
end
|
39
|
+
end
|
40
40
|
end
|