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.
@@ -0,0 +1,305 @@
1
+ {
2
+ "type": "FeatureCollection",
3
+ "features": [
4
+ {
5
+ "type": "Feature",
6
+ "geometry": {
7
+ "type": "Point",
8
+ "coordinates": [
9
+ -122.3493,
10
+ 47.6205
11
+ ]
12
+ },
13
+ "properties": {
14
+ "name": "Seattle",
15
+ "type": "city"
16
+ }
17
+ },
18
+ {
19
+ "type": "Feature",
20
+ "geometry": {
21
+ "type": "Point",
22
+ "coordinates": [
23
+ -122.6784,
24
+ 45.5152
25
+ ]
26
+ },
27
+ "properties": {
28
+ "name": "Portland",
29
+ "type": "city"
30
+ }
31
+ },
32
+ {
33
+ "type": "Feature",
34
+ "geometry": {
35
+ "type": "Point",
36
+ "coordinates": [
37
+ -122.4194,
38
+ 37.7749
39
+ ]
40
+ },
41
+ "properties": {
42
+ "name": "San Francisco",
43
+ "type": "city"
44
+ }
45
+ },
46
+ {
47
+ "type": "Feature",
48
+ "geometry": {
49
+ "type": "Point",
50
+ "coordinates": [
51
+ -118.2437,
52
+ 34.0522
53
+ ]
54
+ },
55
+ "properties": {
56
+ "name": "Los Angeles",
57
+ "type": "city"
58
+ }
59
+ },
60
+ {
61
+ "type": "Feature",
62
+ "geometry": {
63
+ "type": "Point",
64
+ "coordinates": [
65
+ -74.006,
66
+ 40.7128
67
+ ]
68
+ },
69
+ "properties": {
70
+ "name": "New York",
71
+ "type": "city"
72
+ }
73
+ },
74
+ {
75
+ "type": "Feature",
76
+ "geometry": {
77
+ "type": "LineString",
78
+ "coordinates": [
79
+ [
80
+ -122.3493,
81
+ 47.6205
82
+ ],
83
+ [
84
+ -122.6784,
85
+ 45.5152
86
+ ],
87
+ [
88
+ -122.4194,
89
+ 37.7749
90
+ ],
91
+ [
92
+ -118.2437,
93
+ 34.0522
94
+ ]
95
+ ]
96
+ },
97
+ "properties": {
98
+ "name": "West Coast Route",
99
+ "mode": "driving"
100
+ }
101
+ },
102
+ {
103
+ "type": "Feature",
104
+ "geometry": {
105
+ "type": "Point",
106
+ "coordinates": [
107
+ 2.3522,
108
+ 48.8566
109
+ ]
110
+ },
111
+ "properties": {}
112
+ },
113
+ {
114
+ "type": "Feature",
115
+ "geometry": {
116
+ "type": "Point",
117
+ "coordinates": [
118
+ -0.1278,
119
+ 51.5074
120
+ ]
121
+ },
122
+ "properties": {}
123
+ },
124
+ {
125
+ "type": "Feature",
126
+ "geometry": {
127
+ "type": "Polygon",
128
+ "coordinates": [
129
+ [
130
+ [
131
+ -123.0,
132
+ 48.0
133
+ ],
134
+ [
135
+ -121.0,
136
+ 48.0
137
+ ],
138
+ [
139
+ -121.0,
140
+ 46.0
141
+ ],
142
+ [
143
+ -123.0,
144
+ 46.0
145
+ ],
146
+ [
147
+ -123.0,
148
+ 48.0
149
+ ]
150
+ ]
151
+ ]
152
+ },
153
+ "properties": {
154
+ "name": "Pacific NW",
155
+ "region": true
156
+ }
157
+ },
158
+ {
159
+ "type": "Feature",
160
+ "geometry": {
161
+ "type": "Polygon",
162
+ "coordinates": [
163
+ [
164
+ [
165
+ -122.3493,
166
+ 47.710441151017214
167
+ ],
168
+ [
169
+ -122.32330338127136,
170
+ 47.708710028492575
171
+ ],
172
+ [
173
+ -122.29831079292721,
174
+ 47.70358352014371
175
+ ],
176
+ [
177
+ -122.27528691572327,
178
+ 47.69525958316883
179
+ ],
180
+ [
181
+ -122.25511936150583,
182
+ 47.684059519927274
183
+ ],
184
+ [
185
+ -122.23858413342101,
186
+ 47.67041541322468
187
+ ],
188
+ [
189
+ -122.22631565848305,
190
+ 47.654853266080394
191
+ ],
192
+ [
193
+ -122.21878256554382,
194
+ 47.63797253321124
195
+ ],
196
+ [
197
+ -122.21627011382594,
198
+ 47.62042286978415
199
+ ],
200
+ [
201
+ -122.21886987894307,
202
+ 47.602879023582524
203
+ ],
204
+ [
205
+ -122.2264769927538,
206
+ 47.586014856783315
207
+ ],
208
+ [
209
+ -122.23879492708923,
210
+ 47.57047750255195
211
+ ],
212
+ [
213
+ -122.25534752329217,
214
+ 47.5568626411414
215
+ ],
216
+ [
217
+ -122.27549771006404,
218
+ 47.54569182325386
219
+ ],
220
+ [
221
+ -122.2984721281491,
222
+ 47.53739267934147
223
+ ],
224
+ [
225
+ -122.32339069534318,
226
+ 47.532282737212164
227
+ ],
228
+ [
229
+ -122.3493,
230
+ 47.53055743197494
231
+ ],
232
+ [
233
+ -122.37520930465682,
234
+ 47.532282737212164
235
+ ],
236
+ [
237
+ -122.4001278718509,
238
+ 47.53739267934147
239
+ ],
240
+ [
241
+ -122.42310228993595,
242
+ 47.54569182325386
243
+ ],
244
+ [
245
+ -122.44325247670783,
246
+ 47.55686264114141
247
+ ],
248
+ [
249
+ -122.45980507291077,
250
+ 47.57047750255195
251
+ ],
252
+ [
253
+ -122.4721230072462,
254
+ 47.58601485678331
255
+ ],
256
+ [
257
+ -122.47973012105693,
258
+ 47.60287902358252
259
+ ],
260
+ [
261
+ -122.48232988617406,
262
+ 47.62042286978415
263
+ ],
264
+ [
265
+ -122.47981743445618,
266
+ 47.63797253321123
267
+ ],
268
+ [
269
+ -122.47228434151695,
270
+ 47.6548532660804
271
+ ],
272
+ [
273
+ -122.46001586657898,
274
+ 47.670415413224674
275
+ ],
276
+ [
277
+ -122.44348063849417,
278
+ 47.684059519927274
279
+ ],
280
+ [
281
+ -122.42331308427673,
282
+ 47.69525958316883
283
+ ],
284
+ [
285
+ -122.40028920707279,
286
+ 47.70358352014371
287
+ ],
288
+ [
289
+ -122.37529661872864,
290
+ 47.708710028492575
291
+ ],
292
+ [
293
+ -122.3493,
294
+ 47.710441151017214
295
+ ]
296
+ ]
297
+ ]
298
+ },
299
+ "properties": {
300
+ "name": "Seattle Metro",
301
+ "radius_km": 10
302
+ }
303
+ }
304
+ ]
305
+ }
@@ -31,29 +31,9 @@ module Geodetic
31
31
 
