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,56 +1,59 @@
|
|
|
1
1
|
# Coordinate Systems Overview
|
|
2
2
|
|
|
3
|
-
The Geodetic gem supports
|
|
3
|
+
The Geodetic gem supports 18 coordinate systems organized into six categories. All coordinate classes live under `Geodetic::Coordinate`.
|
|
4
4
|
|
|
5
5
|
## Global Systems
|
|
6
6
|
|
|
7
7
|
| System | Class | Description |
|
|
8
8
|
|--------|-------|-------------|
|
|
9
|
-
| **LLA** | `Geodetic::
|
|
10
|
-
| **ECEF** | `Geodetic::
|
|
11
|
-
| **UTM** | `Geodetic::
|
|
9
|
+
| **LLA** | `Geodetic::Coordinate::LLA` | Latitude, Longitude, Altitude. The most common geographic coordinate system, expressing positions in decimal degrees with altitude in meters. Negative longitude is the Western hemisphere; negative latitude is the Southern hemisphere. |
|
|
10
|
+
| **ECEF** | `Geodetic::Coordinate::ECEF` | Earth-Centered, Earth-Fixed. A Cartesian coordinate system with the origin at the Earth's center of mass. Positions are expressed as X, Y, Z in meters. Commonly used in satellite navigation and aerospace applications. |
|
|
11
|
+
| **UTM** | `Geodetic::Coordinate::UTM` | Universal Transverse Mercator. Divides the Earth into 60 zones (each 6 degrees of longitude), projecting positions as easting/northing in meters within a zone and hemisphere. Covers latitudes 80S to 84N. |
|
|
12
12
|
|
|
13
13
|
## Local Tangent Plane Systems
|
|
14
14
|
|
|
15
15
|
| System | Class | Description |
|
|
16
16
|
|--------|-------|-------------|
|
|
17
|
-
| **ENU** | `Geodetic::
|
|
18
|
-
| **NED** | `Geodetic::
|
|
17
|
+
| **ENU** | `Geodetic::Coordinate::ENU` | East, North, Up. A local tangent plane coordinate system centered on a reference point. Axes point East, North, and Up relative to the reference. Distances are in meters. Used in robotics, surveying, and local navigation. |
|
|
18
|
+
| **NED** | `Geodetic::Coordinate::NED` | North, East, Down. A local tangent plane coordinate system centered on a reference point. Axes point North, East, and Down. Used extensively in aerospace and aviation applications. Mathematically related to ENU by axis reordering and sign inversion. |
|
|
19
19
|
|
|
20
20
|
## Military and Grid Systems
|
|
21
21
|
|
|
22
22
|
| System | Class | Description |
|
|
23
23
|
|--------|-------|-------------|
|
|
24
|
-
| **MGRS** | `Geodetic::
|
|
25
|
-
| **USNG** | `Geodetic::
|
|
24
|
+
| **MGRS** | `Geodetic::Coordinate::MGRS` | Military Grid Reference System. An alphanumeric system based on UTM that identifies positions using grid zone designator, 100km square identifier, and numeric easting/northing. Variable precision from 10km down to 1m. |
|
|
25
|
+
| **USNG** | `Geodetic::Coordinate::USNG` | United States National Grid. Based on MGRS but formatted with spaces for readability. Used primarily within the United States for emergency services and land management. |
|
|
26
26
|
|
|
27
27
|
## Web Mapping
|
|
28
28
|
|
|
29
29
|
| System | Class | Description |
|
|
30
30
|
|--------|-------|-------------|
|
|
31
|
-
| **WebMercator** | `Geodetic::
|
|
31
|
+
| **WebMercator** | `Geodetic::Coordinate::WebMercator` | Web Mercator (EPSG:3857). Also known as Pseudo-Mercator or Spherical Mercator. The projection used by Google Maps, OpenStreetMap, and Bing Maps. Positions are X/Y in meters. Latitude is clamped to approximately +/-85.05 degrees. Includes tile and pixel coordinate methods for web mapping applications. |
|
|
32
32
|
|
|
33
33
|
## Polar
|
|
34
34
|
|
|
35
35
|
| System | Class | Description |
|
|
36
36
|
|--------|-------|-------------|
|
|
37
|
-
| **UPS** | `Geodetic::
|
|
37
|
+
| **UPS** | `Geodetic::Coordinate::UPS` | Universal Polar Stereographic. Covers the polar regions not handled by UTM (north of 84N and south of 80S). Uses a stereographic projection centered on each pole with zones Y/Z (north) and A/B (south). |
|
|
38
38
|
|
|
39
39
|
## Spatial Hashing
|
|
40
40
|
|
|
41
41
|
| System | Class | Description |
|
|
42
42
|
|--------|-------|-------------|
|
|
43
|
-
| **GH36** | `Geodetic::
|
|
44
|
-
| **GH** | `Geodetic::
|
|
45
|
-
| **HAM** | `Geodetic::
|
|
46
|
-
| **OLC** | `Geodetic::
|
|
43
|
+
| **GH36** | `Geodetic::Coordinate::GH36` | Geohash-36. A hierarchical spatial hashing algorithm that encodes latitude/longitude into a compact, URL-friendly string using a case-sensitive 36-character alphabet (radix-36). Each hash represents a rectangular cell; the coordinate value is the cell midpoint. Supports neighbor lookup, area extraction via `to_area`, and configurable precision (default 10 characters for sub-meter resolution). |
|
|
44
|
+
| **GH** | `Geodetic::Coordinate::GH` | Geohash (base-32). The standard geohash algorithm by Gustavo Niemeyer using a 32-character alphabet (`0-9, b-z` excluding `a, i, l, o`). The de facto standard for spatial hashing, natively supported by Elasticsearch, Redis, PostGIS, and many geocoding services. Supports neighbor lookup, area extraction, and configurable precision (default 12 characters for sub-centimeter resolution). |
|
|
45
|
+
| **HAM** | `Geodetic::Coordinate::HAM` | Maidenhead Locator System. A hierarchical grid system used worldwide in amateur radio that encodes positions using alternating letter/digit pairs (e.g., `FN31pr`). Four levels of precision: Field (18x18), Square (10x10), Subsquare (24x24), Extended (10x10). Supports neighbor lookup, area extraction, and configurable precision (default 6 characters for ~5 km resolution). |
|
|
46
|
+
| **OLC** | `Geodetic::Coordinate::OLC` | Open Location Code (Plus Codes). Google's open system for encoding locations into short codes like `849VCWC8+R9`. Uses a 20-character alphabet with 5 paired levels of base-20 encoding plus optional grid refinement. Includes a `+` separator at position 8. Supports neighbor lookup, area extraction, and configurable precision (default 10 characters for ~14 m resolution). |
|
|
47
|
+
| **GEOREF** | `Geodetic::Coordinate::GEOREF` | World Geographic Reference System. A geocode system used in aviation and military applications that encodes positions using letter tiles (15° grid), letter degree subdivisions, and numeric minute pairs. Uses a 24-letter alphabet (A-Z excluding I and O). Supports variable precision from 15° tiles (2 chars) down to 0.01-minute resolution (12 chars). Default precision is 8 characters (1-minute resolution). |
|
|
48
|
+
| **GARS** | `Geodetic::Coordinate::GARS` | Global Area Reference System. An NGA standard that divides the world into 30-minute cells identified by a 3-digit longitude band (001-720) and 2-letter latitude band. Cells are subdivided into 15-minute quadrants (1-4) and 5-minute keypads (1-9, telephone layout). Variable precision: 5 chars (30'), 6 chars (15'), 7 chars (5'). Default precision is 7 characters. |
|
|
49
|
+
| **H3** | `Geodetic::Coordinate::H3` | H3 Hexagonal Hierarchical Index. Uber's spatial indexing system that divides the globe into hexagonal cells (and 12 pentagons) at 16 resolution levels (0-15). Each cell is a 64-bit integer displayed as a hex string. Unlike the rectangular spatial hashes, `to_area` returns an `Areas::Polygon` with 6 vertices (5 for pentagons) and `neighbors` returns an Array of 6 cells. **Requires `libh3` installed** (`brew install h3` on macOS). |
|
|
47
50
|
|
|
48
51
|
## Regional Systems
|
|
49
52
|
|
|
50
53
|
| System | Class | Description |
|
|
51
54
|
|--------|-------|-------------|
|
|
52
|
-
| **StatePlane** | `Geodetic::
|
|
53
|
-
| **BNG** | `Geodetic::
|
|
55
|
+
| **StatePlane** | `Geodetic::Coordinate::StatePlane` | State Plane Coordinate System. US state-based coordinate systems using Lambert Conformal Conic or Transverse Mercator projections. Each state has one or more zones with specific parameters. Coordinates are typically in US Survey Feet. |
|
|
56
|
+
| **BNG** | `Geodetic::Coordinate::BNG` | British National Grid. The official coordinate system for Great Britain, based on the OSGB36 datum with the Airy 1830 ellipsoid. Uses a Transverse Mercator projection and an alphanumeric grid reference system (e.g., "TQ 30 80"). |
|
|
54
57
|
|
|
55
58
|
---
|
|
56
59
|
|
|
@@ -58,23 +61,26 @@ The Geodetic gem supports 15 coordinate systems organized into six categories. A
|
|
|
58
61
|
|
|
59
62
|
Every coordinate system can convert to every other coordinate system. The table below confirms full interoperability:
|
|
60
63
|
|
|
61
|
-
| From \ To | LLA | ECEF | UTM | ENU | NED | MGRS | USNG | WebMercator | UPS | StatePlane | BNG | GH36 | GH | HAM | OLC |
|
|
62
|
-
|
|
63
|
-
| **LLA** | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
64
|
-
| **ECEF** | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
65
|
-
| **UTM** | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
66
|
-
| **ENU** | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
67
|
-
| **NED** | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
68
|
-
| **MGRS** | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
69
|
-
| **USNG** | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
70
|
-
| **WebMercator**| Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y |
|
|
71
|
-
| **UPS** | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y |
|
|
72
|
-
| **StatePlane** | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y |
|
|
73
|
-
| **BNG** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y |
|
|
74
|
-
| **GH36** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y |
|
|
75
|
-
| **GH** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y |
|
|
76
|
-
| **HAM** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y |
|
|
77
|
-
| **OLC** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- |
|
|
64
|
+
| From \ To | LLA | ECEF | UTM | ENU | NED | MGRS | USNG | WebMercator | UPS | StatePlane | BNG | GH36 | GH | HAM | OLC | GEOREF | GARS | H3 |
|
|
65
|
+
|-----------|-----|------|-----|-----|-----|------|------|-------------|-----|------------|-----|------|----|----|-----|--------|------|-----|
|
|
66
|
+
| **LLA** | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
67
|
+
| **ECEF** | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
68
|
+
| **UTM** | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
69
|
+
| **ENU** | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
70
|
+
| **NED** | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
71
|
+
| **MGRS** | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
72
|
+
| **USNG** | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
73
|
+
| **WebMercator**| Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
74
|
+
| **UPS** | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
75
|
+
| **StatePlane** | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y | Y |
|
|
76
|
+
| **BNG** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y | Y |
|
|
77
|
+
| **GH36** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y | Y |
|
|
78
|
+
| **GH** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y | Y |
|
|
79
|
+
| **HAM** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y | Y |
|
|
80
|
+
| **OLC** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y | Y |
|
|
81
|
+
| **GEOREF** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y | Y |
|
|
82
|
+
| **GARS** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- | Y |
|
|
83
|
+
| **H3** | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | -- |
|
|
78
84
|
|
|
79
85
|
## Universal Distance and Bearing Calculations
|
|
80
86
|
|
|
@@ -94,6 +100,6 @@ Conversions typically route through **LLA** or **ECEF** as intermediate steps:
|
|
|
94
100
|
- **ECEF** is the intermediate for local tangent plane systems (ENU, NED), since the rotation from global Cartesian to local frames is straightforward in ECEF.
|
|
95
101
|
- **ENU and NED** convert between each other directly by reordering axes and inverting the vertical component.
|
|
96
102
|
- **MGRS and USNG** route through UTM, which in turn routes through LLA.
|
|
97
|
-
- **WebMercator, UPS, BNG, StatePlane, GH36, GH, HAM, and
|
|
103
|
+
- **WebMercator, UPS, BNG, StatePlane, GH36, GH, HAM, OLC, GEOREF, GARS, and H3** all convert through LLA.
|
|
98
104
|
|
|
99
105
|
For example, converting from BNG to NED follows the chain: `BNG -> LLA -> ECEF -> ENU -> NED`. The gem handles this automatically when you call a conversion method.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::LLA
|
|
2
2
|
|
|
3
3
|
Latitude, Longitude, Altitude -- the most common geodetic coordinate system. Represents a position on (or above/below) the Earth's surface using angular degrees and a height in meters above the WGS84 reference ellipsoid.
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ LLA is the **hub class** in the Geodetic library. It can convert directly to all
|
|
|
11
11
|
## Constructor
|
|
12
12
|
|
|
13
13
|
```ruby
|
|
14
|
-
Geodetic::
|
|
14
|
+
Geodetic::Coordinate::LLA.new(lat: 0.0, lng: 0.0, alt: 0.0)
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
| Parameter | Type | Default | Description |
|
|
@@ -48,9 +48,9 @@ All conversion methods accept an optional `datum` parameter (defaults to `Geodet
|
|
|
48
48
|
Converts to Earth-Centered, Earth-Fixed Cartesian coordinates.
|
|
49
49
|
|
|
50
50
|
```ruby
|
|
51
|
-
lla = Geodetic::
|
|
51
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
52
52
|
ecef = lla.to_ecef
|
|
53
|
-
# => Geodetic::
|
|
53
|
+
# => Geodetic::Coordinate::ECEF
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
### LLA.from_ecef(ecef, datum = WGS84)
|
|
@@ -63,7 +63,7 @@ Converts to Universal Transverse Mercator coordinates. The UTM zone and hemisphe
|
|
|
63
63
|
|
|
64
64
|
```ruby
|
|
65
65
|
utm = lla.to_utm
|
|
66
|
-
# => Geodetic::
|
|
66
|
+
# => Geodetic::Coordinate::UTM
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
### LLA.from_utm(utm, datum = WGS84)
|
|
@@ -75,10 +75,10 @@ Creates an LLA from a UTM instance. Raises `ArgumentError` if the argument is no
|
|
|
75
75
|
Converts to East-North-Up local tangent plane coordinates relative to a reference LLA position.
|
|
76
76
|
|
|
77
77
|
```ruby
|
|
78
|
-
origin = Geodetic::
|
|
79
|
-
point = Geodetic::
|
|
78
|
+
origin = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
79
|
+
point = Geodetic::Coordinate::LLA.new(lat: 38.8987, lng: -77.0355, alt: 20.0)
|
|
80
80
|
enu = point.to_enu(origin)
|
|
81
|
-
# => Geodetic::
|
|
81
|
+
# => Geodetic::Coordinate::ENU
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
Raises `ArgumentError` if `reference_lla` is not an `LLA`.
|
|
@@ -93,7 +93,7 @@ Converts to North-East-Down local tangent plane coordinates relative to a refere
|
|
|
93
93
|
|
|
94
94
|
```ruby
|
|
95
95
|
ned = point.to_ned(origin)
|
|
96
|
-
# => Geodetic::
|
|
96
|
+
# => Geodetic::Coordinate::NED
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Raises `ArgumentError` if `reference_lla` is not an `LLA`.
|
|
@@ -109,7 +109,7 @@ Creates an LLA from a NED instance and a reference LLA origin. Raises `ArgumentE
|
|
|
109
109
|
Returns a comma-separated string of `lat, lng, alt`.
|
|
110
110
|
|
|
111
111
|
```ruby
|
|
112
|
-
lla = Geodetic::
|
|
112
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
113
113
|
lla.to_s
|
|
114
114
|
# => "38.8977, -77.0365, 17.0"
|
|
115
115
|
```
|
|
@@ -128,7 +128,7 @@ lla.to_a
|
|
|
128
128
|
Parses a comma-separated string into an LLA.
|
|
129
129
|
|
|
130
130
|
```ruby
|
|
131
|
-
lla = Geodetic::
|
|
131
|
+
lla = Geodetic::Coordinate::LLA.from_string("38.8977, -77.0365, 17.0")
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
### LLA.from_array(array)
|
|
@@ -136,7 +136,7 @@ lla = Geodetic::Coordinates::LLA.from_string("38.8977, -77.0365, 17.0")
|
|
|
136
136
|
Creates an LLA from a three-element array `[lat, lng, alt]`.
|
|
137
137
|
|
|
138
138
|
```ruby
|
|
139
|
-
lla = Geodetic::
|
|
139
|
+
lla = Geodetic::Coordinate::LLA.from_array([38.8977, -77.0365, 17.0])
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
### to_dms
|
|
@@ -144,7 +144,7 @@ lla = Geodetic::Coordinates::LLA.from_array([38.8977, -77.0365, 17.0])
|
|
|
144
144
|
Converts to a Degrees-Minutes-Seconds string with hemisphere indicators and altitude.
|
|
145
145
|
|
|
146
146
|
```ruby
|
|
147
|
-
lla = Geodetic::
|
|
147
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
148
148
|
lla.to_dms
|
|
149
149
|
# => "38° 53' 51.72\" N, 77° 2' 11.40\" W, 17.00 m"
|
|
150
150
|
```
|
|
@@ -160,7 +160,7 @@ DD° MM' SS.ss" N/S, DDD° MM' SS.ss" E/W[, altitude m]
|
|
|
160
160
|
The altitude portion is optional and defaults to `0.0`.
|
|
161
161
|
|
|
162
162
|
```ruby
|
|
163
|
-
lla = Geodetic::
|
|
163
|
+
lla = Geodetic::Coordinate::LLA.from_dms("38° 53' 51.72\" N, 77° 2' 11.40\" W, 17.0 m")
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
Raises `ArgumentError` if the string does not match the expected format.
|
|
@@ -178,8 +178,8 @@ Compares two LLA instances for approximate equality. Returns `true` if:
|
|
|
178
178
|
Returns `false` if `other` is not an `LLA`.
|
|
179
179
|
|
|
180
180
|
```ruby
|
|
181
|
-
a = Geodetic::
|
|
182
|
-
b = Geodetic::
|
|
181
|
+
a = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
182
|
+
b = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
183
183
|
a == b
|
|
184
184
|
# => true
|
|
185
185
|
```
|
|
@@ -191,7 +191,7 @@ Converts to Geohash-36 coordinates with configurable precision.
|
|
|
191
191
|
```ruby
|
|
192
192
|
gh36 = lla.to_gh36
|
|
193
193
|
gh36 = lla.to_gh36(precision: 5) # coarser precision
|
|
194
|
-
# => Geodetic::
|
|
194
|
+
# => Geodetic::Coordinate::GH36
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
### LLA.from_gh36(gh36_coord, datum = WGS84)
|
|
@@ -199,7 +199,7 @@ gh36 = lla.to_gh36(precision: 5) # coarser precision
|
|
|
199
199
|
Creates an LLA from a GH36 instance. Returns the midpoint of the geohash cell.
|
|
200
200
|
|
|
201
201
|
```ruby
|
|
202
|
-
lla = Geodetic::
|
|
202
|
+
lla = Geodetic::Coordinate::LLA.from_gh36(gh36)
|
|
203
203
|
```
|
|
204
204
|
|
|
205
205
|
## GeoidHeightSupport Mixin
|
|
@@ -211,7 +211,7 @@ LLA includes the `Geodetic::GeoidHeightSupport` module, which provides methods f
|
|
|
211
211
|
Returns the geoid undulation (in meters) at the coordinate's lat/lng for the specified geoid model.
|
|
212
212
|
|
|
213
213
|
```ruby
|
|
214
|
-
lla = Geodetic::
|
|
214
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 17.0)
|
|
215
215
|
lla.geoid_height
|
|
216
216
|
# => Float (geoid undulation in meters)
|
|
217
217
|
```
|
|
@@ -242,7 +242,7 @@ Supported vertical datums: `'NAVD88'`, `'NGVD29'`, `'MSL'`, `'HAE'`.
|
|
|
242
242
|
Sets the default geoid model for the class. Returns the class for chaining.
|
|
243
243
|
|
|
244
244
|
```ruby
|
|
245
|
-
Geodetic::
|
|
245
|
+
Geodetic::Coordinate::LLA.with_geoid_height('EGM96')
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
## Code Examples
|
|
@@ -253,7 +253,7 @@ Geodetic::Coordinates::LLA.with_geoid_height('EGM96')
|
|
|
253
253
|
require 'geodetic'
|
|
254
254
|
|
|
255
255
|
# Create an LLA coordinate
|
|
256
|
-
lla = Geodetic::
|
|
256
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 40.7128, lng: -74.0060, alt: 10.0)
|
|
257
257
|
|
|
258
258
|
# Convert to ECEF and back
|
|
259
259
|
ecef = lla.to_ecef
|
|
@@ -269,8 +269,8 @@ lla_roundtrip = utm.to_lla
|
|
|
269
269
|
### Local tangent plane
|
|
270
270
|
|
|
271
271
|
```ruby
|
|
272
|
-
origin = Geodetic::
|
|
273
|
-
target = Geodetic::
|
|
272
|
+
origin = Geodetic::Coordinate::LLA.new(lat: 40.7128, lng: -74.0060, alt: 10.0)
|
|
273
|
+
target = Geodetic::Coordinate::LLA.new(lat: 40.7138, lng: -74.0050, alt: 15.0)
|
|
274
274
|
|
|
275
275
|
enu = target.to_enu(origin)
|
|
276
276
|
ned = target.to_ned(origin)
|
|
@@ -279,17 +279,17 @@ ned = target.to_ned(origin)
|
|
|
279
279
|
### DMS formatting
|
|
280
280
|
|
|
281
281
|
```ruby
|
|
282
|
-
lla = Geodetic::
|
|
282
|
+
lla = Geodetic::Coordinate::LLA.new(lat: -33.8688, lng: 151.2093, alt: 58.0)
|
|
283
283
|
puts lla.to_dms
|
|
284
284
|
# => "33° 52' 7.68" S, 151° 12' 33.48" E, 58.00 m"
|
|
285
285
|
|
|
286
|
-
restored = Geodetic::
|
|
286
|
+
restored = Geodetic::Coordinate::LLA.from_dms(lla.to_dms)
|
|
287
287
|
```
|
|
288
288
|
|
|
289
289
|
### Geoid height operations
|
|
290
290
|
|
|
291
291
|
```ruby
|
|
292
|
-
lla = Geodetic::
|
|
292
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 38.8977, lng: -77.0365, alt: 50.0)
|
|
293
293
|
|
|
294
294
|
# Get geoid undulation at this location
|
|
295
295
|
puts lla.geoid_height # EGM2008 (default)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::MGRS - Military Grid Reference System
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
@@ -34,7 +34,7 @@ MGRS.new(
|
|
|
34
34
|
### Example
|
|
35
35
|
|
|
36
36
|
```ruby
|
|
37
|
-
mgrs = Geodetic::
|
|
37
|
+
mgrs = Geodetic::Coordinate::MGRS.new(mgrs_string: "18SUJ2337006519")
|
|
38
38
|
mgrs.to_s # => "18SUJ2337006519"
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -70,7 +70,7 @@ MGRS converts to other coordinate systems via **UTM** and **LLA**:
|
|
|
70
70
|
## Example
|
|
71
71
|
|
|
72
72
|
```ruby
|
|
73
|
-
mgrs = Geodetic::
|
|
73
|
+
mgrs = Geodetic::Coordinate::MGRS.new(mgrs_string: "18SUJ2337006519")
|
|
74
74
|
|
|
75
75
|
mgrs.grid_zone # => "18S"
|
|
76
76
|
mgrs.square_id # => "UJ"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::NED - North, East, Down
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
@@ -57,7 +57,7 @@ The one exception is the conversion between NED and ENU, which does not require
|
|
|
57
57
|
NED is a relative coordinate system. The universal `distance_to`, `straight_line_distance_to`, `bearing_to`, and `elevation_to` methods raise `ArgumentError` because NED cannot be converted to an absolute system without a reference point. Convert to an absolute system first:
|
|
58
58
|
|
|
59
59
|
```ruby
|
|
60
|
-
ref = Geodetic::
|
|
60
|
+
ref = Geodetic::Coordinate::LLA.new(lat: 47.62, lng: -122.35, alt: 0.0)
|
|
61
61
|
lla = ned.to_lla(ref)
|
|
62
62
|
lla.distance_to(other_lla) # Vincenty great-circle distance
|
|
63
63
|
lla.bearing_to(other_lla) # Great-circle forward azimuth (Bearing object)
|
|
@@ -70,7 +70,7 @@ Bearing is measured in **degrees from north**, clockwise, in the range **0-360**
|
|
|
70
70
|
## Example
|
|
71
71
|
|
|
72
72
|
```ruby
|
|
73
|
-
point = Geodetic::
|
|
73
|
+
point = Geodetic::Coordinate::NED.new(n: 200.0, e: 100.0, d: -50.0)
|
|
74
74
|
|
|
75
75
|
point.north # => 200.0
|
|
76
76
|
point.east # => 100.0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::OLC
|
|
2
2
|
|
|
3
3
|
## Open Location Code (Plus Codes)
|
|
4
4
|
|
|
@@ -19,11 +19,11 @@ OLC is a **2D coordinate system** (no altitude). Conversions to/from other syste
|
|
|
19
19
|
|
|
20
20
|
```ruby
|
|
21
21
|
# From a plus code string
|
|
22
|
-
coord = Geodetic::
|
|
22
|
+
coord = Geodetic::Coordinate::OLC.new("849VCWC8+R9")
|
|
23
23
|
|
|
24
24
|
# From any coordinate (converts via LLA)
|
|
25
|
-
coord = Geodetic::
|
|
26
|
-
coord = Geodetic::
|
|
25
|
+
coord = Geodetic::Coordinate::OLC.new(lla_coord)
|
|
26
|
+
coord = Geodetic::Coordinate::OLC.new(utm_coord, precision: 11)
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
| Parameter | Type | Default | Description |
|
|
@@ -102,11 +102,11 @@ OLC.from_ham(ham_coord)
|
|
|
102
102
|
### LLA Convenience Methods
|
|
103
103
|
|
|
104
104
|
```ruby
|
|
105
|
-
lla = Geodetic::
|
|
105
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 37.4220, lng: -122.0841)
|
|
106
106
|
olc = lla.to_olc # default precision 10
|
|
107
107
|
olc = lla.to_olc(precision: 11) # grid refinement precision
|
|
108
108
|
|
|
109
|
-
lla = Geodetic::
|
|
109
|
+
lla = Geodetic::Coordinate::LLA.from_olc(olc)
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
## Serialization
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::StatePlane
|
|
2
2
|
|
|
3
3
|
## US State Plane Coordinate System
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ The State Plane Coordinate System (SPCS) is a set of 124 geographic zones used a
|
|
|
7
7
|
## Constructor
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
point = Geodetic::
|
|
10
|
+
point = Geodetic::Coordinate::StatePlane.new(
|
|
11
11
|
easting: 0.0,
|
|
12
12
|
northing: 0.0,
|
|
13
13
|
zone_code: 'CA_I',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::UPS
|
|
2
2
|
|
|
3
3
|
## Universal Polar Stereographic
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ The Universal Polar Stereographic (UPS) coordinate system covers the polar regio
|
|
|
7
7
|
## Constructor
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
point = Geodetic::
|
|
10
|
+
point = Geodetic::Coordinate::UPS.new(
|
|
11
11
|
easting: 0.0,
|
|
12
12
|
northing: 0.0,
|
|
13
13
|
hemisphere: 'N',
|
|
@@ -46,8 +46,8 @@ Both easting and northing use a **false origin of 2,000,000 meters** to ensure a
|
|
|
46
46
|
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.
|
|
47
47
|
|
|
48
48
|
```ruby
|
|
49
|
-
ups_a = Geodetic::
|
|
50
|
-
ups_b = Geodetic::
|
|
49
|
+
ups_a = Geodetic::Coordinate::UPS.new(easting: 2000000.0, northing: 2000000.0, hemisphere: 'N', zone: 'Z')
|
|
50
|
+
ups_b = Geodetic::Coordinate::UPS.new(easting: 2100000.0, northing: 2100000.0, hemisphere: 'N', zone: 'Z')
|
|
51
51
|
ups_a.distance_to(ups_b) # => Distance (meters, great-circle)
|
|
52
52
|
ups_a.straight_line_distance_to(ups_b) # => Distance (meters, Euclidean)
|
|
53
53
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::USNG - US National Grid
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
@@ -59,7 +59,7 @@ USNG <-> MGRS <-> UTM <-> LLA
|
|
|
59
59
|
## Example
|
|
60
60
|
|
|
61
61
|
```ruby
|
|
62
|
-
usng = Geodetic::
|
|
62
|
+
usng = Geodetic::Coordinate::USNG.new(usng_string: "18T WL 12345 67890")
|
|
63
63
|
|
|
64
64
|
usng.grid_zone # => "18T"
|
|
65
65
|
usng.square_id # => "WL"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Geodetic::
|
|
1
|
+
# Geodetic::Coordinate::UTM
|
|
2
2
|
|
|
3
3
|
Universal Transverse Mercator -- a projected coordinate system that divides the Earth into 60 longitudinal zones (each 6 degrees wide) and two hemispheres (North and South). Positions within each zone are expressed as easting and northing distances in meters from the zone's origin. UTM is widely used in military, engineering, and surveying applications because it provides a flat, metric grid that minimizes distortion within each zone.
|
|
4
4
|
|
|
5
5
|
## Constructor
|
|
6
6
|
|
|
7
7
|
```ruby
|
|
8
|
-
Geodetic::
|
|
8
|
+
Geodetic::Coordinate::UTM.new(easting: 0.0, northing: 0.0, altitude: 0.0, zone: 1, hemisphere: 'N')
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
| Parameter | Type | Default | Description |
|
|
@@ -48,9 +48,9 @@ All conversion methods accept an optional `datum` parameter (defaults to `Geodet
|
|
|
48
48
|
Converts to geodetic Latitude, Longitude, Altitude coordinates. Uses a series expansion for the inverse UTM projection.
|
|
49
49
|
|
|
50
50
|
```ruby
|
|
51
|
-
utm = Geodetic::
|
|
51
|
+
utm = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, zone: 18, hemisphere: 'N')
|
|
52
52
|
lla = utm.to_lla
|
|
53
|
-
# => Geodetic::
|
|
53
|
+
# => Geodetic::Coordinate::LLA
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
### UTM.from_lla(lla, datum = WGS84)
|
|
@@ -58,7 +58,7 @@ lla = utm.to_lla
|
|
|
58
58
|
Creates a UTM from an LLA instance. The zone and hemisphere are computed automatically. Raises `ArgumentError` if the argument is not an `LLA`.
|
|
59
59
|
|
|
60
60
|
```ruby
|
|
61
|
-
utm = Geodetic::
|
|
61
|
+
utm = Geodetic::Coordinate::UTM.from_lla(lla)
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### to_ecef(datum = WGS84)
|
|
@@ -67,7 +67,7 @@ Converts to Earth-Centered, Earth-Fixed Cartesian coordinates. Internally conver
|
|
|
67
67
|
|
|
68
68
|
```ruby
|
|
69
69
|
ecef = utm.to_ecef
|
|
70
|
-
# => Geodetic::
|
|
70
|
+
# => Geodetic::Coordinate::ECEF
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### UTM.from_ecef(ecef, datum = WGS84)
|
|
@@ -79,9 +79,9 @@ Creates a UTM from an ECEF instance. Raises `ArgumentError` if the argument is n
|
|
|
79
79
|
Converts to East-North-Up local tangent plane coordinates relative to a reference LLA position.
|
|
80
80
|
|
|
81
81
|
```ruby
|
|
82
|
-
origin = Geodetic::
|
|
82
|
+
origin = Geodetic::Coordinate::LLA.new(lat: 40.7128, lng: -74.0060, alt: 10.0)
|
|
83
83
|
enu = utm.to_enu(origin)
|
|
84
|
-
# => Geodetic::
|
|
84
|
+
# => Geodetic::Coordinate::ENU
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
Raises `ArgumentError` if `reference_lla` is not an `LLA`.
|
|
@@ -96,7 +96,7 @@ Converts to North-East-Down local tangent plane coordinates relative to a refere
|
|
|
96
96
|
|
|
97
97
|
```ruby
|
|
98
98
|
ned = utm.to_ned(origin)
|
|
99
|
-
# => Geodetic::
|
|
99
|
+
# => Geodetic::Coordinate::NED
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
Raises `ArgumentError` if `reference_lla` is not an `LLA`.
|
|
@@ -112,7 +112,7 @@ Creates a UTM from a NED instance and a reference LLA origin. Raises `ArgumentEr
|
|
|
112
112
|
Returns a comma-separated string of `easting, northing, altitude, zone, hemisphere`.
|
|
113
113
|
|
|
114
114
|
```ruby
|
|
115
|
-
utm = Geodetic::
|
|
115
|
+
utm = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, altitude: 10.0, zone: 18, hemisphere: 'N')
|
|
116
116
|
utm.to_s
|
|
117
117
|
# => "580000.0, 4510000.0, 10.0, 18, N"
|
|
118
118
|
```
|
|
@@ -131,7 +131,7 @@ utm.to_a
|
|
|
131
131
|
Parses a comma-separated string into a UTM.
|
|
132
132
|
|
|
133
133
|
```ruby
|
|
134
|
-
utm = Geodetic::
|
|
134
|
+
utm = Geodetic::Coordinate::UTM.from_string("580000.0, 4510000.0, 10.0, 18, N")
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
### UTM.from_array(array)
|
|
@@ -139,7 +139,7 @@ utm = Geodetic::Coordinates::UTM.from_string("580000.0, 4510000.0, 10.0, 18, N")
|
|
|
139
139
|
Creates a UTM from a five-element array `[easting, northing, altitude, zone, hemisphere]`.
|
|
140
140
|
|
|
141
141
|
```ruby
|
|
142
|
-
utm = Geodetic::
|
|
142
|
+
utm = Geodetic::Coordinate::UTM.from_array([580000.0, 4510000.0, 10.0, 18, "N"])
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## Additional Methods
|
|
@@ -157,8 +157,8 @@ Compares two UTM instances for approximate equality. Returns `true` if:
|
|
|
157
157
|
Returns `false` if `other` is not a `UTM`.
|
|
158
158
|
|
|
159
159
|
```ruby
|
|
160
|
-
a = Geodetic::
|
|
161
|
-
b = Geodetic::
|
|
160
|
+
a = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, zone: 18, hemisphere: 'N')
|
|
161
|
+
b = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, zone: 18, hemisphere: 'N')
|
|
162
162
|
a == b
|
|
163
163
|
# => true
|
|
164
164
|
```
|
|
@@ -168,8 +168,8 @@ a == b
|
|
|
168
168
|
Computes the Vincenty great-circle distance to one or more other coordinates. Works across UTM zones and across different coordinate types (coordinates are converted to LLA internally). Returns a `Distance` for a single target or an Array of `Distance` objects for multiple targets (radial distances from the receiver).
|
|
169
169
|
|
|
170
170
|
```ruby
|
|
171
|
-
a = Geodetic::
|
|
172
|
-
b = Geodetic::
|
|
171
|
+
a = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, altitude: 10.0, zone: 18, hemisphere: 'N')
|
|
172
|
+
b = Geodetic::Coordinate::UTM.new(easting: 580100.0, northing: 4510200.0, altitude: 15.0, zone: 18, hemisphere: 'N')
|
|
173
173
|
a.distance_to(b)
|
|
174
174
|
# => Distance (meters, great-circle distance)
|
|
175
175
|
```
|
|
@@ -188,8 +188,8 @@ a.straight_line_distance_to(b)
|
|
|
188
188
|
Returns `true` if both UTM instances share the same zone number and hemisphere.
|
|
189
189
|
|
|
190
190
|
```ruby
|
|
191
|
-
a = Geodetic::
|
|
192
|
-
b = Geodetic::
|
|
191
|
+
a = Geodetic::Coordinate::UTM.new(easting: 580000.0, northing: 4510000.0, zone: 18, hemisphere: 'N')
|
|
192
|
+
b = Geodetic::Coordinate::UTM.new(easting: 590000.0, northing: 4520000.0, zone: 18, hemisphere: 'N')
|
|
193
193
|
a.same_zone?(b)
|
|
194
194
|
# => true
|
|
195
195
|
```
|
|
@@ -201,7 +201,7 @@ Raises `ArgumentError` if `other` is not a `UTM`.
|
|
|
201
201
|
Returns the central meridian longitude (in degrees) for the UTM zone.
|
|
202
202
|
|
|
203
203
|
```ruby
|
|
204
|
-
utm = Geodetic::
|
|
204
|
+
utm = Geodetic::Coordinate::UTM.new(zone: 18, hemisphere: 'N')
|
|
205
205
|
utm.central_meridian
|
|
206
206
|
# => -75
|
|
207
207
|
```
|
|
@@ -216,7 +216,7 @@ The formula is: `(zone - 1) * 6 - 180 + 3`.
|
|
|
216
216
|
require 'geodetic'
|
|
217
217
|
|
|
218
218
|
# Start with an LLA and convert to UTM
|
|
219
|
-
lla = Geodetic::
|
|
219
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 40.7128, lng: -74.0060, alt: 10.0)
|
|
220
220
|
utm = lla.to_utm
|
|
221
221
|
puts utm.to_s
|
|
222
222
|
# zone and hemisphere are determined automatically
|
|
@@ -228,11 +228,11 @@ lla_roundtrip = utm.to_lla
|
|
|
228
228
|
### Distance calculations
|
|
229
229
|
|
|
230
230
|
```ruby
|
|
231
|
-
point_a = Geodetic::
|
|
231
|
+
point_a = Geodetic::Coordinate::UTM.new(
|
|
232
232
|
easting: 583960.0, northing: 4507523.0,
|
|
233
233
|
altitude: 10.0, zone: 18, hemisphere: 'N'
|
|
234
234
|
)
|
|
235
|
-
point_b = Geodetic::
|
|
235
|
+
point_b = Geodetic::Coordinate::UTM.new(
|
|
236
236
|
easting: 584060.0, northing: 4507623.0,
|
|
237
237
|
altitude: 15.0, zone: 18, hemisphere: 'N'
|
|
238
238
|
)
|
|
@@ -250,7 +250,7 @@ puts "Same zone? #{point_a.same_zone?(point_b)}"
|
|
|
250
250
|
|
|
251
251
|
```ruby
|
|
252
252
|
# Check which zone a location falls in
|
|
253
|
-
lla = Geodetic::
|
|
253
|
+
lla = Geodetic::Coordinate::LLA.new(lat: 48.8566, lng: 2.3522, alt: 35.0) # Paris
|
|
254
254
|
utm = lla.to_utm
|
|
255
255
|
puts "Zone: #{utm.zone}#{utm.hemisphere}" # => "31N"
|
|
256
256
|
puts "Central meridian: #{utm.central_meridian}" # => 3
|