proj4rb 2.2.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +82 -66
  3. data/Gemfile +4 -4
  4. data/README.rdoc +82 -45
  5. data/lib/api/api.rb +96 -111
  6. data/lib/api/api_5_0.rb +331 -300
  7. data/lib/api/api_5_1.rb +6 -6
  8. data/lib/api/api_5_2.rb +4 -4
  9. data/lib/api/api_6_0.rb +116 -14
  10. data/lib/api/api_6_1.rb +4 -4
  11. data/lib/api/api_6_2.rb +9 -6
  12. data/lib/api/api_6_3.rb +6 -0
  13. data/lib/api/api_7_0.rb +68 -0
  14. data/lib/api/api_7_1.rb +73 -0
  15. data/lib/api/api_7_2.rb +14 -0
  16. data/lib/api/api_8_0.rb +6 -0
  17. data/lib/api/api_8_1.rb +24 -0
  18. data/lib/api/api_8_2.rb +6 -0
  19. data/lib/api/api_9_1.rb +7 -0
  20. data/lib/api/api_9_2.rb +9 -0
  21. data/lib/api/api_experimental.rb +196 -0
  22. data/lib/proj/area.rb +73 -0
  23. data/lib/proj/axis_info.rb +44 -0
  24. data/lib/proj/bounds.rb +13 -0
  25. data/lib/proj/context.rb +249 -0
  26. data/lib/proj/conversion.rb +92 -0
  27. data/lib/{coordinate.rb → proj/coordinate.rb} +281 -197
  28. data/lib/proj/coordinate_operation_mixin.rb +381 -0
  29. data/lib/proj/coordinate_system.rb +137 -0
  30. data/lib/proj/crs.rb +672 -0
  31. data/lib/proj/crs_info.rb +47 -0
  32. data/lib/proj/database.rb +305 -0
  33. data/lib/proj/datum.rb +32 -0
  34. data/lib/proj/datum_ensemble.rb +34 -0
  35. data/lib/proj/ellipsoid.rb +78 -0
  36. data/lib/proj/error.rb +71 -0
  37. data/lib/proj/file_api.rb +166 -0
  38. data/lib/proj/grid.rb +121 -0
  39. data/lib/proj/grid_cache.rb +64 -0
  40. data/lib/proj/grid_info.rb +19 -0
  41. data/lib/proj/network_api.rb +92 -0
  42. data/lib/{operation.rb → proj/operation.rb} +42 -42
  43. data/lib/proj/operation_factory_context.rb +136 -0
  44. data/lib/proj/parameter.rb +38 -0
  45. data/lib/proj/parameters.rb +106 -0
  46. data/lib/proj/pj_object.rb +670 -0
  47. data/lib/proj/pj_objects.rb +44 -0
  48. data/lib/proj/prime_meridian.rb +66 -0
  49. data/lib/proj/projection.rb +698 -0
  50. data/lib/proj/session.rb +46 -0
  51. data/lib/proj/strings.rb +32 -0
  52. data/lib/proj/transformation.rb +102 -0
  53. data/lib/proj/unit.rb +109 -0
  54. data/lib/proj.rb +118 -17
  55. data/proj4rb.gemspec +32 -32
  56. data/test/abstract_test.rb +29 -7
  57. data/test/context_test.rb +172 -82
  58. data/test/conversion_test.rb +368 -0
  59. data/test/coordinate_system_test.rb +144 -0
  60. data/test/coordinate_test.rb +34 -34
  61. data/test/crs_test.rb +1071 -372
  62. data/test/database_test.rb +360 -0
  63. data/test/datum_ensemble_test.rb +65 -0
  64. data/test/datum_test.rb +55 -0
  65. data/test/ellipsoid_test.rb +80 -34
  66. data/test/file_api_test.rb +66 -0
  67. data/test/grid_cache_test.rb +72 -0
  68. data/test/grid_test.rb +141 -0
  69. data/test/network_api_test.rb +45 -0
  70. data/test/operation_factory_context_test.rb +201 -0
  71. data/test/operation_test.rb +29 -29
  72. data/test/parameters_test.rb +40 -0
  73. data/test/pj_object_test.rb +179 -0
  74. data/test/prime_meridian_test.rb +76 -0
  75. data/test/proj_test.rb +58 -16
  76. data/test/projection_test.rb +650 -224
  77. data/test/session_test.rb +78 -0
  78. data/test/transformation_test.rb +209 -67
  79. data/test/unit_test.rb +76 -47
  80. metadata +67 -29
  81. data/lib/api/api_4_9.rb +0 -31
  82. data/lib/area.rb +0 -32
  83. data/lib/config.rb +0 -70
  84. data/lib/context.rb +0 -103
  85. data/lib/crs.rb +0 -204
  86. data/lib/ellipsoid.rb +0 -42
  87. data/lib/error.rb +0 -18
  88. data/lib/pj_object.rb +0 -80
  89. data/lib/point.rb +0 -72
  90. data/lib/prime_meridian.rb +0 -40
  91. data/lib/projection.rb +0 -207
  92. data/lib/transformation.rb +0 -61
  93. data/lib/unit.rb +0 -54
  94. data/test/prime_meridians_test.rb +0 -33