32
32
  n.times.map do |i|
33
33
  angle = @bearing + step * i
34
- destination(@center, @radius, angle)
34
+ Vector.new(distance: @radius, bearing: angle).destination_from(@center)
35
35
  end
36
36
  end
37
-
38
- # Compute a destination point given start, distance (meters), and bearing (degrees).
39
- # Uses a simplified flat-earth projection adequate for polygon-scale distances.
40
- def destination(origin, distance_m, bearing_deg)
41
- bearing_rad = bearing_deg * Geodetic::RAD_PER_DEG
42
- lat_rad = origin.lat * Geodetic::RAD_PER_DEG
43
-
44
- # Approximate meters per degree at this latitude
45
- m_per_deg_lat = 111_320.0
46
- m_per_deg_lng = 111_320.0 * Math.cos(lat_rad)
47
-
48
- dlat = distance_m * Math.cos(bearing_rad) / m_per_deg_lat
49
- dlng = distance_m * Math.sin(bearing_rad) / m_per_deg_lng
50
-
51
- Coordinate::LLA.new(
52
- lat: origin.lat + dlat,
53
- lng: origin.lng + dlng,
54
- alt: origin.alt
55
- )
56
- end
57
37
  end
58
38
  end
59
39
  end
@@ -138,15 +138,15 @@ module Geodetic
138
138
  end
