geodetic 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,9 +132,9 @@ module Geodetic
132
132
  LLA.new(lat: lat, lng: lng, alt: 0.0)
133
133
  end
134
134
 
135
- def self.from_lla(lla_coord, datum = WGS84)
136
- lat = lla_coord.lat
137
- lng = lla_coord.lng
135
+ def self.from_lla(lla, datum = WGS84)
136
+ lat = lla.lat
137
+ lng = lla.lng
138
138
 
139
139
  # Determine hemisphere and zone
140
140
  hemisphere = lat >= 0 ? 'N' : 'S'
@@ -183,8 +183,8 @@ module Geodetic
183
183
  to_lla(datum).to_ecef(datum)
184
184
  end
185
185
 
186
- def self.from_ecef(ecef_coord, datum = WGS84)
187
- lla_coord = ecef_coord.to_lla(datum)
186
+ def self.from_ecef(ecef, datum = WGS84)
187
+ lla_coord = ecef.to_lla(datum)
188
188
  from_lla(lla_coord, datum)
189
189
  end
190
190
 
@@ -192,8 +192,8 @@ module Geodetic
192
192
  to_lla(datum).to_utm(datum)
193
193
  end
194
194
 
195
- def self.from_utm(utm_coord, datum = WGS84)
196
- lla_coord = utm_coord.to_lla(datum)
195
+ def self.from_utm(utm, datum = WGS84)
196
+ lla_coord = utm.to_lla(datum)
197
197
  from_lla(lla_coord, datum)
198
198
  end
199
199
 
@@ -201,8 +201,8 @@ module Geodetic
201
201
  to_lla(datum).to_enu(reference_lla)
202
202
  end
203
203
 
204
- def self.from_enu(enu_coord, reference_lla, datum = WGS84)
205
- lla_coord = enu_coord.to_lla(reference_lla)
204
+ def self.from_enu(enu, reference_lla, datum = WGS84)
205
+ lla_coord = enu.to_lla(reference_lla)
206
206
  from_lla(lla_coord, datum)
207
207
  end
208
208
 
@@ -210,8 +210,8 @@ module Geodetic
210
210
  to_lla(datum).to_ned(reference_lla)
211
211
  end
212
212
 
213
- def self.from_ned(ned_coord, reference_lla, datum = WGS84)
214
- lla_coord = ned_coord.to_lla(reference_lla)
213
+ def self.from_ned(ned, reference_lla, datum = WGS84)
214
+ lla_coord = ned.to_lla(reference_lla)
215
215
  from_lla(lla_coord, datum)
216
216
  end
217
217
 
@@ -219,8 +219,8 @@ module Geodetic
219
219
  MGRS.from_lla(to_lla(datum), datum, precision)
220
220
  end
221
221
 
222
- def self.from_mgrs(mgrs_coord, datum = WGS84)
223
- lla_coord = mgrs_coord.to_lla(datum)
222
+ def self.from_mgrs(mgrs, datum = WGS84)
223
+ lla_coord = mgrs.to_lla(datum)
224
224
  from_lla(lla_coord, datum)
225
225
  end
226
226
 
@@ -228,8 +228,8 @@ module Geodetic
228
228
  WebMercator.from_lla(to_lla(datum), datum)
229
229
  end
230
230
 
231
- def self.from_web_mercator(web_mercator_coord, datum = WGS84)
232
- lla_coord = web_mercator_coord.to_lla(datum)
231
+ def self.from_web_mercator(web_mercator, datum = WGS84)
232
+ lla_coord = web_mercator.to_lla(datum)
233
233
  from_lla(lla_coord, datum)
234
234
  end
235
235
 
@@ -237,8 +237,8 @@ module Geodetic
237
237
  USNG.from_lla(to_lla(datum), datum, precision)
238
238
  end
239
239
 