data/lib/area.rb DELETED
@@ -1,32 +0,0 @@
1
- module Proj
2
- class Area
3
- attr_reader :name, :west_lon_degree, :south_lat_degree, :east_lon_degree, :north_lat_degree
4
-
5
- def self.for_object(pj_object)
6
- p_name = FFI::MemoryPointer.new(:pointer)
7
- p_west_lon_degree = FFI::MemoryPointer.new(:double)
8
- p_south_lat_degree = FFI::MemoryPointer.new(:double)
9
- p_east_lon_degree = FFI::MemoryPointer.new(:double)
10
- p_north_lat_degree = FFI::MemoryPointer.new(:double)
11
-
12
- result = Api.proj_get_area_of_use(Context.current, pj_object,
13
- p_west_lon_degree, p_south_lat_degree, p_east_lon_degree, p_north_lat_degree,
14
- p_name)
15
- unless result
16
- Error.check
17
- end
18
-
19
- name = p_name.read_pointer.read_string_to_null.force_encoding('utf-8')
20
- self.new(name,
21
- p_west_lon_degree.read_double, p_south_lat_degree.read_double, p_east_lon_degree.read_double, p_north_lat_degree.read_double)
22
- end
23
-
24
- def initialize(name, west_lon_degree, south_lat_degree, east_lon_degree, north_lat_degree)
25
- @name = name
26
- @west_lon_degree = west_lon_degree
27
- @south_lat_degree = south_lat_degree
28
- @east_lon_degree = east_lon_degree
29
- @north_lat_degree = north_lat_degree
30
- end
31
- end
32
- end
data/lib/config.rb DELETED
@@ -1,70 +0,0 @@
1
- require 'singleton'
2
-
3
- module Proj
4
- class Config
5
- include Singleton
6
-
7
- def set_search_paths
8
- p_paths = self.search_paths_pointer
9
- items = p_paths.type_size/p_paths.size
10
-
11
- # Set search paths on default context - any new contexts will inherit from this
12
- if Api.method_defined?(:proj_context_set_search_paths)
13
- Api.proj_context_set_search_paths(nil, items, p_paths)
14
- end
15
-
16
- if Api.method_defined?(:pj_set_searchpath)
17
- Api.pj_set_searchpath(items, p_paths)
18
- end
19
- end
20
-
21
- def search_paths
22
- ['/usr/share/proj',
23
- '/usr/local/share/proj',
24
- '/opt/share/proj',
25
- '/opt/local/share/proj',
26
- 'c:/msys64/mingw64/share/proj',
27
- 'c:/mingw64/share/proj',
28
- '/opt/local/lib/proj6/share/proj',
29
- '/opt/local/lib/proj5/share/proj',
30
- '/opt/local/lib/proj49/share/proj']
31
- end
32
-
33
- def data_path
34
- if ENV['PROJ_LIB'] && File.directory?(ENV['PROJ_LIB'])
35
- ENV['PROJ_LIB']
36
- else
37
- result = self.search_paths.detect do |path|
38
- File.directory?(path)
39
- end
40
-
41
- unless result
42
- raise(Error, "Could not find Proj data directory. Please set the PROJ_LIB environmental variable to correct directory")
43
- end
44
-
45
- result
46
- end
47
- end
48
-
49
- def search_paths_pointer
50
- p_path = FFI::MemoryPointer.from_string(self.data_path)
51
- p_paths = FFI::MemoryPointer.new(:pointer, 1)
52
- p_paths[0].write_pointer(p_path)
53
- p_paths
54
- end
55
-
56
- def db_path
57
- result = self.search_paths.map do |path|
58
- File.join(path, 'proj.db')
59
- end.detect do |path|
60
- File.exists?(path)
61
- end
62
-
63
- unless result
64
- raise(Error, "Could not find Proj database (proj.db). Please set the PROJ_LIB environmental variable to directory that contains it")
65
- end
66
-
67
- result
68
- end
69
- end
70
- end
data/lib/context.rb DELETED
@@ -1,103 +0,0 @@
1
- module Proj
2
- # Proj 4.8 introduced the concept of a thread context object to support multi-threaded programs. The bindings
3
- # automatically create on context per thread (its stored in local thread storage).
4
- class Context
5
- # The context for the current thread
6
- #
7
- # @return [Context]
8
- def self.current
9
- Thread.current[:proj_context] ||= Context.new
10
- end
11
-
12
- def self.finalize(pointer)
13
- proc do
14
- Api.proj_context_destroy(pointer)
15
- end
16
- end
17
-
18
- def initialize
19
- @pointer = Api.proj_context_create
20
- ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
21
-
22
- set_database_path
23
- end
24
-
25
- # Helper method that tries to locate the Proj coordinate database (proj.db)
26
- def set_database_path
27
- return unless Api.method_defined?(:proj_context_get_database_path)
28
- return if database_path
29
-
30
- self.database_path = Config.instance.db_path
31
- end
32
-
33
- def to_ptr
34
- @pointer
35
- end
36
-
37
- # Get the last error number
38
- #
39
- # return [Integer]
40
- def errno
41
- Api.proj_context_errno(self)
42
- end
43
-
44
- # Gets the path the Proj database
45
- #
46
- # return [String]
47
- def database_path
48
- Api.proj_context_get_database_path(self)
49
- end
50
-
51
- # Sets the path to the Proj database
52
- def database_path=(value)
53
- result = Api.proj_context_set_database_path(self, value, nil, nil)
54
- unless result == 1
55
- Error.check(self.errno)
56
- end
57
- end
58
-
59
- # Sets a custom log function
60
- #
61
- # @example
62
- # context.set_log_function(data) do |pointer, int, message|
63
- # ... do stuff...
64
- # end
65
- #
66
- # @param pointer [FFI::MemoryPointer] Optional pointer to custom data
67
- # @param proc [Proc] Custom logging procedure
68
- # @return [nil]
69
- def set_log_function(pointer = nil, &proc)
70
- Api.proj_log_func(self, pointer, proc)
71
- end
72
-
73
- # Gets the current log level
74
- #
75
- # @return [:PJ_LOG_LEVEL]
76
- def log_level
77
- Api.proj_log_level(self, :PJ_LOG_TELL)
78
- end
79
-
80
- # Sets the current log level
81
- #
82
- # @param value [:PJ_LOG_LEVEL]
83
- # @return [nil]
84
- def log_level=(value)
85
- Api.proj_log_level(self, value)
86
- end
87
-
88
- # Gets if proj4 init rules are being used (i.e., support +init parameters)
89
- #
90
- # @return [Boolean]
91
- def use_proj4_init_rules
92
- Api.proj_context_get_use_proj4_init_rules(self, 0)
93
- end
94
-
95
- # Sets if proj4 init rules should be used
96
- #
97
- # @param value [Boolean]
98
- # @return [nil]
99
- def use_proj4_init_rules=(value)
100
- Api.proj_context_use_proj4_init_rules(self, value ? 1 : 0)
101
- end
102
- end
103
- end
data/lib/crs.rb DELETED
@@ -1,204 +0,0 @@
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
data/lib/ellipsoid.rb DELETED
@@ -1,42 +0,0 @@
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
- end
data/lib/error.rb DELETED
@@ -1,18 +0,0 @@
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
- end
data/lib/pj_object.rb DELETED
@@ -1,80 +0,0 @@
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
data/lib/point.rb DELETED
@@ -1,72 +0,0 @@
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 +0,0 @@
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
- end