139
139
  end
140
140
 
141
- def self.from_lla(lla_coord, datum = WGS84)
141
+ def self.from_lla(lla, datum = WGS84)
142
142
  # Convert to OSGB36 if needed
143
143
  if datum == WGS84
144
144
  # Simplified WGS84 to OSGB36 transformation
145
- lat = lla_coord.lat + 0.00015
146
- lng = lla_coord.lng - 0.00045
147
- osgb36_lla = LLA.new(lat: lat, lng: lng, alt: lla_coord.alt)
145
+ lat = lla.lat + 0.00015
146
+ lng = lla.lng - 0.00045
147
+ osgb36_lla = LLA.new(lat: lat, lng: lng, alt: lla.alt)
148
148
  else
149
- osgb36_lla = lla_coord
149
+ osgb36_lla = lla
150
150
  end
151
151
 
152
152
  # Convert to BNG using Transverse Mercator
@@ -158,8 +158,8 @@ module Geodetic
158
158
  to_lla(datum).to_ecef(datum)
159
159
  end
160
160
 
161
- def self.from_ecef(ecef_coord, datum = WGS84)
162
- lla_coord = ecef_coord.to_lla(datum)
161
+ def self.from_ecef(ecef, datum = WGS84)
162
+ lla_coord = ecef.to_lla(datum)
163
163
  from_lla(lla_coord, datum)
164
164
  end
165
165
 
@@ -167,8 +167,8 @@ module Geodetic
167
167
  to_lla(datum).to_utm(datum)
168
168
  end
169
169
 
170
- def self.from_utm(utm_coord, datum = WGS84)
171
- lla_coord = utm_coord.to_lla(datum)
170
+ def self.from_utm(utm, datum = WGS84)
171
+ lla_coord = utm.to_lla(datum)
172
172
  from_lla(lla_coord, datum)
173
173
  end
174
174
 
@@ -176,8 +176,8 @@ module Geodetic
176
176
  to_lla(datum).to_enu(reference_lla)
177
177
  end
178
178
 
179
- def self.from_enu(enu_coord, reference_lla, datum = WGS84)
180
- lla_coord = enu_coord.to_lla(reference_lla)
179
+ def self.from_enu(enu, reference_lla, datum = WGS84)
180
+ lla_coord = enu.to_lla(reference_lla)
181
181
  from_lla(lla_coord, datum)
182
182
  end
183
183
 
@@ -185,8 +185,8 @@ module Geodetic
185
185
  to_lla(datum).to_ned(reference_lla)
186
186
  end
187
187
 
188
- def self.from_ned(ned_coord, reference_lla, datum = WGS84)
189
- lla_coord = ned_coord.to_lla(reference_lla)
188
+ def self.from_ned(ned, reference_lla, datum = WGS84)
189
+ lla_coord = ned.to_lla(reference_lla)
190
190
  from_lla(lla_coord, datum)
191
191
  end
192
192
 
@@ -194,8 +194,8 @@ module Geodetic
194
194
  MGRS.from_lla(to_lla(datum), datum, precision)
195
195
  end
196
196
 
