geodetic 0.2.0 → 0.3.1
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 +30 -0
- data/README.md +83 -28
- data/docs/coordinate-systems/gars.md +0 -4
- data/docs/coordinate-systems/georef.md +0 -4
- data/docs/coordinate-systems/gh.md +0 -4
- data/docs/coordinate-systems/gh36.md +0 -4
- data/docs/coordinate-systems/h3.md +308 -0
- data/docs/coordinate-systems/ham.md +0 -4
- data/docs/coordinate-systems/index.md +25 -23
- data/docs/coordinate-systems/olc.md +0 -4
- data/docs/index.md +7 -3
- data/docs/reference/conversions.md +15 -15
- data/docs/reference/feature.md +116 -0
- data/docs/reference/map-rendering.md +32 -0
- data/docs/reference/serialization.md +4 -4
- data/examples/02_all_coordinate_systems.rb +0 -3
- data/examples/03_distance_calculations.rb +1 -0
- data/examples/04_bearing_calculations.rb +1 -0
- data/examples/05_map_rendering/.gitignore +2 -0
- data/examples/05_map_rendering/demo.rb +264 -0
- data/examples/05_map_rendering/icons/bridge.png +0 -0
- data/examples/05_map_rendering/icons/building.png +0 -0
- data/examples/05_map_rendering/icons/landmark.png +0 -0
- data/examples/05_map_rendering/icons/monument.png +0 -0
- data/examples/05_map_rendering/icons/park.png +0 -0
- data/examples/05_map_rendering/nyc_landmarks.png +0 -0
- data/examples/README.md +62 -0
- data/fiddle_pointer_buffer_pool.md +119 -0
- data/lib/geodetic/coordinate/bng.rb +14 -33
- data/lib/geodetic/coordinate/ecef.rb +5 -1
- data/lib/geodetic/coordinate/enu.rb +13 -0
- data/lib/geodetic/coordinate/gars.rb +2 -3
- data/lib/geodetic/coordinate/georef.rb +2 -3
- data/lib/geodetic/coordinate/gh.rb +2 -4
- data/lib/geodetic/coordinate/gh36.rb +4 -5
- data/lib/geodetic/coordinate/h3.rb +412 -0
- data/lib/geodetic/coordinate/ham.rb +2 -3
- data/lib/geodetic/coordinate/lla.rb +15 -1
- data/lib/geodetic/coordinate/mgrs.rb +1 -1
- data/lib/geodetic/coordinate/ned.rb +13 -0
- data/lib/geodetic/coordinate/olc.rb +0 -1
- data/lib/geodetic/coordinate/spatial_hash.rb +2 -2
- data/lib/geodetic/coordinate/state_plane.rb +9 -0
- data/lib/geodetic/coordinate/ups.rb +1 -1
- data/lib/geodetic/coordinate/usng.rb +1 -1
- data/lib/geodetic/coordinate/utm.rb +1 -1
- data/lib/geodetic/coordinate/web_mercator.rb +1 -1
- data/lib/geodetic/coordinate.rb +31 -26
- data/lib/geodetic/feature.rb +44 -0
- data/lib/geodetic/geoid_height.rb +11 -6
- data/lib/geodetic/version.rb +1 -1
- data/lib/geodetic.rb +1 -0
- data/mkdocs.yml +2 -0
- metadata +20 -5
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Geodetic
|
|
4
|
+
class Feature
|
|
5
|
+
attr_accessor :label, :geometry, :metadata
|
|
6
|
+
|
|
7
|
+
def initialize(label:, geometry:, metadata: {})
|
|
8
|
+
@label = label
|
|
9
|
+
@geometry = geometry
|
|
10
|
+
@metadata = metadata
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def distance_to(other)
|
|
14
|
+
resolve_point.distance_to(resolve_point_from(other))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def bearing_to(other)
|
|
18
|
+
resolve_point.bearing_to(resolve_point_from(other))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_s
|
|
22
|
+
"#{@label} (#{@geometry})"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def inspect
|
|
26
|
+
"#<Geodetic::Feature name=#{@label.inspect} geometry=#{@geometry.inspect} metadata=#{@metadata.inspect}>"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def resolve_point
|
|
32
|
+
@geometry.respond_to?(:centroid) ? @geometry.centroid : @geometry
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def resolve_point_from(other)
|
|
36
|
+
case other
|
|
37
|
+
when Feature
|
|
38
|
+
other.send(:resolve_point)
|
|
39
|
+
else
|
|
40
|
+
other.respond_to?(:centroid) ? other.centroid : other
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -107,14 +107,14 @@ module Geodetic
|
|
|
107
107
|
raise ArgumentError, "Unknown vertical datum: #{to_datum}" unless to_info
|
|
108
108
|
|
|
109
109
|
if from_info[:type] == 'orthometric'
|
|
110
|
-
geoid_model = GeoidHeight.
|
|
110
|
+
geoid_model = GeoidHeight.for(from_info[:reference_geoid])
|
|
111
111
|
ellipsoidal_height = geoid_model.orthometric_to_ellipsoidal(lat, lng, height)
|
|
112
112
|
else
|
|
113
113
|
ellipsoidal_height = height
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
if to_info[:type] == 'orthometric'
|
|
117
|
-
geoid_model = GeoidHeight.
|
|
117
|
+
geoid_model = GeoidHeight.for(to_info[:reference_geoid])
|
|
118
118
|
geoid_model.ellipsoidal_to_orthometric(lat, lng, ellipsoidal_height)
|
|
119
119
|
else
|
|
120
120
|
ellipsoidal_height
|
|
@@ -175,6 +175,11 @@ module Geodetic
|
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
+
def self.for(geoid_model = 'EGM2008')
|
|
179
|
+
@instances ||= {}
|
|
180
|
+
@instances[geoid_model] ||= new(geoid_model: geoid_model)
|
|
181
|
+
end
|
|
182
|
+
|
|
178
183
|
def self.available_models
|
|
179
184
|
GEOID_MODELS.keys
|
|
180
185
|
end
|
|
@@ -271,7 +276,7 @@ module Geodetic
|
|
|
271
276
|
def convert_height_datum(from_datum, to_datum, geoid_model = 'EGM2008')
|
|
272
277
|
return self unless respond_to?(:lat) && respond_to?(:lng) && respond_to?(:alt)
|
|
273
278
|
|
|
274
|
-
geoid = GeoidHeight.
|
|
279
|
+
geoid = GeoidHeight.for(geoid_model)
|
|
275
280
|
new_height = geoid.convert_vertical_datum(self.lat, self.lng, self.alt, from_datum, to_datum)
|
|
276
281
|
|
|
277
282
|
self.class.new(lat: self.lat, lng: self.lng, alt: new_height)
|
|
@@ -280,19 +285,19 @@ module Geodetic
|
|
|
280
285
|
def geoid_height(geoid_model = 'EGM2008')
|
|
281
286
|
return nil unless respond_to?(:lat) && respond_to?(:lng)
|
|
282
287
|
|
|
283
|
-
geoid = GeoidHeight.
|
|
288
|
+
geoid = GeoidHeight.for(geoid_model)
|
|
284
289
|
geoid.geoid_height_at(self.lat, self.lng)
|
|
285
290
|
end
|
|
286
291
|
|
|
287
292
|
def orthometric_height(geoid_model = 'EGM2008')
|
|
288
293
|
return nil unless respond_to?(:alt) && respond_to?(:lat) && respond_to?(:lng)
|
|
289
294
|
|
|
290
|
-
geoid = GeoidHeight.
|
|
295
|
+
geoid = GeoidHeight.for(geoid_model)
|
|
291
296
|
geoid.ellipsoidal_to_orthometric(self.lat, self.lng, self.alt)
|
|
292
297
|
end
|
|
293
298
|
|
|
294
299
|
def self.from_orthometric_height(lat, lng, orthometric_height, geoid_model = 'EGM2008')
|
|
295
|
-
geoid = GeoidHeight.
|
|
300
|
+
geoid = GeoidHeight.for(geoid_model)
|
|
296
301
|
geoid.orthometric_to_ellipsoidal(lat, lng, orthometric_height)
|
|
297
302
|
end
|
|
298
303
|
end
|
data/lib/geodetic/version.rb
CHANGED
data/lib/geodetic.rb
CHANGED
data/mkdocs.yml
CHANGED
|
@@ -136,5 +136,7 @@ nav:
|
|
|
136
136
|
- Datums: reference/datums.md
|
|
137
137
|
- Geoid Height: reference/geoid-height.md
|
|
138
138
|
- Areas: reference/areas.md
|
|
139
|
+
- Feature: reference/feature.md
|
|
139
140
|
- Serialization: reference/serialization.md
|
|
140
141
|
- Conversions: reference/conversions.md
|
|
142
|
+
- Map Rendering: reference/map-rendering.md
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: geodetic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dewayne VanHoozer
|
|
@@ -9,11 +9,11 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description: A Ruby gem for converting between
|
|
12
|
+
description: A Ruby gem for converting between 18 geodetic coordinate systems (LLA,
|
|
13
13
|
ECEF, UTM, ENU, NED, MGRS, USNG, Web Mercator, UPS, State Plane, BNG, GH36, GH,
|
|
14
|
-
HAM, OLC, GEOREF, GARS) with Vincenty great-circle and ECEF Euclidean distance
|
|
15
|
-
unit-aware Distance and Bearing classes, geoid height support, and
|
|
16
|
-
operations.
|
|
14
|
+
HAM, OLC, GEOREF, GARS, H3) with Vincenty great-circle and ECEF Euclidean distance
|
|
15
|
+
calculations, unit-aware Distance and Bearing classes, geoid height support, and
|
|
16
|
+
geographic area operations.
|
|
17
17
|
email:
|
|
18
18
|
- dewayne@vanhoozer.me
|
|
19
19
|
executables: []
|
|
@@ -35,6 +35,7 @@ files:
|
|
|
35
35
|
- docs/coordinate-systems/georef.md
|
|
36
36
|
- docs/coordinate-systems/gh.md
|
|
37
37
|
- docs/coordinate-systems/gh36.md
|
|
38
|
+
- docs/coordinate-systems/h3.md
|
|
38
39
|
- docs/coordinate-systems/ham.md
|
|
39
40
|
- docs/coordinate-systems/index.md
|
|
40
41
|
- docs/coordinate-systems/lla.md
|
|
@@ -52,12 +53,24 @@ files:
|
|
|
52
53
|
- docs/reference/areas.md
|
|
53
54
|
- docs/reference/conversions.md
|
|
54
55
|
- docs/reference/datums.md
|
|
56
|
+
- docs/reference/feature.md
|
|
55
57
|
- docs/reference/geoid-height.md
|
|
58
|
+
- docs/reference/map-rendering.md
|
|
56
59
|
- docs/reference/serialization.md
|
|
57
60
|
- examples/01_basic_conversions.rb
|
|
58
61
|
- examples/02_all_coordinate_systems.rb
|
|
59
62
|
- examples/03_distance_calculations.rb
|
|
60
63
|
- examples/04_bearing_calculations.rb
|
|
64
|
+
- examples/05_map_rendering/.gitignore
|
|
65
|
+
- examples/05_map_rendering/demo.rb
|
|
66
|
+
- examples/05_map_rendering/icons/bridge.png
|
|
67
|
+
- examples/05_map_rendering/icons/building.png
|
|
68
|
+
- examples/05_map_rendering/icons/landmark.png
|
|
69
|
+
- examples/05_map_rendering/icons/monument.png
|
|
70
|
+
- examples/05_map_rendering/icons/park.png
|
|
71
|
+
- examples/05_map_rendering/nyc_landmarks.png
|
|
72
|
+
- examples/README.md
|
|
73
|
+
- fiddle_pointer_buffer_pool.md
|
|
61
74
|
- lib/geodetic.rb
|
|
62
75
|
- lib/geodetic/areas.rb
|
|
63
76
|
- lib/geodetic/areas/circle.rb
|
|
@@ -72,6 +85,7 @@ files:
|
|
|
72
85
|
- lib/geodetic/coordinate/georef.rb
|
|
73
86
|
- lib/geodetic/coordinate/gh.rb
|
|
74
87
|
- lib/geodetic/coordinate/gh36.rb
|
|
88
|
+
- lib/geodetic/coordinate/h3.rb
|
|
75
89
|
- lib/geodetic/coordinate/ham.rb
|
|
76
90
|
- lib/geodetic/coordinate/lla.rb
|
|
77
91
|
- lib/geodetic/coordinate/mgrs.rb
|
|
@@ -85,6 +99,7 @@ files:
|
|
|
85
99
|
- lib/geodetic/coordinate/web_mercator.rb
|
|
86
100
|
- lib/geodetic/datum.rb
|
|
87
101
|
- lib/geodetic/distance.rb
|
|
102
|
+
- lib/geodetic/feature.rb
|
|
88
103
|
- lib/geodetic/geoid_height.rb
|
|
89
104
|
- lib/geodetic/version.rb
|
|
90
105
|
- mkdocs.yml
|