240
- def self.from_usng(usng_coord, datum = WGS84)
241
- lla_coord = usng_coord.to_lla(datum)
240
+ def self.from_usng(usng, datum = WGS84)
241
+ lla_coord = usng.to_lla(datum)
242
242
  from_lla(lla_coord, datum)
243
243
  end
244
244
 
@@ -246,8 +246,8 @@ module Geodetic
246
246
  BNG.from_lla(to_lla(datum), datum)
247
247
  end
248
248
 
249
- def self.from_bng(bng_coord, datum = WGS84)
250
- lla_coord = bng_coord.to_lla(datum)
249
+ def self.from_bng(bng, datum = WGS84)
250
+ lla_coord = bng.to_lla(datum)
251
251
  from_lla(lla_coord, datum)
252
252
  end
253
253
 
@@ -255,8 +255,8 @@ module Geodetic
255
255
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
256
256
  end
257
257
 
258
- def self.from_state_plane(sp_coord, datum = WGS84)
259
- lla_coord = sp_coord.to_lla(datum)
258
+ def self.from_state_plane(state_plane, datum = WGS84)
259
+ lla_coord = state_plane.to_lla(datum)
260
260
  from_lla(lla_coord, datum)
261
261
  end
262
262
 
@@ -49,13 +49,13 @@ module Geodetic
49
49
  MGRS.new(mgrs_string: mgrs_string)
50
50
  end
51
51
 
52
- def self.from_mgrs(mgrs_coord)
52
+ def self.from_mgrs(mgrs)
53
53
  # Extract components from MGRS
54
- grid_zone = mgrs_coord.grid_zone_designator
55
- square_id = mgrs_coord.square_identifier
56
- easting = mgrs_coord.easting
57
- northing = mgrs_coord.northing
58
- precision = mgrs_coord.precision
54
+ grid_zone = mgrs.grid_zone_designator
55
+ square_id = mgrs.square_identifier
56
+ easting = mgrs.easting
57
+ northing = mgrs.northing
58
+ precision = mgrs.precision
59
59
 
60
60
  new(grid_zone: grid_zone, square_id: square_id, easting: easting, northing: northing, precision: precision)
61
61
  end
@@ -64,8 +64,8 @@ module Geodetic
64
64
  to_mgrs.to_utm
65
65
  end
66
66
 
67
- def self.from_utm(utm_coord, precision = 5)
68
- mgrs_coord = MGRS.from_utm(utm_coord, precision)
67
+ def self.from_utm(utm, precision = 5)
68
+ mgrs_coord = MGRS.from_utm(utm, precision)
69
69
  from_mgrs(mgrs_coord)
70
70
  end
71
71
 
@@ -73,8 +73,8 @@ module Geodetic
73
73
  to_mgrs.to_lla(datum)
74
74
  end
75
75
 
76
- def self.from_lla(lla_coord, datum = WGS84, precision = 5)
77
- mgrs_coord = MGRS.from_lla(lla_coord, datum, precision)
76
+ def self.from_lla(lla, datum = WGS84, precision = 5)
77
+ mgrs_coord = MGRS.from_lla(lla, datum, precision)
78
78
  from_mgrs(mgrs_coord)
79
79
  end
80
80
 
@@ -82,8 +82,8 @@ module Geodetic
82
82
  to_lla(datum).to_ecef(datum)
83
83
  end
84
84
 
85
- def self.from_ecef(ecef_coord, datum = WGS84, precision = 5)
86
- lla_coord = ecef_coord.to_lla(datum)
85
+ def self.from_ecef(ecef, datum = WGS84, precision = 5)
86
+ lla_coord = ecef.to_lla(datum)
87
87
  from_lla(lla_coord, datum, precision)
88
88
  end
89
89
 
@@ -91,8 +91,8 @@ module Geodetic
91
91
  to_lla(datum).to_enu(reference_lla)
92
92
  end
93
93
 
