proj4rb 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +1,42 @@
1
- module Proj
2
- class Ellipsoid
3
- attr_reader :id, :major, :ell, :name
4
-
5
- def self.list
6
- pointer_to_array = FFI::Pointer.new(Api::PJ_ELLPS, Api.proj_list_ellps)
7
- result = Array.new
8
- 0.step do |i|
9
- ellipse_info = Api::PJ_ELLPS.new(pointer_to_array[i])
10
- break result if ellipse_info[:id].nil?
11
- result << self.new(ellipse_info[:id], ellipse_info[:major], ellipse_info[:ell], ellipse_info[:name])
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, major, ell, name)
20
- @id = id
21
- @major = major
22
- @ell = ell
23
- @name = name
24
- end
25
-
26
- def <=>(other)
27
- self.id <=> other.id
28
- end
29
-
30
- def ==(other)
31
- self.id == other.id
32
- end
33
-
34
- def to_s
35
- self.id
36
- end
37
-
38
- def inspect
39
- "#<#{self.class} id=\"#{id}\", major=\"#{major}\", ell=\"#{ell}\", name=\"#{name}\">"
40
- end
41
- end
1
+ module Proj
2
+ class Ellipsoid
3
+ attr_reader :id, :major, :ell, :name
4
+
5
+ def self.list
6
+ pointer_to_array = FFI::Pointer.new(Api::PJ_ELLPS, Api.proj_list_ellps)
7
+ result = Array.new
8
+ 0.step do |i|
9
+ ellipse_info = Api::PJ_ELLPS.new(pointer_to_array[i])
10
+ break result if ellipse_info[:id].nil?
11
+ result << self.new(ellipse_info[:id], ellipse_info[:major], ellipse_info[:ell], ellipse_info[:name])
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, major, ell, name)
20
+ @id = id
21
+ @major = major
22
+ @ell = ell
23
+ @name = name
24
+ end
25
+
26
+ def <=>(other)
27
+ self.id <=> other.id
28
+ end
29
+
30
+ def ==(other)
31
+ self.id == other.id
32
+ end
33
+
34
+ def to_s
35
+ self.id
36
+ end
37
+
38
+ def inspect
39
+ "#<#{self.class} id=\"#{id}\", major=\"#{major}\", ell=\"#{ell}\", name=\"#{name}\">"
40
+ end
41
+ end
42
42
  end
@@ -1,18 +1,18 @@
1
- module Proj
2
- class Error < StandardError
3
- def self.check(errno=nil)
4
- unless errno
5
- errno = Context.current.errno
6
- end
7
-
8
- if errno != 0
9
- message = if Api.method_defined?(:proj_errno_string)
10
- Api.proj_errno_string(errno)
11
- else
12
- Api.pj_strerrno(errno)
13
- end
14
- raise(self, message)
15
- end
16
- end
17
- end
1
+ module Proj
2
+ class Error < StandardError
3
+ def self.check(errno=nil)
4
+ unless errno
5
+ errno = Context.current.errno
6
+ end
7
+
8
+ if errno != 0
9
+ message = if Api.method_defined?(:proj_errno_string)
10
+ Api.proj_errno_string(errno)
11
+ else
12
+ Api.pj_strerrno(errno)
13
+ end
14
+ raise(self, message)
15
+ end
16
+ end
17
+ end
18
18
  end
@@ -1,43 +1,43 @@
1
- module Proj
2
- class Operation
3
- attr_reader :id, :description
4
-
5
- def self.list
6
- pointer_to_array = FFI::Pointer.new(Api::PJ_OPERATIONS, Api.proj_list_operations)
7
- result = Array.new
8
- 0.step do |i|
9
- operation_info = Api::PJ_OPERATIONS.new(pointer_to_array[i])
10
- break result if operation_info[:id].nil?
11
- id = operation_info[:id]
12
- description = operation_info[:descr].read_pointer.read_string.force_encoding('UTF-8')
13
- result << self.new(id, description)
14
- end
15
- result
16
- end
17
-
18
- def self.get(id)
19
- self.list.find {|operation| operation.id == id}
20
- end
21
-
22
- def initialize(id, description)
23
- @id = id
24
- @description = description
25
- end
26
-
27
- def <=>(other)
28
- self.id <=> other.id
29
- end
30
-
31
- def ==(other)
32
- self.id == other.id
33
- end
34
-
35
- def to_s
36
- self.id
37
- end
38
-
39
- def inspect
40
- "#<#{self.class} id=\"#{id}\", major=\"#{major}\", ell=\"#{ell}\", name=\"#{name}\">"
41
- end
42
- end
1
+ module Proj
2
+ class Operation
3
+ attr_reader :id, :description
4
+
5
+ def self.list
6
+ pointer_to_array = FFI::Pointer.new(Api::PJ_OPERATIONS, Api.proj_list_operations)
7
+ result = Array.new
8
+ 0.step do |i|
9
+ operation_info = Api::PJ_OPERATIONS.new(pointer_to_array[i])
10
+ break result if operation_info[:id].nil?
11
+ id = operation_info[:id]
12
+ description = operation_info[:descr].read_pointer.read_string.force_encoding('UTF-8')
13
+ result << self.new(id, description)
14
+ end
15
+ result
16
+ end
17
+
18
+ def self.get(id)
19
+ self.list.find {|operation| operation.id == id}
20
+ end
21
+
22
+ def initialize(id, description)
23
+ @id = id
24
+ @description = description
25
+ end
26
+
27
+ def <=>(other)
28
+ self.id <=> other.id
29
+ end
30
+
31
+ def ==(other)
32
+ self.id == other.id
33
+ end
34
+
35
+ def to_s
36
+ self.id
37
+ end
38
+
39
+ def inspect
40
+ "#<#{self.class} id=\"#{id}\", major=\"#{major}\", ell=\"#{ell}\", name=\"#{name}\">"
41
+ end
42
+ end
43
43
  end
@@ -1,80 +1,80 @@
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
+ # 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