197
- def self.from_mgrs(mgrs_coord, datum = WGS84)
198
- lla_coord = mgrs_coord.to_lla(datum)
197
+ def self.from_mgrs(mgrs, datum = WGS84)
198
+ lla_coord = mgrs.to_lla(datum)
199
199
  from_lla(lla_coord, datum)
200
200
  end
201
201
 
@@ -203,8 +203,8 @@ module Geodetic
203
203
  USNG.from_lla(to_lla(datum), datum, precision)
204
204
  end
205
205
 
206
- def self.from_usng(usng_coord, datum = WGS84)
207
- lla_coord = usng_coord.to_lla(datum)
206
+ def self.from_usng(usng, datum = WGS84)
207
+ lla_coord = usng.to_lla(datum)
208
208
  from_lla(lla_coord, datum)
209
209
  end
210
210
 
@@ -212,8 +212,8 @@ module Geodetic
212
212
  WebMercator.from_lla(to_lla(datum), datum)
213
213
  end
214
214
 
215
- def self.from_web_mercator(web_mercator_coord, datum = WGS84)
216
- lla_coord = web_mercator_coord.to_lla(datum)
215
+ def self.from_web_mercator(web_mercator, datum = WGS84)
216
+ lla_coord = web_mercator.to_lla(datum)
217
217
  from_lla(lla_coord, datum)
218
218
  end
219
219
 
@@ -221,8 +221,8 @@ module Geodetic
221
221
  UPS.from_lla(to_lla(datum), datum)
222
222
  end
223
223
 
224
- def self.from_ups(ups_coord, datum = WGS84)
225
- lla_coord = ups_coord.to_lla(datum)
224
+ def self.from_ups(ups, datum = WGS84)
225
+ lla_coord = ups.to_lla(datum)
226
226
  from_lla(lla_coord, datum)
227
227
  end
228
228
 
@@ -230,8 +230,8 @@ module Geodetic
230
230
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
231
231
  end
232
232
 
233
- def self.from_state_plane(state_plane_coord, datum = WGS84)
234
- lla_coord = state_plane_coord.to_lla(datum)
233
+ def self.from_state_plane(state_plane, datum = WGS84)
234
+ lla_coord = state_plane.to_lla(datum)
235
235
  from_lla(lla_coord, datum)
236
236
  end
237
237
 
@@ -312,13 +312,13 @@ module Geodetic
312
312
  LLA.new(lat: lat_deg, lng: lng_deg, alt: 0.0)
313
313
  end
314
314
 
315
- def self.transverse_mercator_forward(lla_coord, datum)
315
+ def self.transverse_mercator_forward(lla, datum)
316
316
  # Forward Transverse Mercator projection from OSGB36 lat/lng to BNG
317
317
  a = datum.a
318
318
  e2 = datum.e2
319
319
 
320
- lat = lla_coord.lat * RAD_PER_DEG
321
- lng = lla_coord.lng * RAD_PER_DEG
320
+ lat = lla.lat * RAD_PER_DEG
321
+ lng = lla.lng * RAD_PER_DEG
322
322
  lat0_rad = ORIGIN_LATITUDE * RAD_PER_DEG
323
323
  lng0_rad = ORIGIN_LONGITUDE * RAD_PER_DEG
324
324
  k0 = SCALE_FACTOR
@@ -140,48 +140,48 @@ module Geodetic
140
140
  MGRS.from_lla(to_lla(datum), datum, precision)
141
141
  end
142
142
 
143
- def self.from_mgrs(mgrs_coord, datum = WGS84)
144
- mgrs_coord.to_ecef(datum)
143
+ def self.from_mgrs(mgrs, datum = WGS84)
144
+ mgrs.to_ecef(datum)
145
145
  end
146
146
 
147
147
  def to_usng(datum = WGS84, precision = 5)
148
148
  USNG.from_lla(to_lla(datum), datum, precision)
149
149
  end
150
150
 
151
- def self.from_usng(usng_coord, datum = WGS84)
152
- usng_coord.to_ecef(datum)
151
+ def self.from_usng(usng, datum = WGS84)
152
+ usng.to_ecef(datum)
153
153
  end