94
- def self.from_enu(enu_coord, reference_lla, datum = WGS84, precision = 5)
95
- lla_coord = enu_coord.to_lla(reference_lla)
94
+ def self.from_enu(enu, reference_lla, datum = WGS84, precision = 5)
95
+ lla_coord = enu.to_lla(reference_lla)
96
96
  from_lla(lla_coord, datum, precision)
97
97
  end
98
98
 
@@ -100,8 +100,8 @@ module Geodetic
100
100
  to_lla(datum).to_ned(reference_lla)
101
101
  end
102
102
 
103
- def self.from_ned(ned_coord, reference_lla, datum = WGS84, precision = 5)
104
- lla_coord = ned_coord.to_lla(reference_lla)
103
+ def self.from_ned(ned, reference_lla, datum = WGS84, precision = 5)
104
+ lla_coord = ned.to_lla(reference_lla)
105
105
  from_lla(lla_coord, datum, precision)
106
106
  end
107
107
 
@@ -109,8 +109,8 @@ module Geodetic
109
109
  UPS.from_lla(to_lla(datum), datum)
110
110
  end
111
111
 
112
- def self.from_ups(ups_coord, datum = WGS84, precision = 5)
113
- lla_coord = ups_coord.to_lla(datum)
112
+ def self.from_ups(ups, datum = WGS84, precision = 5)
113
+ lla_coord = ups.to_lla(datum)
114
114
  from_lla(lla_coord, datum, precision)
115
115
  end
116
116
 
@@ -118,8 +118,8 @@ module Geodetic
118
118
  WebMercator.from_lla(to_lla(datum), datum)
119
119
  end
120
120
 
121
- def self.from_web_mercator(web_mercator_coord, datum = WGS84, precision = 5)
122
- lla_coord = web_mercator_coord.to_lla(datum)
121
+ def self.from_web_mercator(web_mercator, datum = WGS84, precision = 5)
122
+ lla_coord = web_mercator.to_lla(datum)
123
123
  from_lla(lla_coord, datum, precision)
124
124
  end
125
125
 
@@ -127,16 +127,16 @@ module Geodetic
127
127
  BNG.from_lla(to_lla(datum), datum)
128
128
  end
129
129
 
130
- def self.from_bng(bng_coord, datum = WGS84, precision = 5)
131
- from_lla(bng_coord.to_lla(datum), datum, precision)
130
+ def self.from_bng(bng, datum = WGS84, precision = 5)
131
+ from_lla(bng.to_lla(datum), datum, precision)
132
132
  end
133
133
 
134
134
  def to_state_plane(zone_code, datum = WGS84)
135
135
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
136
136
  end
137
137
 
138
- def self.from_state_plane(sp_coord, datum = WGS84, precision = 5)
139
- from_lla(sp_coord.to_lla(datum), datum, precision)
138
+ def self.from_state_plane(state_plane, datum = WGS84, precision = 5)
139
+ from_lla(state_plane.to_lla(datum), datum, precision)
140
140
  end
141
141
 
142
142
  def ==(other)
@@ -196,7 +196,7 @@ module Geodetic
196
196
  adjacent_usng = USNG.new(grid_zone: @grid_zone_designator, square_id: @square_identifier,
197
197
  easting: new_east, northing: new_north, precision: @precision)
198
198
  squares[direction] = adjacent_usng
199
- rescue => e
199
+ rescue ArgumentError
200
200
  # Skip invalid adjacent squares (e.g., crossing zone boundaries)
201
201
  squares[direction] = nil
202
202
  end
@@ -152,48 +152,48 @@ module Geodetic
152
152
  MGRS.from_utm(self, precision)
153
153
  end
154
154
 
155
- def self.from_mgrs(mgrs_coord, datum = WGS84)
156
- mgrs_coord.to_utm
155
+ def self.from_mgrs(mgrs, datum = WGS84)
156
+ mgrs.to_utm
157
157
  end
158
158
 
159
159
  def to_usng(datum = WGS84, precision = 5)
