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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +62 -3
- data/README.md +95 -48
- data/docs/coordinate-systems/index.md +18 -18
- data/docs/index.md +49 -27
- data/docs/reference/arithmetic.md +1 -1
- data/docs/reference/conversions.md +3 -3
- data/docs/reference/feature.md +1 -1
- data/docs/reference/geojson.md +388 -0
- data/examples/09_geojson_export.rb +255 -0
- data/examples/README.md +14 -0
- data/examples/geodetic_demo.geojson +305 -0
- data/lib/geodetic/areas/regular_polygon.rb +1 -21
- data/lib/geodetic/coordinate/bng.rb +26 -26
- data/lib/geodetic/coordinate/ecef.rb +12 -12
- data/lib/geodetic/coordinate/enu.rb +26 -26
- data/lib/geodetic/coordinate/lla.rb +16 -16
- data/lib/geodetic/coordinate/mgrs.rb +26 -26
- data/lib/geodetic/coordinate/ned.rb +26 -26
- data/lib/geodetic/coordinate/spatial_hash.rb +22 -22
- data/lib/geodetic/coordinate/state_plane.rb +42 -42
- data/lib/geodetic/coordinate/ups.rb +21 -21
- data/lib/geodetic/coordinate/usng.rb +25 -25
- data/lib/geodetic/coordinate/utm.rb +12 -12
- data/lib/geodetic/coordinate/web_mercator.rb +21 -21
- data/lib/geodetic/coordinate.rb +3 -2
- data/lib/geodetic/geojson.rb +303 -0
- data/lib/geodetic/path.rb +12 -15
- data/lib/geodetic/segment.rb +2 -18
- data/lib/geodetic/version.rb +1 -1
- data/lib/geodetic.rb +5 -4
- data/mkdocs.yml +10 -0
- metadata +5 -1
|
@@ -226,60 +226,60 @@ module Geodetic
|
|
|
226
226
|
GH36.new(self, precision: precision)
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
-
def self.from_gh36(
|
|
230
|
-
|
|
229
|
+
def self.from_gh36(gh36, datum = WGS84)
|
|
230
|
+
gh36.to_lla(datum)
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
def to_gh(precision: 12)
|
|
234
234
|
GH.new(self, precision: precision)
|
|
235
235
|
end
|
|
236
236
|
|
|
237
|
-
def self.from_gh(
|
|
238
|
-
|
|
237
|
+
def self.from_gh(gh, datum = WGS84)
|
|
238
|
+
gh.to_lla(datum)
|
|
239
239
|
end
|
|
240
240
|
|
|
241
241
|
def to_ham(precision: 6)
|
|
242
242
|
HAM.new(self, precision: precision)
|
|
243
243
|
end
|
|
244
244
|
|
|
245
|
-
def self.from_ham(
|
|
246
|
-
|
|
245
|
+
def self.from_ham(ham, datum = WGS84)
|
|
246
|
+
ham.to_lla(datum)
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
def to_olc(precision: 10)
|
|
250
250
|
OLC.new(self, precision: precision)
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
-
def self.from_olc(
|
|
254
|
-
|
|
253
|
+
def self.from_olc(olc, datum = WGS84)
|
|
254
|
+
olc.to_lla(datum)
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
def to_georef(precision: 8)
|
|
258
258
|
GEOREF.new(self, precision: precision)
|
|
259
259
|
end
|
|
260
260
|
|
|
261
|
-
def self.from_georef(
|
|
262
|
-
|
|
261
|
+
def self.from_georef(georef, datum = WGS84)
|
|
262
|
+
georef.to_lla(datum)
|
|
263
263
|
end
|
|
264
264
|
|
|
265
265
|
def to_gars(precision: 7)
|
|
266
266
|
GARS.new(self, precision: precision)
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
-
def self.from_gars(
|
|
270
|
-
|
|
269
|
+
def self.from_gars(gars, datum = WGS84)
|
|
270
|
+
gars.to_lla(datum)
|
|
271
271
|
end
|
|
272
272
|
|
|
273
273
|
def to_h3(precision: 7)
|
|
274
274
|
H3.new(self, precision: precision)
|
|
275
275
|
end
|
|
276
276
|
|
|
277
|
-
def self.from_h3(
|
|
278
|
-
|
|
277
|
+
def self.from_h3(h3, datum = WGS84)
|
|
278
|
+
h3.to_lla(datum)
|
|
279
279
|
end
|
|
280
280
|
|
|
281
|
-
def self.from_lla(
|
|
282
|
-
|
|
281
|
+
def self.from_lla(lla, datum = WGS84)
|
|
282
|
+
lla
|
|
283
283
|
end
|
|
284
284
|
|
|
285
285
|
def to_s(precision = 6)
|
|
@@ -55,24 +55,24 @@ module Geodetic
|
|
|
55
55
|
UTM.new(easting: utm_easting, northing: utm_northing, zone: zone_number, hemisphere: hemisphere)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def self.from_utm(
|
|
58
|
+
def self.from_utm(utm, precision = 5)
|
|
59
59
|
# Create instance to access instance methods
|
|
60
60
|
temp_instance = new()
|
|
61
61
|
|
|
62
62
|
# Get 100km square identifier
|
|
63
|
-
square_id = temp_instance.utm_to_square(
|
|
63
|
+
square_id = temp_instance.utm_to_square(utm.zone, utm.easting, utm.northing)
|
|
64
64
|
|
|
65
65
|
# Calculate position within the 100km square
|
|
66
|
-
square_easting =
|
|
67
|
-
square_northing =
|
|
66
|
+
square_easting = utm.easting % 100000
|
|
67
|
+
square_northing = utm.northing % 100000
|
|
68
68
|
|
|
69
69
|
# Create grid zone designator using hemisphere-aware band letter
|
|
70
|
-
if
|
|
71
|
-
zone_letter = get_zone_letter(
|
|
70
|
+
if utm.hemisphere == 'N'
|
|
71
|
+
zone_letter = get_zone_letter(utm.northing)
|
|
72
72
|
else
|
|
73
|
-
zone_letter = get_zone_letter_south(
|
|
73
|
+
zone_letter = get_zone_letter_south(utm.northing)
|
|
74
74
|
end
|
|
75
|
-
grid_zone = "#{
|
|
75
|
+
grid_zone = "#{utm.zone}#{zone_letter}"
|
|
76
76
|
|
|
77
77
|
new(grid_zone: grid_zone, square_id: square_id, easting: square_easting, northing: square_northing, precision: precision)
|
|
78
78
|
end
|
|
@@ -82,8 +82,8 @@ module Geodetic
|
|
|
82
82
|
utm_coord.to_lla(datum)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def self.from_lla(
|
|
86
|
-
utm_coord = UTM.from_lla(
|
|
85
|
+
def self.from_lla(lla, datum = WGS84, precision = 5)
|
|
86
|
+
utm_coord = UTM.from_lla(lla, datum)
|
|
87
87
|
from_utm(utm_coord, precision)
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -91,8 +91,8 @@ module Geodetic
|
|
|
91
91
|
to_lla(datum).to_ecef(datum)
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
def self.from_ecef(
|
|
95
|
-
lla_coord =
|
|
94
|
+
def self.from_ecef(ecef, datum = WGS84, precision = 5)
|
|
95
|
+
lla_coord = ecef.to_lla(datum)
|
|
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_enu(reference_lla)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
def self.from_enu(
|
|
104
|
-
lla_coord =
|
|
103
|
+
def self.from_enu(enu, reference_lla, datum = WGS84, precision = 5)
|
|
104
|
+
lla_coord = enu.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
|
to_lla(datum).to_ned(reference_lla)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
def self.from_ned(
|
|
113
|
-
lla_coord =
|
|
112
|
+
def self.from_ned(ned, reference_lla, datum = WGS84, precision = 5)
|
|
113
|
+
lla_coord = ned.to_lla(reference_lla)
|
|
114
114
|
from_lla(lla_coord, datum, precision)
|
|
115
115
|
end
|
|
116
116
|
|
|
@@ -118,40 +118,40 @@ module Geodetic
|
|
|
118
118
|
WebMercator.from_lla(to_lla(datum), datum)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
def self.from_web_mercator(
|
|
122
|
-
from_lla(
|
|
121
|
+
def self.from_web_mercator(web_mercator, datum = WGS84, precision = 5)
|
|
122
|
+
from_lla(web_mercator.to_lla(datum), datum, precision)
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def to_ups(datum = WGS84)
|
|
126
126
|
UPS.from_lla(to_lla(datum), datum)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
def self.from_ups(
|
|
130
|
-
from_lla(
|
|
129
|
+
def self.from_ups(ups, datum = WGS84, precision = 5)
|
|
130
|
+
from_lla(ups.to_lla(datum), datum, precision)
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def to_usng
|
|
134
134
|
USNG.from_mgrs(self)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
def self.from_usng(
|
|
138
|
-
|
|
137
|
+
def self.from_usng(usng)
|
|
138
|
+
usng.to_mgrs
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def to_state_plane(zone_code, datum = WGS84)
|
|
142
142
|
StatePlane.from_lla(to_lla(datum), zone_code, datum)
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
def self.from_state_plane(
|
|
146
|
-
from_lla(
|
|
145
|
+
def self.from_state_plane(state_plane, datum = WGS84, precision = 5)
|
|
146
|
+
from_lla(state_plane.to_lla(datum), datum, precision)
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
def to_bng(datum = WGS84)
|
|
150
150
|
BNG.from_lla(to_lla(datum), datum)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
def self.from_bng(
|
|
154
|
-
from_lla(
|
|
153
|
+
def self.from_bng(bng, datum = WGS84, precision = 5)
|
|
154
|
+
from_lla(bng.to_lla(datum), datum, precision)
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
def ==(other)
|
|
@@ -89,8 +89,8 @@ module Geodetic
|
|
|
89
89
|
MGRS.from_lla(to_lla(reference_lla), datum, precision)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def self.from_mgrs(
|
|
93
|
-
lla =
|
|
92
|
+
def self.from_mgrs(mgrs, reference_lla, datum = WGS84)
|
|
93
|
+
lla = mgrs.to_lla(datum)
|
|
94
94
|
from_lla(lla, reference_lla)
|
|
95
95
|
end
|
|
96
96
|
|
|
@@ -98,8 +98,8 @@ module Geodetic
|
|
|
98
98
|
USNG.from_lla(to_lla(reference_lla), datum, precision)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
def self.from_usng(
|
|
102
|
-
lla =
|
|
101
|
+
def self.from_usng(usng, reference_lla, datum = WGS84)
|
|
102
|
+
lla = usng.to_lla(datum)
|
|
103
103
|
from_lla(lla, reference_lla)
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -107,8 +107,8 @@ module Geodetic
|
|
|
107
107
|
WebMercator.from_lla(to_lla(reference_lla), datum)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def self.from_web_mercator(
|
|
111
|
-
lla =
|
|
110
|
+
def self.from_web_mercator(web_mercator, reference_lla, datum = WGS84)
|
|
111
|
+
lla = web_mercator.to_lla(datum)
|
|
112
112
|
from_lla(lla, reference_lla)
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -116,8 +116,8 @@ module Geodetic
|
|
|
116
116
|
UPS.from_lla(to_lla(reference_lla), datum)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
def self.from_ups(
|
|
120
|
-
lla =
|
|
119
|
+
def self.from_ups(ups, reference_lla, datum = WGS84)
|
|
120
|
+
lla = ups.to_lla(datum)
|
|
121
121
|
from_lla(lla, reference_lla)
|
|
122
122
|
end
|
|
123
123
|
|
|
@@ -125,8 +125,8 @@ module Geodetic
|
|
|
125
125
|
StatePlane.from_lla(to_lla(reference_lla), zone_code, datum)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def self.from_state_plane(
|
|
129
|
-
lla =
|
|
128
|
+
def self.from_state_plane(state_plane, reference_lla, datum = WGS84)
|
|
129
|
+
lla = state_plane.to_lla(datum)
|
|
130
130
|
from_lla(lla, reference_lla)
|
|
131
131
|
end
|
|
132
132
|
|
|
@@ -134,8 +134,8 @@ module Geodetic
|
|
|
134
134
|
BNG.from_lla(to_lla(reference_lla))
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
def self.from_bng(
|
|
138
|
-
lla =
|
|
137
|
+
def self.from_bng(bng, reference_lla)
|
|
138
|
+
lla = bng.to_lla
|
|
139
139
|
from_lla(lla, reference_lla)
|
|
140
140
|
end
|
|
141
141
|
|
|
@@ -143,8 +143,8 @@ module Geodetic
|
|
|
143
143
|
GH36.new(to_lla(reference_lla), precision: precision)
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
def self.from_gh36(
|
|
147
|
-
lla =
|
|
146
|
+
def self.from_gh36(gh36, reference_lla)
|
|
147
|
+
lla = gh36.to_lla
|
|
148
148
|
from_lla(lla, reference_lla)
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -152,8 +152,8 @@ module Geodetic
|
|
|
152
152
|
GH.new(to_lla(reference_lla), precision: precision)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
def self.from_gh(
|
|
156
|
-
lla =
|
|
155
|
+
def self.from_gh(gh, reference_lla)
|
|
156
|
+
lla = gh.to_lla
|
|
157
157
|
from_lla(lla, reference_lla)
|
|
158
158
|
end
|
|
159
159
|
|
|
@@ -161,8 +161,8 @@ module Geodetic
|
|
|
161
161
|
HAM.new(to_lla(reference_lla), precision: precision)
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
def self.from_ham(
|
|
165
|
-
lla =
|
|
164
|
+
def self.from_ham(ham, reference_lla)
|
|
165
|
+
lla = ham.to_lla
|
|
166
166
|
from_lla(lla, reference_lla)
|
|
167
167
|
end
|
|
168
168
|
|
|
@@ -170,8 +170,8 @@ module Geodetic
|
|
|
170
170
|
OLC.new(to_lla(reference_lla), precision: precision)
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
-
def self.from_olc(
|
|
174
|
-
lla =
|
|
173
|
+
def self.from_olc(olc, reference_lla)
|
|
174
|
+
lla = olc.to_lla
|
|
175
175
|
from_lla(lla, reference_lla)
|
|
176
176
|
end
|
|
177
177
|
|
|
@@ -179,8 +179,8 @@ module Geodetic
|
|
|
179
179
|
GEOREF.new(to_lla(reference_lla), precision: precision)
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
def self.from_georef(
|
|
183
|
-
lla =
|
|
182
|
+
def self.from_georef(georef, reference_lla)
|
|
183
|
+
lla = georef.to_lla
|
|
184
184
|
from_lla(lla, reference_lla)
|
|
185
185
|
end
|
|
186
186
|
|
|
@@ -188,8 +188,8 @@ module Geodetic
|
|
|
188
188
|
GARS.new(to_lla(reference_lla), precision: precision)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
|
-
def self.from_gars(
|
|
192
|
-
lla =
|
|
191
|
+
def self.from_gars(gars, reference_lla)
|
|
192
|
+
lla = gars.to_lla
|
|
193
193
|
from_lla(lla, reference_lla)
|
|
194
194
|
end
|
|
195
195
|
|
|
@@ -197,8 +197,8 @@ module Geodetic
|
|
|
197
197
|
H3.new(to_lla(reference_lla), precision: precision)
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
def self.from_h3(
|
|
201
|
-
lla =
|
|
200
|
+
def self.from_h3(h3, reference_lla)
|
|
201
|
+
lla = h3.to_lla
|
|
202
202
|
from_lla(lla, reference_lla)
|
|
203
203
|
end
|
|
204
204
|
|
|
@@ -191,8 +191,8 @@ module Geodetic
|
|
|
191
191
|
LLA.new(lat: lat, lng: lng, alt: 0.0)
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
-
def self.from_lla(
|
|
195
|
-
new(
|
|
194
|
+
def self.from_lla(lla, datum = WGS84, precision = default_precision)
|
|
195
|
+
new(lla, precision: precision)
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
# --- Standard conversions (all chain through LLA) ---
|
|
@@ -201,24 +201,24 @@ module Geodetic
|
|
|
201
201
|
to_lla(datum).to_ecef(datum)
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
def self.from_ecef(
|
|
205
|
-
new(
|
|
204
|
+
def self.from_ecef(ecef, datum = WGS84, precision = default_precision)
|
|
205
|
+
new(ecef, precision: precision)
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
def to_utm(datum = WGS84)
|
|
209
209
|
to_lla(datum).to_utm(datum)
|
|
210
210
|
end
|
|
211
211
|
|
|
212
|
-
def self.from_utm(
|
|
213
|
-
new(
|
|
212
|
+
def self.from_utm(utm, datum = WGS84, precision = default_precision)
|
|
213
|
+
new(utm, precision: precision)
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
def to_enu(reference_lla, datum = WGS84)
|
|
217
217
|
to_lla(datum).to_enu(reference_lla)
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
def self.from_enu(
|
|
221
|
-
lla_coord =
|
|
220
|
+
def self.from_enu(enu, reference_lla, datum = WGS84, precision = default_precision)
|
|
221
|
+
lla_coord = enu.to_lla(reference_lla)
|
|
222
222
|
new(lla_coord, precision: precision)
|
|
223
223
|
end
|
|
224
224
|
|
|
@@ -226,8 +226,8 @@ module Geodetic
|
|
|
226
226
|
to_lla(datum).to_ned(reference_lla)
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
-
def self.from_ned(
|
|
230
|
-
lla_coord =
|
|
229
|
+
def self.from_ned(ned, reference_lla, datum = WGS84, precision = default_precision)
|
|
230
|
+
lla_coord = ned.to_lla(reference_lla)
|
|
231
231
|
new(lla_coord, precision: precision)
|
|
232
232
|
end
|
|
233
233
|
|
|
@@ -235,48 +235,48 @@ module Geodetic
|
|
|
235
235
|
MGRS.from_lla(to_lla(datum), datum, mgrs_precision)
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
def self.from_mgrs(
|
|
239
|
-
new(
|
|
238
|
+
def self.from_mgrs(mgrs, datum = WGS84, precision = default_precision)
|
|
239
|
+
new(mgrs, precision: precision)
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
def to_usng(datum = WGS84, usng_precision = 5)
|
|
243
243
|
USNG.from_lla(to_lla(datum), datum, usng_precision)
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
def self.from_usng(
|
|
247
|
-
new(
|
|
246
|
+
def self.from_usng(usng, datum = WGS84, precision = default_precision)
|
|
247
|
+
new(usng, precision: precision)
|
|
248
248
|
end
|
|
249
249
|
|
|
250
250
|
def to_web_mercator(datum = WGS84)
|
|
251
251
|
WebMercator.from_lla(to_lla(datum), datum)
|
|
252
252
|
end
|
|
253
253
|
|
|
254
|
-
def self.from_web_mercator(
|
|
255
|
-
new(
|
|
254
|
+
def self.from_web_mercator(web_mercator, datum = WGS84, precision = default_precision)
|
|
255
|
+
new(web_mercator, precision: precision)
|
|
256
256
|
end
|
|
257
257
|
|
|
258
258
|
def to_ups(datum = WGS84)
|
|
259
259
|
UPS.from_lla(to_lla(datum), datum)
|
|
260
260
|
end
|
|
261
261
|
|
|
262
|
-
def self.from_ups(
|
|
263
|
-
new(
|
|
262
|
+
def self.from_ups(ups, datum = WGS84, precision = default_precision)
|
|
263
|
+
new(ups, precision: precision)
|
|
264
264
|
end
|
|
265
265
|
|
|
266
266
|
def to_state_plane(zone_code, datum = WGS84)
|
|
267
267
|
StatePlane.from_lla(to_lla(datum), zone_code, datum)
|
|
268
268
|
end
|
|
269
269
|
|
|
270
|
-
def self.from_state_plane(
|
|
271
|
-
new(
|
|
270
|
+
def self.from_state_plane(state_plane, datum = WGS84, precision = default_precision)
|
|
271
|
+
new(state_plane, precision: precision)
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
def to_bng(datum = WGS84)
|
|
275
275
|
BNG.from_lla(to_lla(datum), datum)
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
-
def self.from_bng(
|
|
279
|
-
new(
|
|
278
|
+
def self.from_bng(bng, datum = WGS84, precision = default_precision)
|
|
279
|
+
new(bng, precision: precision)
|
|
280
280
|
end
|
|
281
281
|
|
|
282
282
|
# --- Equality and utility ---
|
|
@@ -156,15 +156,15 @@ module Geodetic
|
|
|
156
156
|
end
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
def self.from_lla(
|
|
159
|
+
def self.from_lla(lla, zone_code, datum = WGS84)
|
|
160
160
|
zone_info = ZONES[zone_code.to_s.upcase]
|
|
161
161
|
raise ArgumentError, "Unknown zone: #{zone_code}" unless zone_info
|
|
162
162
|
|
|
163
163
|
case zone_info[:projection]
|
|
164
164
|
when 'lambert_conformal_conic'
|
|
165
|
-
from_lla_lambert_conformal_conic(
|
|
165
|
+
from_lla_lambert_conformal_conic(lla, zone_code, zone_info, datum)
|
|
166
166
|
when 'transverse_mercator'
|
|
167
|
-
from_lla_transverse_mercator(
|
|
167
|
+
from_lla_transverse_mercator(lla, zone_code, zone_info, datum)
|
|
168
168
|
else
|
|
169
169
|
raise ArgumentError, "Unsupported projection: #{zone_info[:projection]}"
|
|
170
170
|
end
|
|
@@ -174,8 +174,8 @@ module Geodetic
|
|
|
174
174
|
to_lla(datum).to_ecef(datum || @datum)
|
|
175
175
|
end
|
|
176
176
|
|
|
177
|
-
def self.from_ecef(
|
|
178
|
-
lla_coord =
|
|
177
|
+
def self.from_ecef(ecef, zone_code, datum = WGS84)
|
|
178
|
+
lla_coord = ecef.to_lla(datum)
|
|
179
179
|
from_lla(lla_coord, zone_code, datum)
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -183,8 +183,8 @@ module Geodetic
|
|
|
183
183
|
to_lla(datum).to_utm(datum || @datum)
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
-
def self.from_utm(
|
|
187
|
-
lla_coord =
|
|
186
|
+
def self.from_utm(utm, zone_code, datum = WGS84)
|
|
187
|
+
lla_coord = utm.to_lla(datum)
|
|
188
188
|
from_lla(lla_coord, zone_code, datum)
|
|
189
189
|
end
|
|
190
190
|
|
|
@@ -192,8 +192,8 @@ module Geodetic
|
|
|
192
192
|
to_lla(datum).to_enu(reference_lla)
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
-
def self.from_enu(
|
|
196
|
-
lla_coord =
|
|
195
|
+
def self.from_enu(enu, reference_lla, zone_code, datum = WGS84)
|
|
196
|
+
lla_coord = enu.to_lla(reference_lla)
|
|
197
197
|
from_lla(lla_coord, zone_code, datum)
|
|
198
198
|
end
|
|
199
199
|
|
|
@@ -201,8 +201,8 @@ module Geodetic
|
|
|
201
201
|
to_lla(datum).to_ned(reference_lla)
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
def self.from_ned(
|
|
205
|
-
lla_coord =
|
|
204
|
+
def self.from_ned(ned, reference_lla, zone_code, datum = WGS84)
|
|
205
|
+
lla_coord = ned.to_lla(reference_lla)
|
|
206
206
|
from_lla(lla_coord, zone_code, datum)
|
|
207
207
|
end
|
|
208
208
|
|
|
@@ -210,8 +210,8 @@ module Geodetic
|
|
|
210
210
|
MGRS.from_lla(to_lla(datum), datum || @datum, precision)
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
-
def self.from_mgrs(
|
|
214
|
-
lla_coord =
|
|
213
|
+
def self.from_mgrs(mgrs, zone_code, datum = WGS84)
|
|
214
|
+
lla_coord = mgrs.to_lla(datum)
|
|
215
215
|
from_lla(lla_coord, zone_code, datum)
|
|
216
216
|
end
|
|
217
217
|
|
|
@@ -219,8 +219,8 @@ module Geodetic
|
|
|
219
219
|
USNG.from_lla(to_lla(datum), datum || @datum, precision)
|
|
220
220
|
end
|
|
221
221
|
|
|
222
|
-
def self.from_usng(
|
|
223
|
-
lla_coord =
|
|
222
|
+
def self.from_usng(usng, zone_code, datum = WGS84)
|
|
223
|
+
lla_coord = usng.to_lla(datum)
|
|
224
224
|
from_lla(lla_coord, zone_code, datum)
|
|
225
225
|
end
|
|
226
226
|
|
|
@@ -228,8 +228,8 @@ module Geodetic
|
|
|
228
228
|
WebMercator.from_lla(to_lla(datum), datum || @datum)
|
|
229
229
|
end
|
|
230
230
|
|
|
231
|
-
def self.from_web_mercator(
|
|
232
|
-
lla_coord =
|
|
231
|
+
def self.from_web_mercator(web_mercator, zone_code, datum = WGS84)
|
|
232
|
+
lla_coord = web_mercator.to_lla(datum)
|
|
233
233
|
from_lla(lla_coord, zone_code, datum)
|
|
234
234
|
end
|
|
235
235
|
|
|
@@ -237,8 +237,8 @@ module Geodetic
|
|
|
237
237
|
UPS.from_lla(to_lla(datum), datum || @datum)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
-
def self.from_ups(
|
|
241
|
-
lla_coord =
|
|
240
|
+
def self.from_ups(ups, zone_code, datum = WGS84)
|
|
241
|
+
lla_coord = ups.to_lla(datum)
|
|
242
242
|
from_lla(lla_coord, zone_code, datum)
|
|
243
243
|
end
|
|
244
244
|
|
|
@@ -246,8 +246,8 @@ module Geodetic
|
|
|
246
246
|
BNG.from_lla(to_lla(datum), datum || @datum)
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
-
def self.from_bng(
|
|
250
|
-
lla_coord =
|
|
249
|
+
def self.from_bng(bng, zone_code, datum = WGS84)
|
|
250
|
+
lla_coord = bng.to_lla(datum)
|
|
251
251
|
from_lla(lla_coord, zone_code, datum)
|
|
252
252
|
end
|
|
253
253
|
|
|
@@ -255,8 +255,8 @@ module Geodetic
|
|
|
255
255
|
GH36.new(to_lla(datum), precision: precision)
|
|
256
256
|
end
|
|
257
257
|
|
|
258
|
-
def self.from_gh36(
|
|
259
|
-
lla_coord =
|
|
258
|
+
def self.from_gh36(gh36, zone_code, datum = WGS84)
|
|
259
|
+
lla_coord = gh36.to_lla(datum)
|
|
260
260
|
from_lla(lla_coord, zone_code, datum)
|
|
261
261
|
end
|
|
262
262
|
|
|
@@ -264,8 +264,8 @@ module Geodetic
|
|
|
264
264
|
GH.new(to_lla(datum), precision: precision)
|
|
265
265
|
end
|
|
266
266
|
|
|
267
|
-
def self.from_gh(
|
|
268
|
-
lla_coord =
|
|
267
|
+
def self.from_gh(gh, zone_code, datum = WGS84)
|
|
268
|
+
lla_coord = gh.to_lla(datum)
|
|
269
269
|
from_lla(lla_coord, zone_code, datum)
|
|
270
270
|
end
|
|
271
271
|
|
|
@@ -273,8 +273,8 @@ module Geodetic
|
|
|
273
273
|
HAM.new(to_lla(datum), precision: precision)
|
|
274
274
|
end
|
|
275
275
|
|
|
276
|
-
def self.from_ham(
|
|
277
|
-
lla_coord =
|
|
276
|
+
def self.from_ham(ham, zone_code, datum = WGS84)
|
|
277
|
+
lla_coord = ham.to_lla(datum)
|
|
278
278
|
from_lla(lla_coord, zone_code, datum)
|
|
279
279
|
end
|
|
280
280
|
|
|
@@ -282,8 +282,8 @@ module Geodetic
|
|
|
282
282
|
OLC.new(to_lla(datum), precision: precision)
|
|
283
283
|
end
|
|
284
284
|
|
|
285
|
-
def self.from_olc(
|
|
286
|
-
lla_coord =
|
|
285
|
+
def self.from_olc(olc, zone_code, datum = WGS84)
|
|
286
|
+
lla_coord = olc.to_lla(datum)
|
|
287
287
|
from_lla(lla_coord, zone_code, datum)
|
|
288
288
|
end
|
|
289
289
|
|
|
@@ -291,8 +291,8 @@ module Geodetic
|
|
|
291
291
|
GEOREF.new(to_lla(datum), precision: precision)
|
|
292
292
|
end
|
|
293
293
|
|
|
294
|
-
def self.from_georef(
|
|
295
|
-
lla_coord =
|
|
294
|
+
def self.from_georef(georef, zone_code, datum = WGS84)
|
|
295
|
+
lla_coord = georef.to_lla(datum)
|
|
296
296
|
from_lla(lla_coord, zone_code, datum)
|
|
297
297
|
end
|
|
298
298
|
|
|
@@ -300,8 +300,8 @@ module Geodetic
|
|
|
300
300
|
GARS.new(to_lla(datum), precision: precision)
|
|
301
301
|
end
|
|
302
302
|
|
|
303
|
-
def self.from_gars(
|
|
304
|
-
lla_coord =
|
|
303
|
+
def self.from_gars(gars, zone_code, datum = WGS84)
|
|
304
|
+
lla_coord = gars.to_lla(datum)
|
|
305
305
|
from_lla(lla_coord, zone_code, datum)
|
|
306
306
|
end
|
|
307
307
|
|
|
@@ -309,8 +309,8 @@ module Geodetic
|
|
|
309
309
|
H3.new(to_lla(datum), precision: precision)
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
-
def self.from_h3(
|
|
313
|
-
lla_coord =
|
|
312
|
+
def self.from_h3(h3, zone_code, datum = WGS84)
|
|
313
|
+
lla_coord = h3.to_lla(datum)
|
|
314
314
|
from_lla(lla_coord, zone_code, datum)
|
|
315
315
|
end
|
|
316
316
|
|
|
@@ -359,7 +359,7 @@ module Geodetic
|
|
|
359
359
|
end
|
|
360
360
|
|
|
361
361
|
# Find appropriate zone for a given LLA coordinate
|
|
362
|
-
def self.find_zone_for_lla(
|
|
362
|
+
def self.find_zone_for_lla(lla, state_name = nil)
|
|
363
363
|
# This is a simplified version - real implementation would use precise zone boundaries
|
|
364
364
|
candidate_zones = state_name ? zones_for_state(state_name) : ZONES
|
|
365
365
|
|
|
@@ -448,10 +448,10 @@ module Geodetic
|
|
|
448
448
|
LLA.new(lat: lat, lng: lng, alt: 0.0)
|
|
449
449
|
end
|
|
450
450
|
|
|
451
|
-
def self.from_lla_lambert_conformal_conic(
|
|
451
|
+
def self.from_lla_lambert_conformal_conic(lla, zone_code, zone_info, datum)
|
|
452
452
|
# Lambert Conformal Conic forward projection (simplified)
|
|
453
|
-
lat =
|
|
454
|
-
lng =
|
|
453
|
+
lat = lla.lat * RAD_PER_DEG
|
|
454
|
+
lng = lla.lng * RAD_PER_DEG
|
|
455
455
|
|
|
456
456
|
lat0_rad = zone_info[:latitude_of_origin] * RAD_PER_DEG
|
|
457
457
|
lon0_rad = zone_info[:central_meridian] * RAD_PER_DEG
|
|
@@ -474,10 +474,10 @@ module Geodetic
|
|
|
474
474
|
new(easting: x, northing: y, zone_code: zone_code, datum: datum)
|
|
475
475
|
end
|
|
476
476
|
|
|
477
|
-
def self.from_lla_transverse_mercator(
|
|
477
|
+
def self.from_lla_transverse_mercator(lla, zone_code, zone_info, datum)
|
|
478
478
|
# Transverse Mercator forward projection (simplified)
|
|
479
|
-
lat =
|
|
480
|
-
lng =
|
|
479
|
+
lat = lla.lat * RAD_PER_DEG
|
|
480
|
+
lng = lla.lng * RAD_PER_DEG
|
|
481
481
|
|
|
482
482
|
lat0_rad = zone_info[:latitude_of_origin] * RAD_PER_DEG
|
|
483
483
|
lon0_rad = zone_info[:central_meridian] * RAD_PER_DEG
|