154
154
 
155
155
  def to_web_mercator(datum = WGS84)
156
156
  WebMercator.from_lla(to_lla(datum), datum)
157
157
  end
158
158
 
159
- def self.from_web_mercator(wm_coord, datum = WGS84)
160
- wm_coord.to_ecef(datum)
159
+ def self.from_web_mercator(web_mercator, datum = WGS84)
160
+ web_mercator.to_ecef(datum)
161
161
  end
162
162
 
163
163
  def to_ups(datum = WGS84)
164
164
  UPS.from_lla(to_lla(datum), datum)
165
165
  end
166
166
 
167
- def self.from_ups(ups_coord, datum = WGS84)
168
- ups_coord.to_ecef(datum)
167
+ def self.from_ups(ups, datum = WGS84)
168
+ ups.to_ecef(datum)
169
169
  end
170
170
 
171
171
  def to_state_plane(zone_code, datum = WGS84)
172
172
  StatePlane.from_lla(to_lla(datum), zone_code, datum)
173
173
  end
174
174
 
175
- def self.from_state_plane(sp_coord, datum = WGS84)
176
- sp_coord.to_ecef(datum)
175
+ def self.from_state_plane(state_plane, datum = WGS84)
176
+ state_plane.to_ecef(datum)
177
177
  end
178
178
 
179
179
  def to_bng(datum = WGS84)
180
180
  BNG.from_lla(to_lla(datum))
181
181
  end
182
182
 
183
- def self.from_bng(bng_coord, datum = WGS84)
184
- bng_coord.to_ecef(datum)
183
+ def self.from_bng(bng, datum = WGS84)
184
+ bng.to_ecef(datum)
185
185
  end
186
186
 
187
187
  def to_s(precision = 2)
@@ -108,8 +108,8 @@ module Geodetic
108
108
  MGRS.from_lla(to_lla(reference_lla), datum, precision)
109
109
  end
110
110
 
111
- def self.from_mgrs(mgrs_coord, reference_lla, datum = WGS84)
112
- lla = mgrs_coord.to_lla(datum)
111
+ def self.from_mgrs(mgrs, reference_lla, datum = WGS84)
112
+ lla = mgrs.to_lla(datum)
113
113
  from_lla(lla, reference_lla)
114
114
  end
115
115
 
@@ -117,8 +117,8 @@ module Geodetic
117
117
  USNG.from_lla(to_lla(reference_lla), datum, precision)
118
118
  end
119
119
 
120
- def self.from_usng(usng_coord, reference_lla, datum = WGS84)
121
- lla = usng_coord.to_lla(datum)
120
+ def self.from_usng(usng, reference_lla, datum = WGS84)
121
+ lla = usng.to_lla(datum)
122
122
  from_lla(lla, reference_lla)
123
123
  end
124
124
 
@@ -126,8 +126,8 @@ module Geodetic
126
126
  WebMercator.from_lla(to_lla(reference_lla), datum)
127
127
  end
128
128
 
129
- def self.from_web_mercator(wm_coord, reference_lla, datum = WGS84)
130
- lla = wm_coord.to_lla(datum)
129
+ def self.from_web_mercator(web_mercator, reference_lla, datum = WGS84)
130
+ lla = web_mercator.to_lla(datum)
131
131
  from_lla(lla, reference_lla)
132
132
  end
133
133
 
@@ -135,8 +135,8 @@ module Geodetic
135
135
  UPS.from_lla(to_lla(reference_lla), datum)
136
136
  end
137
137
 
138
- def self.from_ups(ups_coord, reference_lla, datum = WGS84)
139
- lla = ups_coord.to_lla(datum)
138
+ def self.from_ups(ups, reference_lla, datum = WGS84)
139
+ lla = ups.to_lla(datum)
140
140
  from_lla(lla, reference_lla)
141
141
  end
142
142
 
@@ -144,8 +144,8 @@ module Geodetic
144
144
  StatePlane.from_lla(to_lla(reference_lla), zone_code, datum)
