geodetic 0.1.0 → 0.3.0
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 +28 -4
- data/README.md +19 -5
- data/docs/coordinate-systems/bng.md +5 -5
- data/docs/coordinate-systems/ecef.md +23 -23
- data/docs/coordinate-systems/enu.md +3 -3
- data/docs/coordinate-systems/gars.md +246 -0
- data/docs/coordinate-systems/georef.md +221 -0
- data/docs/coordinate-systems/gh.md +7 -7
- data/docs/coordinate-systems/gh36.md +6 -6
- data/docs/coordinate-systems/h3.md +312 -0
- data/docs/coordinate-systems/ham.md +6 -6
- data/docs/coordinate-systems/index.md +40 -34
- data/docs/coordinate-systems/lla.md +26 -26
- data/docs/coordinate-systems/mgrs.md +3 -3
- data/docs/coordinate-systems/ned.md +3 -3
- data/docs/coordinate-systems/olc.md +6 -6
- data/docs/coordinate-systems/state-plane.md +2 -2
- data/docs/coordinate-systems/ups.md +4 -4
- data/docs/coordinate-systems/usng.md +2 -2
- data/docs/coordinate-systems/utm.md +23 -23
- data/docs/coordinate-systems/web-mercator.md +7 -7
- data/docs/getting-started/installation.md +17 -17
- data/docs/getting-started/quick-start.md +8 -8
- data/docs/index.md +22 -19
- data/docs/reference/areas.md +15 -15
- data/docs/reference/conversions.md +31 -31
- data/docs/reference/geoid-height.md +5 -5
- data/docs/reference/serialization.md +44 -44
- data/examples/01_basic_conversions.rb +10 -10
- data/examples/02_all_coordinate_systems.rb +24 -24
- data/lib/geodetic/areas/circle.rb +1 -1
- data/lib/geodetic/areas/polygon.rb +2 -2
- data/lib/geodetic/areas/rectangle.rb +6 -6
- data/lib/geodetic/{coordinates → coordinate}/bng.rb +3 -37
- data/lib/geodetic/{coordinates → coordinate}/ecef.rb +3 -33
- data/lib/geodetic/{coordinates → coordinate}/enu.rb +30 -1
- data/lib/geodetic/coordinate/gars.rb +233 -0
- data/lib/geodetic/coordinate/georef.rb +204 -0
- data/lib/geodetic/coordinate/gh.rb +161 -0
- data/lib/geodetic/{coordinates → coordinate}/gh36.rb +28 -187
- data/lib/geodetic/coordinate/h3.rb +413 -0
- data/lib/geodetic/coordinate/ham.rb +226 -0
- data/lib/geodetic/{coordinates → coordinate}/lla.rb +31 -1
- data/lib/geodetic/{coordinates → coordinate}/mgrs.rb +3 -33
- data/lib/geodetic/{coordinates → coordinate}/ned.rb +30 -1
- data/lib/geodetic/{coordinates → coordinate}/olc.rb +19 -225
- data/lib/geodetic/coordinate/spatial_hash.rb +342 -0
- data/lib/geodetic/{coordinates → coordinate}/state_plane.rb +30 -1
- data/lib/geodetic/{coordinates → coordinate}/ups.rb +3 -37
- data/lib/geodetic/{coordinates → coordinate}/usng.rb +3 -33
- data/lib/geodetic/{coordinates → coordinate}/utm.rb +3 -33
- data/lib/geodetic/{coordinates → coordinate}/web_mercator.rb +3 -33
- data/lib/geodetic/{coordinates.rb → coordinate.rb} +62 -45
- data/lib/geodetic/version.rb +1 -1
- data/lib/geodetic.rb +1 -1
- data/spatial_hash_idea.md +241 -0
- metadata +29 -20
- data/lib/geodetic/coordinates/gh.rb +0 -372
- data/lib/geodetic/coordinates/ham.rb +0 -435
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::WebMercator
|
|
2
2
|
|
|
3
3
|
## Web Mercator (EPSG:3857)
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ Web Mercator is the de facto standard projection used by major web mapping platf
|
|
|
7
7
|
## Constructor
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
point = Geodetic::
|
|
10
|
+
point = Geodetic::Coordinate::WebMercator.new(x: 0.0, y: 0.0)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Parameters `x` and `y` are specified in **meters** from the projection origin (the intersection of the Equator and the Prime Meridian).
|
|
@@ -27,7 +27,7 @@ Convert between Web Mercator coordinates and map tile indices at a given zoom le
|
|
|
27
27
|
```ruby
|
|
28
28
|
tile_x, tile_y = point.to_tile_coordinates(zoom)
|
|
29
29
|
|
|
30
|
-
point = Geodetic::
|
|
30
|
+
point = Geodetic::Coordinate::WebMercator.from_tile_coordinates(x, y, zoom)
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Pixel Coordinate Methods
|
|
@@ -37,7 +37,7 @@ Convert between Web Mercator coordinates and pixel positions at a given zoom lev
|
|
|
37
37
|
```ruby
|
|
38
38
|
pixel_x, pixel_y = point.to_pixel_coordinates(zoom, tile_size)
|
|
39
39
|
|
|
40
|
-
point = Geodetic::
|
|
40
|
+
point = Geodetic::Coordinate::WebMercator.from_pixel_coordinates(x, y, zoom, tile_size)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Tile Bounds
|
|
@@ -45,7 +45,7 @@ point = Geodetic::Coordinates::WebMercator.from_pixel_coordinates(x, y, zoom, ti
|
|
|
45
45
|
Retrieve the bounding box of a specific tile.
|
|
46
46
|
|
|
47
47
|
```ruby
|
|
48
|
-
bounds = Geodetic::
|
|
48
|
+
bounds = Geodetic::Coordinate::WebMercator.tile_bounds(tile_x, tile_y, zoom)
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
## Validation and Utility Methods
|
|
@@ -60,8 +60,8 @@ bounds = Geodetic::Coordinates::WebMercator.tile_bounds(tile_x, tile_y, zoom)
|
|
|
60
60
|
The universal `distance_to` method computes the Vincenty great-circle distance (in meters) to any other coordinate type. The `straight_line_distance_to` method computes the Euclidean distance in ECEF space. Both accept single or multiple targets.
|
|
61
61
|
|
|
62
62
|
```ruby
|
|
63
|
-
wm_a = Geodetic::
|
|
64
|
-
wm_b = Geodetic::
|
|
63
|
+
wm_a = Geodetic::Coordinate::WebMercator.new(x: -13627665.0, y: 6044499.0)
|
|
64
|
+
wm_b = Geodetic::Coordinate::WebMercator.new(x: -13631157.0, y: 5694043.0)
|
|
65
65
|
wm_a.distance_to(wm_b) # => Distance (meters, great-circle)
|
|
66
66
|
wm_a.straight_line_distance_to(wm_b) # => Distance (meters, Euclidean)
|
|
67
67
|
```
|
|
@@ -38,21 +38,21 @@ If you want to use a coordinate class directly without going through a conversio
|
|
|
38
38
|
|
|
39
39
|
```ruby
|
|
40
40
|
require "geodetic"
|
|
41
|
-
require "geodetic/
|
|
42
|
-
require "geodetic/
|
|
43
|
-
require "geodetic/
|
|
44
|
-
require "geodetic/
|
|
45
|
-
require "geodetic/
|
|
46
|
-
require "geodetic/
|
|
47
|
-
require "geodetic/
|
|
48
|
-
require "geodetic/
|
|
49
|
-
require "geodetic/
|
|
50
|
-
require "geodetic/
|
|
51
|
-
require "geodetic/
|
|
52
|
-
require "geodetic/
|
|
53
|
-
require "geodetic/
|
|
54
|
-
require "geodetic/
|
|
55
|
-
require "geodetic/
|
|
41
|
+
require "geodetic/coordinate/lla"
|
|
42
|
+
require "geodetic/coordinate/ecef"
|
|
43
|
+
require "geodetic/coordinate/utm"
|
|
44
|
+
require "geodetic/coordinate/enu"
|
|
45
|
+
require "geodetic/coordinate/ned"
|
|
46
|
+
require "geodetic/coordinate/mgrs"
|
|
47
|
+
require "geodetic/coordinate/usng"
|
|
48
|
+
require "geodetic/coordinate/web_mercator"
|
|
49
|
+
require "geodetic/coordinate/ups"
|
|
50
|
+
require "geodetic/coordinate/state_plane"
|
|
51
|
+
require "geodetic/coordinate/bng"
|
|
52
|
+
require "geodetic/coordinate/gh36"
|
|
53
|
+
require "geodetic/coordinate/gh"
|
|
54
|
+
require "geodetic/coordinate/ham"
|
|
55
|
+
require "geodetic/coordinate/olc"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
You only need to require the types you plan to construct directly. Conversion methods handle their own requires internally.
|
|
@@ -61,9 +61,9 @@ You only need to require the types you plan to construct directly. Conversion me
|
|
|
61
61
|
|
|
62
62
|
```ruby
|
|
63
63
|
require "geodetic"
|
|
64
|
-
require "geodetic/
|
|
64
|
+
require "geodetic/coordinate/lla"
|
|
65
65
|
|
|
66
|
-
lla = Geodetic::
|
|
66
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 47.6205, lng: -122.3493, alt: 184.0)
|
|
67
67
|
puts lla.to_s
|
|
68
68
|
#=> "47.6205, -122.3493, 184.0"
|
|
69
69
|
```
|
|
@@ -8,9 +8,9 @@ LLA (Latitude, Longitude, Altitude) is the most common starting point. All const
|
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
10
|
require "geodetic"
|
|
11
|
-
require "geodetic/
|
|
11
|
+
require "geodetic/coordinate/lla"
|
|
12
12
|
|
|
13
|
-
space_needle = Geodetic::
|
|
13
|
+
space_needle = Geodetic::Coordinate::LLA.new(
|
|
14
14
|
lat: 47.6205,
|
|
15
15
|
lng: -122.3493,
|
|
16
16
|
alt: 184.0
|
|
@@ -60,7 +60,7 @@ Local tangent plane coordinate systems require a reference point. ENU (East, Nor
|
|
|
60
60
|
|
|
61
61
|
```ruby
|
|
62
62
|
# Define a reference point (e.g., a nearby base station)
|
|
63
|
-
reference = Geodetic::
|
|
63
|
+
reference = Geodetic::Coordinate::LLA.new(
|
|
64
64
|
lat: 47.6062,
|
|
65
65
|
lng: -122.3321,
|
|
66
66
|
alt: 0.0
|
|
@@ -98,7 +98,7 @@ dms = space_needle.to_dms
|
|
|
98
98
|
puts dms #=> "47° 37' 13.80\" N, 122° 20' 57.48\" W, 184.00 m"
|
|
99
99
|
|
|
100
100
|
# Parse a DMS string back to LLA
|
|
101
|
-
lla = Geodetic::
|
|
101
|
+
lla = Geodetic::Coordinate::LLA.from_dms("47° 37' 13.80\" N, 122° 20' 57.48\" W, 184.00 m")
|
|
102
102
|
puts lla.lat #=> 47.6205
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -112,15 +112,15 @@ str = space_needle.to_s #=> "47.6205, -122.3493, 184.0"
|
|
|
112
112
|
arr = space_needle.to_a #=> [47.6205, -122.3493, 184.0]
|
|
113
113
|
|
|
114
114
|
# Deserialize
|
|
115
|
-
lla_from_str = Geodetic::
|
|
116
|
-
lla_from_arr = Geodetic::
|
|
115
|
+
lla_from_str = Geodetic::Coordinate::LLA.from_string(str)
|
|
116
|
+
lla_from_arr = Geodetic::Coordinate::LLA.from_array(arr)
|
|
117
117
|
|
|
118
118
|
# Works the same for all coordinate types
|
|
119
119
|
ecef = space_needle.to_ecef
|
|
120
120
|
ecef_str = ecef.to_s
|
|
121
121
|
ecef_arr = ecef.to_a
|
|
122
|
-
ecef_restored = Geodetic::
|
|
123
|
-
ecef_restored = Geodetic::
|
|
122
|
+
ecef_restored = Geodetic::Coordinate::ECEF.from_string(ecef_str)
|
|
123
|
+
ecef_restored = Geodetic::Coordinate::ECEF.from_array(ecef_arr)
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## 7. Work with Datums
|
data/docs/index.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<td width="50%" valign="top">
|
|
10
10
|
<h2>Key Features</h2>
|
|
11
11
|
<lu>
|
|
12
|
-
<li><strong>
|
|
12
|
+
<li><strong>18 Coordinate Systems</strong> - LLA, ECEF, UTM, ENU, NED, MGRS, USNG, Web Mercator, UPS, State Plane, BNG, GH36, GH, HAM, OLC<br>
|
|
13
13
|
<li><strong>Full Bidirectional Conversions</strong> - Every system converts to and from every other system<br>
|
|
14
14
|
<li><strong>Distance Calculations</strong> - Vincenty great-circle and straight-line with unit tracking<br>
|
|
15
15
|
<li><strong>Bearing Calculations</strong> - Forward azimuth, back azimuth, compass directions, elevation angles<br>
|
|
@@ -24,29 +24,32 @@
|
|
|
24
24
|
</tr>
|
|
25
25
|
</table>
|
|
26
26
|
|
|
27
|
-
Geodetic is a Ruby gem for converting between geodetic coordinate systems. It provides a clean, consistent API for working with
|
|
27
|
+
Geodetic is a Ruby gem for converting between geodetic coordinate systems. It provides a clean, consistent API for working with 18 coordinate systems, 16 geodetic datums, geoid height calculations, and geographic area computations.
|
|
28
28
|
|
|
29
29
|
## Coordinate Systems
|
|
30
30
|
|
|
31
|
-
Geodetic supports full bidirectional conversion between all
|
|
31
|
+
Geodetic supports full bidirectional conversion between all 18 coordinate systems:
|
|
32
32
|
|
|
33
33
|
| System | Class | Description |
|
|
34
34
|
|--------|-------|-------------|
|
|
35
|
-
| **LLA** | `Geodetic::
|
|
36
|
-
| **ECEF** | `Geodetic::
|
|
37
|
-
| **UTM** | `Geodetic::
|
|
38
|
-
| **ENU** | `Geodetic::
|
|
39
|
-
| **NED** | `Geodetic::
|
|
40
|
-
| **MGRS** | `Geodetic::
|
|
41
|
-
| **USNG** | `Geodetic::
|
|
42
|
-
| **WebMercator** | `Geodetic::
|
|
43
|
-
| **UPS** | `Geodetic::
|
|
44
|
-
| **StatePlane** | `Geodetic::
|
|
45
|
-
| **BNG** | `Geodetic::
|
|
46
|
-
| **GH36** | `Geodetic::
|
|
47
|
-
| **GH** | `Geodetic::
|
|
48
|
-
| **HAM** | `Geodetic::
|
|
49
|
-
| **OLC** | `Geodetic::
|
|
35
|
+
| **LLA** | `Geodetic::Coordinate::LLA` | Latitude, Longitude, Altitude |
|
|
36
|
+
| **ECEF** | `Geodetic::Coordinate::ECEF` | Earth-Centered, Earth-Fixed (X, Y, Z) |
|
|
37
|
+
| **UTM** | `Geodetic::Coordinate::UTM` | Universal Transverse Mercator |
|
|
38
|
+
| **ENU** | `Geodetic::Coordinate::ENU` | East, North, Up (local tangent plane) |
|
|
39
|
+
| **NED** | `Geodetic::Coordinate::NED` | North, East, Down (local tangent plane) |
|
|
40
|
+
| **MGRS** | `Geodetic::Coordinate::MGRS` | Military Grid Reference System |
|
|
41
|
+
| **USNG** | `Geodetic::Coordinate::USNG` | United States National Grid |
|
|
42
|
+
| **WebMercator** | `Geodetic::Coordinate::WebMercator` | Web Mercator projection (EPSG:3857) |
|
|
43
|
+
| **UPS** | `Geodetic::Coordinate::UPS` | Universal Polar Stereographic |
|
|
44
|
+
| **StatePlane** | `Geodetic::Coordinate::StatePlane` | State Plane Coordinate System |
|
|
45
|
+
| **BNG** | `Geodetic::Coordinate::BNG` | British National Grid |
|
|
46
|
+
| **GH36** | `Geodetic::Coordinate::GH36` | Geohash-36 (spatial hash, URL-friendly) |
|
|
47
|
+
| **GH** | `Geodetic::Coordinate::GH` | Geohash base-32 (standard geohash, widely supported) |
|
|
48
|
+
| **HAM** | `Geodetic::Coordinate::HAM` | Maidenhead Locator System (amateur radio grid squares) |
|
|
49
|
+
| **OLC** | `Geodetic::Coordinate::OLC` | Open Location Code / Plus Codes (Google's location encoding) |
|
|
50
|
+
| **GEOREF** | `Geodetic::Coordinate::GEOREF` | World Geographic Reference System (aviation/military) |
|
|
51
|
+
| **GARS** | `Geodetic::Coordinate::GARS` | Global Area Reference System (NGA standard) |
|
|
52
|
+
| **H3** | `Geodetic::Coordinate::H3` | Uber's hexagonal hierarchical index (requires `libh3`) |
|
|
50
53
|
|
|
51
54
|
## Additional Features
|
|
52
55
|
|
|
@@ -66,7 +69,7 @@ Geodetic supports full bidirectional conversion between all 15 coordinate system
|
|
|
66
69
|
require "geodetic"
|
|
67
70
|
|
|
68
71
|
# Create an LLA coordinate (Seattle Space Needle)
|
|
69
|
-
lla = Geodetic::
|
|
72
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 47.6205, lng: -122.3493, alt: 184.0)
|
|
70
73
|
|
|
71
74
|
# Convert to ECEF
|
|
72
75
|
ecef = lla.to_ecef
|
data/docs/reference/areas.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Areas Reference
|
|
2
2
|
|
|
3
|
-
The `Geodetic::Areas` module provides three geometric area classes for point-in-area testing: `Circle`, `Polygon`, and `Rectangle`. All operate on `Geodetic::
|
|
3
|
+
The `Geodetic::Areas` module provides three geometric area classes for point-in-area testing: `Circle`, `Polygon`, and `Rectangle`. All operate on `Geodetic::Coordinate::LLA` points.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ Defines a circular area on the Earth's surface.
|
|
|
11
11
|
### Constructor
|
|
12
12
|
|
|
13
13
|
```ruby
|
|
14
|
-
center = Geodetic::
|
|
14
|
+
center = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 0.0)
|
|
15
15
|
|
|
16
16
|
circle = Geodetic::Areas::Circle.new(
|
|
17
17
|
centroid: center, # LLA point at the center
|
|
@@ -33,7 +33,7 @@ circle = Geodetic::Areas::Circle.new(
|
|
|
33
33
|
Returns `true` if the given LLA point falls within (or on the boundary of) the circle. The distance from centroid to the point is compared against the radius.
|
|
34
34
|
|
|
35
35
|
```ruby
|
|
36
|
-
point = Geodetic::
|
|
36
|
+
point = Geodetic::Coordinate::LLA.new(lat: 38.898, lng: -77.036, alt: 0.0)
|
|
37
37
|
circle.includes?(point) # => true or false
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -62,10 +62,10 @@ Defines an arbitrary polygon area on the Earth's surface.
|
|
|
62
62
|
|
|
63
63
|
```ruby
|
|
64
64
|
boundary = [
|
|
65
|
-
Geodetic::
|
|
66
|
-
Geodetic::
|
|
67
|
-
Geodetic::
|
|
68
|
-
Geodetic::
|
|
65
|
+
Geodetic::Coordinate::LLA.new(lat: 38.90, lng: -77.04, alt: 0.0),
|
|
66
|
+
Geodetic::Coordinate::LLA.new(lat: 38.90, lng: -77.03, alt: 0.0),
|
|
67
|
+
Geodetic::Coordinate::LLA.new(lat: 38.89, lng: -77.03, alt: 0.0),
|
|
68
|
+
Geodetic::Coordinate::LLA.new(lat: 38.89, lng: -77.04, alt: 0.0)
|
|
69
69
|
]
|
|
70
70
|
|
|
71
71
|
polygon = Geodetic::Areas::Polygon.new(boundary: boundary)
|
|
@@ -95,7 +95,7 @@ Returns `true` if the given LLA point falls within the polygon. Uses the winding
|
|
|
95
95
|
Also returns `true` if the point is exactly equal to any boundary vertex.
|
|
96
96
|
|
|
97
97
|
```ruby
|
|
98
|
-
point = Geodetic::
|
|
98
|
+
point = Geodetic::Coordinate::LLA.new(lat: 38.895, lng: -77.035, alt: 0.0)
|
|
99
99
|
polygon.includes?(point) # => true or false
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -123,8 +123,8 @@ Defines an axis-aligned rectangle by its northwest and southeast corners.
|
|
|
123
123
|
### Constructor
|
|
124
124
|
|
|
125
125
|
```ruby
|
|
126
|
-
nw = Geodetic::
|
|
127
|
-
se = Geodetic::
|
|
126
|
+
nw = Geodetic::Coordinate::LLA.new(lat: 41.0, lng: -75.0)
|
|
127
|
+
se = Geodetic::Coordinate::LLA.new(lat: 40.0, lng: -74.0)
|
|
128
128
|
|
|
129
129
|
rectangle = Geodetic::Areas::Rectangle.new(nw: nw, se: se)
|
|
130
130
|
```
|
|
@@ -132,8 +132,8 @@ rectangle = Geodetic::Areas::Rectangle.new(nw: nw, se: se)
|
|
|
132
132
|
The constructor accepts any coordinate type that responds to `to_lla` -- coordinates are automatically converted to LLA.
|
|
133
133
|
|
|
134
134
|
```ruby
|
|
135
|
-
nw_wm = Geodetic::
|
|
136
|
-
se_wm = Geodetic::
|
|
135
|
+
nw_wm = Geodetic::Coordinate::WebMercator.from_lla(nw)
|
|
136
|
+
se_wm = Geodetic::Coordinate::WebMercator.from_lla(se)
|
|
137
137
|
rectangle = Geodetic::Areas::Rectangle.new(nw: nw_wm, se: se_wm)
|
|
138
138
|
```
|
|
139
139
|
|
|
@@ -163,7 +163,7 @@ rectangle.sw # => LLA (se.lat, nw.lng)
|
|
|
163
163
|
Returns `true` if the given point falls within (or on the boundary of) the rectangle. Accepts any coordinate type that responds to `to_lla`.
|
|
164
164
|
|
|
165
165
|
```ruby
|
|
166
|
-
point = Geodetic::
|
|
166
|
+
point = Geodetic::Coordinate::LLA.new(lat: 40.5, lng: -74.5)
|
|
167
167
|
rectangle.includes?(point) # => true
|
|
168
168
|
```
|
|
169
169
|
|
|
@@ -184,10 +184,10 @@ rectangle.excludes?(point) # => true or false
|
|
|
184
184
|
|
|
185
185
|
### Integration with GH36
|
|
186
186
|
|
|
187
|
-
`Geodetic::
|
|
187
|
+
`Geodetic::Coordinate::GH36#to_area` returns a `Rectangle` representing the geohash cell's bounding box:
|
|
188
188
|
|
|
189
189
|
```ruby
|
|
190
|
-
gh36 = Geodetic::
|
|
190
|
+
gh36 = Geodetic::Coordinate::GH36.new("bdrdC26BqH")
|
|
191
191
|
area = gh36.to_area
|
|
192
192
|
# => Geodetic::Areas::Rectangle
|
|
193
193
|
|
|
@@ -34,11 +34,11 @@ TargetClass.from_<source>(source_object, datum = WGS84)
|
|
|
34
34
|
Examples:
|
|
35
35
|
|
|
36
36
|
```ruby
|
|
37
|
-
Geodetic::
|
|
38
|
-
Geodetic::
|
|
39
|
-
Geodetic::
|
|
40
|
-
Geodetic::
|
|
41
|
-
Geodetic::
|
|
37
|
+
Geodetic::Coordinate::ECEF.from_lla(lla)
|
|
38
|
+
Geodetic::Coordinate::LLA.from_ecef(ecef)
|
|
39
|
+
Geodetic::Coordinate::UTM.from_lla(lla)
|
|
40
|
+
Geodetic::Coordinate::LLA.from_utm(utm)
|
|
41
|
+
Geodetic::Coordinate::WebMercator.from_ecef(ecef)
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
---
|
|
@@ -50,7 +50,7 @@ ENU and NED are local tangent plane systems that require a **reference LLA** poi
|
|
|
50
50
|
### Instance Methods
|
|
51
51
|
|
|
52
52
|
```ruby
|
|
53
|
-
ref = Geodetic::
|
|
53
|
+
ref = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 0.0)
|
|
54
54
|
|
|
55
55
|
# LLA to local
|
|
56
56
|
lla.to_enu(ref)
|
|
@@ -80,24 +80,24 @@ ned.to_ecef(reference_ecef, reference_lla)
|
|
|
80
80
|
### Class Methods
|
|
81
81
|
|
|
82
82
|
```ruby
|
|
83
|
-
ref = Geodetic::
|
|
83
|
+
ref = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 0.0)
|
|
84
84
|
|
|
85
|
-
Geodetic::
|
|
86
|
-
Geodetic::
|
|
87
|
-
Geodetic::
|
|
88
|
-
Geodetic::
|
|
85
|
+
Geodetic::Coordinate::ENU.from_lla(lla, ref)
|
|
86
|
+
Geodetic::Coordinate::NED.from_lla(lla, ref)
|
|
87
|
+
Geodetic::Coordinate::LLA.from_enu(enu, ref)
|
|
88
|
+
Geodetic::Coordinate::LLA.from_ned(ned, ref)
|
|
89
89
|
|
|
90
90
|
# From other systems via reference
|
|
91
|
-
Geodetic::
|
|
92
|
-
Geodetic::
|
|
93
|
-
Geodetic::
|
|
94
|
-
Geodetic::
|
|
91
|
+
Geodetic::Coordinate::ENU.from_utm(utm, ref)
|
|
92
|
+
Geodetic::Coordinate::NED.from_utm(utm, ref)
|
|
93
|
+
Geodetic::Coordinate::UTM.from_enu(enu, ref)
|
|
94
|
+
Geodetic::Coordinate::UTM.from_ned(ned, ref)
|
|
95
95
|
|
|
96
96
|
# ECEF-based
|
|
97
|
-
Geodetic::
|
|
98
|
-
Geodetic::
|
|
99
|
-
Geodetic::
|
|
100
|
-
Geodetic::
|
|
97
|
+
Geodetic::Coordinate::ENU.from_ecef(ecef, ref_ecef, ref_lla)
|
|
98
|
+
Geodetic::Coordinate::NED.from_ecef(ecef, ref_ecef, ref_lla)
|
|
99
|
+
Geodetic::Coordinate::ECEF.from_enu(enu, ref_ecef, ref_lla)
|
|
100
|
+
Geodetic::Coordinate::ECEF.from_ned(ned, ref_ecef, ref_lla)
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
When `reference_lla` is omitted in ECEF-based conversions, it is computed automatically from `reference_ecef` via `reference_ecef.to_lla`.
|
|
@@ -118,17 +118,17 @@ MGRS and USNG accept an optional `precision` parameter (1-5, default 5) controll
|
|
|
118
118
|
|
|
119
119
|
```ruby
|
|
120
120
|
# LLA to MGRS with precision
|
|
121
|
-
Geodetic::
|
|
121
|
+
Geodetic::Coordinate::MGRS.from_lla(lla, datum, precision)
|
|
122
122
|
lla_point.to_mgrs(datum, precision) # available on UPS, WebMercator, BNG, StatePlane
|
|
123
123
|
|
|
124
124
|
# LLA to USNG with precision
|
|
125
|
-
Geodetic::
|
|
125
|
+
Geodetic::Coordinate::USNG.from_lla(lla, datum, precision)
|
|
126
126
|
|
|
127
127
|
# MGRS <-> USNG (direct conversion)
|
|
128
128
|
mgrs.to_usng # implicit via component transfer
|
|
129
|
-
Geodetic::
|
|
129
|
+
Geodetic::Coordinate::USNG.from_mgrs(mgrs)
|
|
130
130
|
usng.to_mgrs
|
|
131
|
-
Geodetic::
|
|
131
|
+
Geodetic::Coordinate::MGRS.from_usng(usng) # implicit via string
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
---
|
|
@@ -139,11 +139,11 @@ StatePlane requires a **zone code** when converting into the system:
|
|
|
139
139
|
|
|
140
140
|
```ruby
|
|
141
141
|
# To StatePlane (zone_code required)
|
|
142
|
-
Geodetic::
|
|
143
|
-
Geodetic::
|
|
144
|
-
Geodetic::
|
|
145
|
-
Geodetic::
|
|
146
|
-
Geodetic::
|
|
142
|
+
Geodetic::Coordinate::StatePlane.from_lla(lla, 'CA_I')
|
|
143
|
+
Geodetic::Coordinate::StatePlane.from_ecef(ecef, 'CA_I')
|
|
144
|
+
Geodetic::Coordinate::StatePlane.from_utm(utm, 'CA_I')
|
|
145
|
+
Geodetic::Coordinate::StatePlane.from_enu(enu, ref_lla, 'CA_I')
|
|
146
|
+
Geodetic::Coordinate::StatePlane.from_ned(ned, ref_lla, 'CA_I')
|
|
147
147
|
|
|
148
148
|
# From StatePlane (zone is stored in the object)
|
|
149
149
|
state_plane.to_lla
|
|
@@ -178,7 +178,7 @@ utm.to_lla(clarke)
|
|
|
178
178
|
StatePlane stores its datum internally and uses it when no datum argument is provided:
|
|
179
179
|
|
|
180
180
|
```ruby
|
|
181
|
-
sp = Geodetic::
|
|
181
|
+
sp = Geodetic::Coordinate::StatePlane.new(
|
|
182
182
|
easting: 2000000.0, northing: 500000.0,
|
|
183
183
|
zone_code: 'CA_I', datum: clarke
|
|
184
184
|
)
|
|
@@ -240,7 +240,7 @@ Universal distance methods are available on all coordinate types and work across
|
|
|
240
240
|
### Great-Circle Distance (Vincenty)
|
|
241
241
|
|
|
242
242
|
- **`distance_to(other, *others)`** — Instance method. Computes the Vincenty great-circle distance from the receiver to one or more target coordinates. Returns a `Distance` for a single target, or an Array of `Distance` objects for multiple targets (radial distances from the receiver).
|
|
243
|
-
- **`GCS.distance_between(*coords)`** — Class method on `Geodetic::
|
|
243
|
+
- **`GCS.distance_between(*coords)`** — Class method on `Geodetic::Coordinate` (aliased as `GCS`). Computes consecutive chain distances between an ordered sequence of coordinates. Returns a `Distance` for two coordinates, or an Array of `Distance` objects for three or more.
|
|
244
244
|
|
|
245
245
|
> **`Distance` objects** wrap a distance value and provide unit-aware access. Call `.meters` to get the raw Float value in meters, or `.to_f` to get the value in the current display unit.
|
|
246
246
|
|
|
@@ -299,7 +299,7 @@ Universal bearing methods are available on all coordinate types and work across
|
|
|
299
299
|
|
|
300
300
|
- **`bearing_to(other)`** — Instance method. Computes the great-circle forward azimuth from the receiver to the target coordinate. Returns a `Bearing` object.
|
|
301
301
|
- **`elevation_to(other)`** — Instance method. Computes the vertical look angle (elevation) from the receiver to the target. Returns a Float in degrees (-90 to +90).
|
|
302
|
-
- **`GCS.bearing_between(*coords)`** — Class method on `Geodetic::
|
|
302
|
+
- **`GCS.bearing_between(*coords)`** — Class method on `Geodetic::Coordinate` (aliased as `GCS`). Computes consecutive chain bearings between an ordered sequence of coordinates. Returns a `Bearing` for two coordinates, or an Array of `Bearing` objects for three or more.
|
|
303
303
|
|
|
304
304
|
```ruby
|
|
305
305
|
seattle = GCS::LLA.new(lat: 47.6205, lng: -122.3493, alt: 0.0)
|
|
@@ -141,7 +141,7 @@ Geodetic::GeoidHeight.available_vertical_datums
|
|
|
141
141
|
|
|
142
142
|
## Geodetic::GeoidHeightSupport (Mixin)
|
|
143
143
|
|
|
144
|
-
The `GeoidHeightSupport` module is included in `Geodetic::
|
|
144
|
+
The `GeoidHeightSupport` module is included in `Geodetic::Coordinate::LLA`, adding geoid-related methods directly to LLA instances.
|
|
145
145
|
|
|
146
146
|
### Mixin Methods
|
|
147
147
|
|
|
@@ -150,7 +150,7 @@ The `GeoidHeightSupport` module is included in `Geodetic::Coordinates::LLA`, add
|
|
|
150
150
|
Returns the geoid undulation at the LLA position.
|
|
151
151
|
|
|
152
152
|
```ruby
|
|
153
|
-
point = Geodetic::
|
|
153
|
+
point = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 100.0)
|
|
154
154
|
point.geoid_height # Uses EGM2008
|
|
155
155
|
point.geoid_height('GEOID18') # Uses GEOID18
|
|
156
156
|
```
|
|
@@ -168,7 +168,7 @@ point.orthometric_height # alt minus geoid undulation
|
|
|
168
168
|
Returns a new LLA with the altitude converted between vertical datums. The original object is not modified.
|
|
169
169
|
|
|
170
170
|
```ruby
|
|
171
|
-
wgs84_point = Geodetic::
|
|
171
|
+
wgs84_point = Geodetic::Coordinate::LLA.new(lat: 40.0, lng: -100.0, alt: 300.0)
|
|
172
172
|
navd88_point = wgs84_point.convert_height_datum('HAE', 'NAVD88')
|
|
173
173
|
```
|
|
174
174
|
|
|
@@ -177,6 +177,6 @@ navd88_point = wgs84_point.convert_height_datum('HAE', 'NAVD88')
|
|
|
177
177
|
The mixin also extends the including class with a `with_geoid_height` class method and a `geoid_model` reader, though these are primarily for internal use:
|
|
178
178
|
|
|
179
179
|
```ruby
|
|
180
|
-
Geodetic::
|
|
181
|
-
Geodetic::
|
|
180
|
+
Geodetic::Coordinate::LLA.with_geoid_height('GEOID18')
|
|
181
|
+
Geodetic::Coordinate::LLA.geoid_model # => 'GEOID18'
|
|
182
182
|
```
|