160
160
  USNG.from_utm(self, precision)
161
161
  end
162
162
 
163
- def self.from_usng(usng_coord, datum = WGS84)
164
- usng_coord.to_utm
163
+ def self.from_usng(usng, datum = WGS84)
164
+ usng.to_utm
165
165
  end
166
166
 
167
167
  def to_web_mercator(datum = WGS84)
168
168
  WebMercator.from_lla(to_lla(datum), datum)
169
169
  end
170
170
 
171
- def self.from_web_mercator(wm_coord, datum = WGS84)
172
- from_lla(wm_coord.to_lla(datum), datum)
171
+ def self.from_web_mercator(web_mercator, datum = WGS84)
172
+ from_lla(web_mercator.to_lla(datum), datum)
173
173
  end
174
174
 
175
175
  def to_ups(datum = WGS84)
176
176
  UPS.from_lla(to_lla(datum), datum)
177
177
  end
178
178
 
179
- def self.from_ups(ups_coord, datum = WGS84)
180
- from_lla(ups_coord.to_lla(datum), datum)
179
+ def self.from_ups(ups, datum = WGS84)
180
+ from_lla(ups.to_lla(datum), datum)
181
181
  end
182
182
 
183
183
  def to_state_plane(zone_code, datum = WGS84)
184
184
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
185
185
  end
186
186
 
187
- def self.from_state_plane(sp_coord, datum = WGS84)
188
- from_lla(sp_coord.to_lla(datum), datum)
187
+ def self.from_state_plane(state_plane, datum = WGS84)
188
+ from_lla(state_plane.to_lla(datum), datum)
189
189
  end
190
190
 
191
191
  def to_bng(datum = WGS84)
192
192
  BNG.from_lla(to_lla(datum))
193
193
  end
194
194
 
195
- def self.from_bng(bng_coord, datum = WGS84)
196
- from_lla(bng_coord.to_lla, datum)
195
+ def self.from_bng(bng, datum = WGS84)
196
+ from_lla(bng.to_lla, datum)
197
197
  end
198
198
 
199
199
  def to_s(precision = 2)
@@ -62,9 +62,9 @@ module Geodetic
62
62
  LLA.new(lat: lat, lng: lng, alt: 0.0)
63
63
  end
64
64
 
65
- def self.from_lla(lla_coord, datum = WGS84)
66
- lat = lla_coord.lat
67
- lng = lla_coord.lng
65
+ def self.from_lla(lla, datum = WGS84)
66
+ lat = lla.lat
67
+ lng = lla.lng
68
68
 
69
69
  # Clamp latitude to Web Mercator limits
70
70
  lat = [[-MAX_LATITUDE, lat].max, MAX_LATITUDE].min
@@ -80,8 +80,8 @@ module Geodetic
80
80
  to_lla(datum).to_ecef(datum)
81
81
  end
82
82
 
83
- def self.from_ecef(ecef_coord, datum = WGS84)
84
- lla_coord = ecef_coord.to_lla(datum)
83
+ def self.from_ecef(ecef, datum = WGS84)
84
+ lla_coord = ecef.to_lla(datum)
85
85
  from_lla(lla_coord, datum)
86
86
  end
87
87
 
@@ -89,8 +89,8 @@ module Geodetic
89
89
  to_lla(datum).to_utm(datum)
90
90
  end
91
91
 
92
- def self.from_utm(utm_coord, datum = WGS84)
93
- lla_coord = utm_coord.to_lla(datum)
92
+ def self.from_utm(utm, datum = WGS84)
93
+ lla_coord = utm.to_lla(datum)
94
94
  from_lla(lla_coord, datum)
95
95
  end
96
96
 
@@ -98,8 +98,8 @@ module Geodetic
98
98
  to_lla(datum).to_enu(reference_lla)
99
99
  end
100
100
 
