gpx 0.8.3 → 1.1.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 +5 -5
- data/.github/workflows/ruby.yml +37 -0
- data/.gitignore +4 -0
- data/.rubocop +1 -0
- data/.rubocop.yml +162 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/.travis.yml +4 -6
- data/CHANGELOG.md +32 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +38 -17
- data/Rakefile +22 -12
- data/UPGRADING.md +7 -0
- data/bin/gpx_distance +5 -6
- data/bin/gpx_smooth +25 -26
- data/gpx.gemspec +14 -11
- data/lib/gpx/bounds.rb +13 -31
- data/lib/gpx/geo_json.rb +199 -0
- data/lib/gpx/gpx.rb +4 -26
- data/lib/gpx/gpx_file.rb +140 -134
- data/lib/gpx/magellan_track_log.rb +34 -66
- data/lib/gpx/point.rb +22 -35
- data/lib/gpx/route.rb +10 -31
- data/lib/gpx/segment.rb +63 -90
- data/lib/gpx/track.rb +38 -42
- data/lib/gpx/track_point.rb +32 -0
- data/lib/gpx/version.rb +3 -1
- data/lib/gpx/waypoint.rb +10 -34
- data/lib/gpx.rb +13 -34
- data/tests/geojson_files/combined_data.json +68 -0
- data/tests/geojson_files/line_string_data.json +83 -0
- data/tests/geojson_files/multi_line_string_data.json +74 -0
- data/tests/geojson_files/multi_point_data.json +14 -0
- data/tests/geojson_files/point_data.json +22 -0
- data/tests/geojson_test.rb +92 -0
- data/tests/gpx10_test.rb +7 -6
- data/tests/gpx_file_test.rb +31 -19
- data/tests/gpx_files/one_segment_mixed_times.gpx +884 -0
- data/tests/gpx_files/routes_without_names.gpx +29 -0
- data/tests/gpx_files/with_empty_tracks.gpx +72 -0
- data/tests/magellan_test.rb +12 -11
- data/tests/output_test.rb +93 -94
- data/tests/route_test.rb +75 -30
- data/tests/segment_test.rb +104 -93
- data/tests/track_file_test.rb +50 -70
- data/tests/track_point_test.rb +22 -11
- data/tests/track_test.rb +73 -61
- data/tests/waypoint_test.rb +46 -48
- metadata +45 -13
- data/lib/gpx/trackpoint.rb +0 -60
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Dott
|
8
8
|
- Doug Fales
|
9
9
|
- Andrew Hao
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.7'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.7'
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: rake
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -27,13 +41,13 @@ dependencies:
|
|
27
41
|
- !ruby/object:Gem::Version
|
28
42
|
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
44
|
+
name: bundler
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
47
|
- - ">="
|
34
48
|
- !ruby/object:Gem::Version
|
35
49
|
version: '0'
|
36
|
-
type: :
|
50
|
+
type: :development
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
@@ -41,7 +55,7 @@ dependencies:
|
|
41
55
|
- !ruby/object:Gem::Version
|
42
56
|
version: '0'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
58
|
+
name: minitest
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
61
|
- - ">="
|
@@ -55,7 +69,7 @@ dependencies:
|
|
55
69
|
- !ruby/object:Gem::Version
|
56
70
|
version: '0'
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
72
|
+
name: rubocop
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
60
74
|
requirements:
|
61
75
|
- - ">="
|
@@ -77,18 +91,25 @@ executables: []
|
|
77
91
|
extensions: []
|
78
92
|
extra_rdoc_files: []
|
79
93
|
files:
|
94
|
+
- ".github/workflows/ruby.yml"
|
80
95
|
- ".gitignore"
|
96
|
+
- ".rubocop"
|
97
|
+
- ".rubocop.yml"
|
98
|
+
- ".ruby-version"
|
99
|
+
- ".tool-versions"
|
81
100
|
- ".travis.yml"
|
82
101
|
- CHANGELOG.md
|
83
102
|
- Gemfile
|
84
103
|
- LICENSE.txt
|
85
104
|
- README.md
|
86
105
|
- Rakefile
|
106
|
+
- UPGRADING.md
|
87
107
|
- bin/gpx_distance
|
88
108
|
- bin/gpx_smooth
|
89
109
|
- gpx.gemspec
|
90
110
|
- lib/gpx.rb
|
91
111
|
- lib/gpx/bounds.rb
|
112
|
+
- lib/gpx/geo_json.rb
|
92
113
|
- lib/gpx/gpx.rb
|
93
114
|
- lib/gpx/gpx_file.rb
|
94
115
|
- lib/gpx/magellan_track_log.rb
|
@@ -96,9 +117,15 @@ files:
|
|
96
117
|
- lib/gpx/route.rb
|
97
118
|
- lib/gpx/segment.rb
|
98
119
|
- lib/gpx/track.rb
|
99
|
-
- lib/gpx/
|
120
|
+
- lib/gpx/track_point.rb
|
100
121
|
- lib/gpx/version.rb
|
101
122
|
- lib/gpx/waypoint.rb
|
123
|
+
- tests/geojson_files/combined_data.json
|
124
|
+
- tests/geojson_files/line_string_data.json
|
125
|
+
- tests/geojson_files/multi_line_string_data.json
|
126
|
+
- tests/geojson_files/multi_point_data.json
|
127
|
+
- tests/geojson_files/point_data.json
|
128
|
+
- tests/geojson_test.rb
|
102
129
|
- tests/gpx10_test.rb
|
103
130
|
- tests/gpx_file_test.rb
|
104
131
|
- tests/gpx_files/arches.gpx
|
@@ -106,11 +133,14 @@ files:
|
|
106
133
|
- tests/gpx_files/gpx10.gpx
|
107
134
|
- tests/gpx_files/magellan_track.log
|
108
135
|
- tests/gpx_files/one_segment.gpx
|
136
|
+
- tests/gpx_files/one_segment_mixed_times.gpx
|
109
137
|
- tests/gpx_files/one_segment_no_time.gpx
|
110
138
|
- tests/gpx_files/one_track.gpx
|
111
139
|
- tests/gpx_files/routes.gpx
|
140
|
+
- tests/gpx_files/routes_without_names.gpx
|
112
141
|
- tests/gpx_files/tracks.gpx
|
113
142
|
- tests/gpx_files/waypoints.gpx
|
143
|
+
- tests/gpx_files/with_empty_tracks.gpx
|
114
144
|
- tests/gpx_files/with_or_without_elev.gpx
|
115
145
|
- tests/magellan_test.rb
|
116
146
|
- tests/output_test.rb
|
@@ -123,7 +153,7 @@ files:
|
|
123
153
|
homepage: http://www.github.com/dougfales/gpx
|
124
154
|
licenses: []
|
125
155
|
metadata: {}
|
126
|
-
post_install_message:
|
156
|
+
post_install_message:
|
127
157
|
rdoc_options: []
|
128
158
|
require_paths:
|
129
159
|
- lib
|
@@ -131,16 +161,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
161
|
requirements:
|
132
162
|
- - ">="
|
133
163
|
- !ruby/object:Gem::Version
|
134
|
-
version: '
|
164
|
+
version: '2.7'
|
165
|
+
- - "<"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '4'
|
135
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
169
|
requirements:
|
137
170
|
- - ">="
|
138
171
|
- !ruby/object:Gem::Version
|
139
172
|
version: '0'
|
140
173
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
174
|
+
rubygems_version: 3.4.10
|
175
|
+
signing_key:
|
144
176
|
specification_version: 4
|
145
177
|
summary: A basic API for reading and writing GPX files.
|
146
178
|
test_files: []
|
data/lib/gpx/trackpoint.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006 Doug Fales
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
module GPX
|
24
|
-
# Basically the same as a point, the TrackPoint class is supposed to
|
25
|
-
# represent the points that are children of Segment elements. So, the only
|
26
|
-
# real difference is that TrackPoints hold a reference to their parent
|
27
|
-
# Segments.
|
28
|
-
class TrackPoint < Point
|
29
|
-
RADIUS = 6371; # earth's mean radius in km
|
30
|
-
|
31
|
-
attr_accessor :segment
|
32
|
-
|
33
|
-
|
34
|
-
def initialize(opts = {})
|
35
|
-
super(opts)
|
36
|
-
@segment = opts[:segment]
|
37
|
-
end
|
38
|
-
|
39
|
-
# Units are in km
|
40
|
-
def haversine_distance_from(p2)
|
41
|
-
d_lat = p2.latr - latr;
|
42
|
-
d_lon = p2.lonr - lonr;
|
43
|
-
a = Math.sin(d_lat/2) * Math.sin(d_lat/2) + Math.cos(latr) * Math.cos(p2.latr) * Math.sin(d_lon/2) * Math.sin(d_lon/2);
|
44
|
-
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
45
|
-
d = RADIUS * c;
|
46
|
-
return d;
|
47
|
-
end
|
48
|
-
|
49
|
-
# Units are in km
|
50
|
-
def pythagorean_distance_from(p2)
|
51
|
-
Math.sqrt((p2.latr - latr)**2 + (p2.lonr - lonr)**2)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Units are in km
|
55
|
-
def law_of_cosines_distance_from(p2)
|
56
|
-
(Math.acos(Math.sin(latr)*Math.sin(p2.latr) + Math.cos(latr)*Math.cos(p2.latr)*Math.cos(p2.lonr-lonr)) * RADIUS)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|