145
145
  end
146
146
 
147
- def self.from_state_plane(sp_coord, reference_lla, datum = WGS84)
148
- lla = sp_coord.to_lla(datum)
147
+ def self.from_state_plane(state_plane, reference_lla, datum = WGS84)
148
+ lla = state_plane.to_lla(datum)
149
149
  from_lla(lla, reference_lla)
150
150
  end
151
151
 
@@ -153,8 +153,8 @@ module Geodetic
153
153
  BNG.from_lla(to_lla(reference_lla))
154
154
  end
155
155
 
156
- def self.from_bng(bng_coord, reference_lla)
157
- lla = bng_coord.to_lla
156
+ def self.from_bng(bng, reference_lla)
157
+ lla = bng.to_lla
158
158
  from_lla(lla, reference_lla)
159
159
  end
160
160
 
@@ -162,8 +162,8 @@ module Geodetic
162
162
  GH36.new(to_lla(reference_lla), precision: precision)
163
163
  end
164
164
 
165
- def self.from_gh36(gh36_coord, reference_lla)
166
- lla = gh36_coord.to_lla
165
+ def self.from_gh36(gh36, reference_lla)
166
+ lla = gh36.to_lla
167
167
  from_lla(lla, reference_lla)
168
168
  end
169
169
 
@@ -171,8 +171,8 @@ module Geodetic
171
171
  GH.new(to_lla(reference_lla), precision: precision)
172
172
  end
173
173
 
174
- def self.from_gh(gh_coord, reference_lla)
175
- lla = gh_coord.to_lla
174
+ def self.from_gh(gh, reference_lla)
175
+ lla = gh.to_lla
176
176
  from_lla(lla, reference_lla)
177
177
  end
178
178
 
@@ -180,8 +180,8 @@ module Geodetic
180
180
  HAM.new(to_lla(reference_lla), precision: precision)
181
181
  end
182
182
 
183
- def self.from_ham(ham_coord, reference_lla)
184
- lla = ham_coord.to_lla
183
+ def self.from_ham(ham, reference_lla)
184
+ lla = ham.to_lla
185
185
  from_lla(lla, reference_lla)
186
186
  end
187
187
 
@@ -189,8 +189,8 @@ module Geodetic
189
189
  OLC.new(to_lla(reference_lla), precision: precision)
190
190
  end
191
191
 
192
- def self.from_olc(olc_coord, reference_lla)
193
- lla = olc_coord.to_lla
192
+ def self.from_olc(olc, reference_lla)
193
+ lla = olc.to_lla
194
194
  from_lla(lla, reference_lla)
195
195
  end
196
196
 
@@ -198,8 +198,8 @@ module Geodetic
198
198
  GEOREF.new(to_lla(reference_lla), precision: precision)
199
199
  end
200
200
 
201
- def self.from_georef(georef_coord, reference_lla)
202
- lla = georef_coord.to_lla
201
+ def self.from_georef(georef, reference_lla)
202
+ lla = georef.to_lla
203
203
  from_lla(lla, reference_lla)
204
204
  end
205
205
 
@@ -207,8 +207,8 @@ module Geodetic
207
207
  GARS.new(to_lla(reference_lla), precision: precision)
208
208
  end
209
209
 
210
- def self.from_gars(gars_coord, reference_lla)
211
- lla = gars_coord.to_lla
210
+ def self.from_gars(gars, reference_lla)
211
+ lla = gars.to_lla
212
212
  from_lla(lla, reference_lla)
213
213
  end
214
214
 
@@ -216,8 +216,8 @@ module Geodetic
216
216
  H3.new(to_lla(reference_lla), precision: precision)
217
217
  end
218
218
 
219
- def self.from_h3(h3_coord, reference_lla)
220
- lla = h3_coord.to_lla
219
+ def self.from_h3(h3, reference_lla)
220
+ lla = h3.to_lla
221
221
  from_lla(lla, reference_lla)
222
222
  end
223
223