101
- def self.from_enu(enu_coord, reference_lla, datum = WGS84)
102
- lla_coord = enu_coord.to_lla(reference_lla)
101
+ def self.from_enu(enu, reference_lla, datum = WGS84)
102
+ lla_coord = enu.to_lla(reference_lla)
103
103
  from_lla(lla_coord, datum)
104
104
  end
105
105
 
@@ -107,8 +107,8 @@ module Geodetic
107
107
  to_lla(datum).to_ned(reference_lla)
108
108
  end
109
109
 
110
- def self.from_ned(ned_coord, reference_lla, datum = WGS84)
111
- lla_coord = ned_coord.to_lla(reference_lla)
110
+ def self.from_ned(ned, reference_lla, datum = WGS84)
111
+ lla_coord = ned.to_lla(reference_lla)
112
112
  from_lla(lla_coord, datum)
113
113
  end
114
114
 
@@ -116,8 +116,8 @@ module Geodetic
116
116
  MGRS.from_lla(to_lla(datum), datum, precision)
117
117
  end
118
118
 
119
- def self.from_mgrs(mgrs_coord, datum = WGS84)
120
- lla_coord = mgrs_coord.to_lla(datum)
119
+ def self.from_mgrs(mgrs, datum = WGS84)
120
+ lla_coord = mgrs.to_lla(datum)
121
121
  from_lla(lla_coord, datum)
122
122
  end
123
123
 
@@ -125,32 +125,32 @@ module Geodetic
125
125
  USNG.from_lla(to_lla(datum), datum, precision)
126
126
  end
127
127
 
128
- def self.from_usng(usng_coord, datum = WGS84)
129
- from_lla(usng_coord.to_lla(datum), datum)
128
+ def self.from_usng(usng, datum = WGS84)
129
+ from_lla(usng.to_lla(datum), datum)
130
130
  end
131
131
 
132
132
  def to_ups(datum = WGS84)
133
133
  UPS.from_lla(to_lla(datum), datum)
134
134
  end
135
135
 
136
- def self.from_ups(ups_coord, datum = WGS84)
137
- from_lla(ups_coord.to_lla(datum), datum)
136
+ def self.from_ups(ups, datum = WGS84)
137
+ from_lla(ups.to_lla(datum), datum)
138
138
  end
139
139
 
140
140
  def to_state_plane(zone_code, datum = WGS84)
141
141
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
142
142
  end
143
143
 
144
- def self.from_state_plane(sp_coord, datum = WGS84)
145
- from_lla(sp_coord.to_lla(datum), datum)
144
+ def self.from_state_plane(state_plane, datum = WGS84)
145
+ from_lla(state_plane.to_lla(datum), datum)
146
146
  end
147
147
 
148
148
  def to_bng(datum = WGS84)
149
149
  BNG.from_lla(to_lla(datum))
150
150
  end
151
151
 
152
- def self.from_bng(bng_coord, datum = WGS84)
153
- from_lla(bng_coord.to_lla, datum)
152
+ def self.from_bng(bng, datum = WGS84)
153
+ from_lla(bng.to_lla, datum)
154
154
  end
155
155
 
156
156
  # Tile coordinate methods for web mapping
@@ -11,7 +11,7 @@ module Geodetic
11
11
  attr_reader :registered_classes
12
12
 
13
13
  def systems
14
- @registered_classes.map(&:first).freeze
14
+ @systems_cache ||= @registered_classes.map(&:first).freeze
15
15
  end
16
16
 
17
17
  def register_class(klass, hash_conversion_style: nil)
@@ -19,8 +19,9 @@ module Geodetic
19
19
  end
20
20
 
21
21
  def finalize!
22
- raise "Geodetic::Coordinate already finalized!" if @finalized
22
+ return if @finalized
23
23
  @finalized = true
24
+ @systems_cache = nil
24
25
 
25
26
  # Phase 1: Generate cross-hash conversion methods between spatial hash subclasses
26
27
  SpatialHash.finalize_cross_hash_conversions!