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/{crs.rb → proj/crs.rb}
RENAMED
@@ -1,206 +1,204 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
module Proj
|
5
|
-
# Represents a coordinate reference system.
|
6
|
-
class Crs < PjObject
|
7
|
-
# To create a coordinate system, you can use CRS codes, well-known text (WKT) strings
|
8
|
-
# or old-style Proj4 strings (which are deprecated).
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# crs1 = Proj::Crs.new('EPSG:4326')
|
12
|
-
# crs2 = Proj::Crs.new('urn:ogc:def:crs:EPSG::4326')
|
13
|
-
# crs3 = Proj::Crs.new('+proj=longlat +datum=WGS84 +no_defs +type=crs')
|
14
|
-
# crs4 = Proj::Crs.new(<<~EOS)
|
15
|
-
# GEOGCRS["WGS 84",
|
16
|
-
# DATUM["World Geodetic System 1984",
|
17
|
-
# ELLIPSOID["WGS 84",6378137,298.257223563,
|
18
|
-
# LENGTHUNIT["metre",1]]],
|
19
|
-
# PRIMEM["Greenwich",0,
|
20
|
-
# ANGLEUNIT["degree",0.0174532925199433]],
|
21
|
-
# CS[ellipsoidal,2],
|
22
|
-
# AXIS["geodetic latitude (Lat)",north,
|
23
|
-
# ORDER[1],
|
24
|
-
# ANGLEUNIT["degree",0.0174532925199433]],
|
25
|
-
# AXIS["geodetic longitude (Lon)",east,
|
26
|
-
# ORDER[2],
|
27
|
-
# ANGLEUNIT["degree",0.0174532925199433]],
|
28
|
-
# USAGE[
|
29
|
-
# SCOPE["unknown"],
|
30
|
-
# AREA["World"],
|
31
|
-
# BBOX[-90,-180,90,180]],
|
32
|
-
# ID["EPSG",4326]]
|
33
|
-
# EOS
|
34
|
-
#
|
35
|
-
# Notice when using the old-style Proj4 string, the addition of the "+type=crs" value.
|
36
|
-
#
|
37
|
-
# @param value [String]. See above
|
38
|
-
# @param context [Context]. An optional Context that the Crs will use for calculations.
|
39
|
-
def initialize(value, context=nil)
|
40
|
-
pointer = Api.proj_create(context || Context.current, value)
|
41
|
-
|
42
|
-
if pointer.null?
|
43
|
-
Error.check
|
44
|
-
end
|
45
|
-
|
46
|
-
super(pointer, context)
|
47
|
-
|
48
|
-
if Api.method_defined?(:proj_is_crs) && !Api.proj_is_crs(pointer)
|
49
|
-
raise(Error, "Invalid crs definition. Proj created an instance of: #{self.proj_type}.")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Get the geodeticCRS / geographicCRS from a CRS.
|
54
|
-
#
|
55
|
-
# @return [Crs]
|
56
|
-
def geodetic_crs
|
57
|
-
PjObject.new(Api.proj_crs_get_geodetic_crs(self.context, self))
|
58
|
-
end
|
59
|
-
|
60
|
-
# Get a CRS component from a CompoundCRS.
|
61
|
-
#
|
62
|
-
# @return [Crs]
|
63
|
-
def sub_crs(index)
|
64
|
-
PjObject.new(Api.proj_crs_get_sub_crs(self.context, self, index))
|
65
|
-
end
|
66
|
-
|
67
|
-
# Returns the datum of a SingleCRS.
|
68
|
-
#
|
69
|
-
# @return [Crs]
|
70
|
-
def datum
|
71
|
-
PjObject.new(Api.proj_crs_get_datum(self.context, self))
|
72
|
-
end
|
73
|
-
|
74
|
-
# Get the horizontal datum from a CRS.
|
75
|
-
#
|
76
|
-
# @return [Crs]
|
77
|
-
def horizontal_datum
|
78
|
-
PjObject.new(Api.proj_crs_get_horizontal_datum(self.context, self))
|
79
|
-
end
|
80
|
-
|
81
|
-
# Returns the coordinate system of a SingleCRS.
|
82
|
-
#
|
83
|
-
# @return [Crs]
|
84
|
-
def coordinate_system
|
85
|
-
PjObject.new(Api.proj_crs_get_coordinate_system(self.context, self))
|
86
|
-
end
|
87
|
-
|
88
|
-
# Returns the number of axis of the coordinate system.
|
89
|
-
#
|
90
|
-
# @return [Integer]
|
91
|
-
def axis_count
|
92
|
-
|
93
|
-
result
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
#
|
101
|
-
#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
#
|
131
|
-
#
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
#
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
#
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
#
|
157
|
-
#
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
#
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
#
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
result
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
-
|
195
|
-
|
196
|
-
|
197
|
-
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
end
|
206
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Proj
|
5
|
+
# Represents a coordinate reference system.
|
6
|
+
class Crs < PjObject
|
7
|
+
# To create a coordinate system, you can use CRS codes, well-known text (WKT) strings
|
8
|
+
# or old-style Proj4 strings (which are deprecated).
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# crs1 = Proj::Crs.new('EPSG:4326')
|
12
|
+
# crs2 = Proj::Crs.new('urn:ogc:def:crs:EPSG::4326')
|
13
|
+
# crs3 = Proj::Crs.new('+proj=longlat +datum=WGS84 +no_defs +type=crs')
|
14
|
+
# crs4 = Proj::Crs.new(<<~EOS)
|
15
|
+
# GEOGCRS["WGS 84",
|
16
|
+
# DATUM["World Geodetic System 1984",
|
17
|
+
# ELLIPSOID["WGS 84",6378137,298.257223563,
|
18
|
+
# LENGTHUNIT["metre",1]]],
|
19
|
+
# PRIMEM["Greenwich",0,
|
20
|
+
# ANGLEUNIT["degree",0.0174532925199433]],
|
21
|
+
# CS[ellipsoidal,2],
|
22
|
+
# AXIS["geodetic latitude (Lat)",north,
|
23
|
+
# ORDER[1],
|
24
|
+
# ANGLEUNIT["degree",0.0174532925199433]],
|
25
|
+
# AXIS["geodetic longitude (Lon)",east,
|
26
|
+
# ORDER[2],
|
27
|
+
# ANGLEUNIT["degree",0.0174532925199433]],
|
28
|
+
# USAGE[
|
29
|
+
# SCOPE["unknown"],
|
30
|
+
# AREA["World"],
|
31
|
+
# BBOX[-90,-180,90,180]],
|
32
|
+
# ID["EPSG",4326]]
|
33
|
+
# EOS
|
34
|
+
#
|
35
|
+
# Notice when using the old-style Proj4 string, the addition of the "+type=crs" value.
|
36
|
+
#
|
37
|
+
# @param value [String]. See above
|
38
|
+
# @param context [Context]. An optional Context that the Crs will use for calculations.
|
39
|
+
def initialize(value, context=nil)
|
40
|
+
pointer = Api.proj_create(context || Context.current, value)
|
41
|
+
|
42
|
+
if pointer.null?
|
43
|
+
Error.check
|
44
|
+
end
|
45
|
+
|
46
|
+
super(pointer, context)
|
47
|
+
|
48
|
+
if Api.method_defined?(:proj_is_crs) && !Api.proj_is_crs(pointer)
|
49
|
+
raise(Error, "Invalid crs definition. Proj created an instance of: #{self.proj_type}.")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get the geodeticCRS / geographicCRS from a CRS.
|
54
|
+
#
|
55
|
+
# @return [Crs]
|
56
|
+
def geodetic_crs
|
57
|
+
PjObject.new(Api.proj_crs_get_geodetic_crs(self.context, self))
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get a CRS component from a CompoundCRS.
|
61
|
+
#
|
62
|
+
# @return [Crs]
|
63
|
+
def sub_crs(index)
|
64
|
+
PjObject.new(Api.proj_crs_get_sub_crs(self.context, self, index))
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the datum of a SingleCRS.
|
68
|
+
#
|
69
|
+
# @return [Crs]
|
70
|
+
def datum
|
71
|
+
PjObject.new(Api.proj_crs_get_datum(self.context, self))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Get the horizontal datum from a CRS.
|
75
|
+
#
|
76
|
+
# @return [Crs]
|
77
|
+
def horizontal_datum
|
78
|
+
PjObject.new(Api.proj_crs_get_horizontal_datum(self.context, self))
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns the coordinate system of a SingleCRS.
|
82
|
+
#
|
83
|
+
# @return [Crs]
|
84
|
+
def coordinate_system
|
85
|
+
PjObject.new(Api.proj_crs_get_coordinate_system(self.context, self))
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns the number of axis of the coordinate system.
|
89
|
+
#
|
90
|
+
# @return [Integer]
|
91
|
+
def axis_count
|
92
|
+
result = Api.proj_cs_get_axis_count(self.context, self.coordinate_system)
|
93
|
+
if result == -1
|
94
|
+
Error.check
|
95
|
+
end
|
96
|
+
result
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns information on an axis.
|
100
|
+
#
|
101
|
+
# @return [Array<Hash>]
|
102
|
+
def axis_info
|
103
|
+
self.axis_count.times.map do |index|
|
104
|
+
p_name = FFI::MemoryPointer.new(:pointer)
|
105
|
+
p_abbreviation = FFI::MemoryPointer.new(:pointer)
|
106
|
+
p_direction = FFI::MemoryPointer.new(:pointer)
|
107
|
+
p_unit_conv_factor = FFI::MemoryPointer.new(:double)
|
108
|
+
p_unit_name = FFI::MemoryPointer.new(:pointer)
|
109
|
+
p_unit_auth_name = FFI::MemoryPointer.new(:pointer)
|
110
|
+
p_unit_code = FFI::MemoryPointer.new(:pointer)
|
111
|
+
|
112
|
+
result = Api.proj_cs_get_axis_info(self.context, self.coordinate_system, index,
|
113
|
+
p_name, p_abbreviation, p_direction, p_unit_conv_factor, p_unit_name, p_unit_auth_name, p_unit_code)
|
114
|
+
|
115
|
+
unless result
|
116
|
+
Error.check
|
117
|
+
end
|
118
|
+
|
119
|
+
{:name => p_name.read_pointer.read_string,
|
120
|
+
:abbreviation => p_abbreviation.read_pointer.read_string_to_null,
|
121
|
+
:direction => p_direction.read_pointer.read_string_to_null,
|
122
|
+
:unit_conv_factor => p_unit_conv_factor.read_double,
|
123
|
+
:unit_name => p_unit_name.read_pointer.read_string_to_null,
|
124
|
+
:unit_auth_name => p_unit_auth_name.read_pointer.read_string_to_null,
|
125
|
+
:unit_code => p_unit_code.read_pointer.read_string_to_null}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Returns the type of the coordinate system.
|
130
|
+
#
|
131
|
+
# @return [:PJ_COORDINATE_SYSTEM_TYPE]
|
132
|
+
def crs_type
|
133
|
+
result = Api.proj_cs_get_type(self.context, self.coordinate_system)
|
134
|
+
if result == :PJ_CS_TYPE_UNKNOWN
|
135
|
+
Error.check
|
136
|
+
end
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
# Return the area of use of an object.
|
141
|
+
#
|
142
|
+
# @return [Area]
|
143
|
+
def area
|
144
|
+
@area ||= Area.for_object(self)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Get the ellipsoid from a CRS or a GeodeticReferenceFrame.
|
148
|
+
#
|
149
|
+
# @return [PjObject]
|
150
|
+
def ellipsoid
|
151
|
+
PjObject.new(Api.proj_get_ellipsoid(self.context, self))
|
152
|
+
end
|
153
|
+
|
154
|
+
# Return the Conversion of a DerivedCRS (such as a ProjectedCRS), or the Transformation from
|
155
|
+
# the baseCRS to the hubCRS of a BoundCRS.
|
156
|
+
#
|
157
|
+
# @return [PjObject]
|
158
|
+
def operation
|
159
|
+
pointer = Api.proj_crs_get_coordoperation(self.context, self)
|
160
|
+
if pointer.null?
|
161
|
+
Error.check
|
162
|
+
end
|
163
|
+
PjObject.new(pointer)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Get the prime meridian of a CRS or a GeodeticReferenceFrame.
|
167
|
+
#
|
168
|
+
# @return [PjObject]
|
169
|
+
def prime_meridian
|
170
|
+
PjObject.new(Api.proj_get_prime_meridian(self.context, self))
|
171
|
+
end
|
172
|
+
|
173
|
+
# A nicely printed out description
|
174
|
+
#
|
175
|
+
# @return [String]
|
176
|
+
def inspect
|
177
|
+
result = StringIO.new
|
178
|
+
result.set_encoding('UTF-8')
|
179
|
+
result << <<~EOS
|
180
|
+
<#{self.class.name}>: #{self.auth(0)}
|
181
|
+
#{self.description}
|
182
|
+
Axis Info [#{self.crs_type}]:
|
183
|
+
EOS
|
184
|
+
|
185
|
+
self.axis_info.each do |axis_info|
|
186
|
+
result << "- #{axis_info[:abbreviation]}[#{axis_info[:direction]}]: #{axis_info[:name]} (#{axis_info[:unit_name]})" << "\n"
|
187
|
+
end
|
188
|
+
|
189
|
+
result << <<~EOS
|
190
|
+
Area of Use:
|
191
|
+
- name: #{self.area.name}
|
192
|
+
- bounds: (#{self.area.west_lon_degree}, #{self.area.south_lat_degree}, #{self.area.east_lon_degree}, #{self.area.north_lat_degree})
|
193
|
+
Coordinate operation:
|
194
|
+
- name: ?
|
195
|
+
- method: ?
|
196
|
+
Datum: #{self.datum.name}
|
197
|
+
- Ellipsoid: #{self.ellipsoid.name}
|
198
|
+
- Prime Meridian: #{self.prime_meridian.name}
|
199
|
+
EOS
|
200
|
+
|
201
|
+
result.string
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -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
|