proj4rb 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,82 +1,80 @@
1
- # encoding: UTF-8
2
- module Proj
3
- class PjObject
4
- attr_reader :context
5
-
6
- def self.finalize(pointer)
7
- proc do
8
- Api.proj_destroy(pointer)
9
- end
10
- end
11
-
12
- def initialize(pointer, context=nil)
13
- @pointer = pointer
14
- @context = context
15
- ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
16
- end
17
-
18
- def to_ptr
19
- @pointer
20
- end
21
-
22
- def context
23
- @context || Context.current
24
- end
25
-
26
- def proj_type
27
- Api.proj_get_type(self)
28
- end
29
-
30
- def info
31
- Api.proj_pj_info(self)
32
- end
33
-
34
- def id
35
- self.info[:id]
36
- end
37
-
38
- def name
39
- Api.proj_get_name(self).force_encoding('UTF-8')
40
- end
41
-
42
- def auth_name(index=0)
43
- Api.proj_get_id_auth_name(self, index).force_encoding('UTF-8')
44
- end
45
-
46
- def auth_code(index=0)
47
- Api.proj_get_id_code(self, index)
48
- end
49
-
50
- def auth(index=0)
51
- "#{self.auth_name(index)}:#{self.auth_code(index)}"
52
- end
53
-
54
- def description
55
- self.info[:description] ? self.info[:description].force_encoding('UTF-8') : nil
56
- end
57
-
58
- def definition
59
- self.info[:definition] ? self.info[:definition].force_encoding('UTF-8') : nil
60
- end
61
-
62
- def has_inverse?
63
- self.info[:has_inverse] == 1 ? true : false
64
- end
65
-
66
- def accuracy
67
- self.info[:accuracy]
68
- end
69
-
70
- def to_proj_string(string_type=:PJ_PROJ_4)
71
- Api.proj_as_proj_string(self.context, self, string_type, nil).force_encoding('UTF-8')
72
- end
73
-
74
- def to_json
75
- Api.proj_as_projjson(self.context, self, nil).force_encoding('UTF-8')
76
- end
77
-
78
- def to_wkt(wkt_type=:PJ_WKT2_2018)
79
- Api.proj_as_wkt(self.context, self, wkt_type, nil).force_encoding('UTF-8')
80
- end
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