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.
Files changed (51) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +37 -0
  3. data/.gitignore +4 -0
  4. data/.rubocop +1 -0
  5. data/.rubocop.yml +162 -0
  6. data/.ruby-version +1 -0
  7. data/.tool-versions +1 -0
  8. data/.travis.yml +4 -6
  9. data/CHANGELOG.md +32 -0
  10. data/Gemfile +2 -0
  11. data/LICENSE.txt +1 -1
  12. data/README.md +38 -17
  13. data/Rakefile +22 -12
  14. data/UPGRADING.md +7 -0
  15. data/bin/gpx_distance +5 -6
  16. data/bin/gpx_smooth +25 -26
  17. data/gpx.gemspec +14 -11
  18. data/lib/gpx/bounds.rb +13 -31
  19. data/lib/gpx/geo_json.rb +199 -0
  20. data/lib/gpx/gpx.rb +4 -26
  21. data/lib/gpx/gpx_file.rb +140 -134
  22. data/lib/gpx/magellan_track_log.rb +34 -66
  23. data/lib/gpx/point.rb +22 -35
  24. data/lib/gpx/route.rb +10 -31
  25. data/lib/gpx/segment.rb +63 -90
  26. data/lib/gpx/track.rb +38 -42
  27. data/lib/gpx/track_point.rb +32 -0
  28. data/lib/gpx/version.rb +3 -1
  29. data/lib/gpx/waypoint.rb +10 -34
  30. data/lib/gpx.rb +13 -34
  31. data/tests/geojson_files/combined_data.json +68 -0
  32. data/tests/geojson_files/line_string_data.json +83 -0
  33. data/tests/geojson_files/multi_line_string_data.json +74 -0
  34. data/tests/geojson_files/multi_point_data.json +14 -0
  35. data/tests/geojson_files/point_data.json +22 -0
  36. data/tests/geojson_test.rb +92 -0
  37. data/tests/gpx10_test.rb +7 -6
  38. data/tests/gpx_file_test.rb +31 -19
  39. data/tests/gpx_files/one_segment_mixed_times.gpx +884 -0
  40. data/tests/gpx_files/routes_without_names.gpx +29 -0
  41. data/tests/gpx_files/with_empty_tracks.gpx +72 -0
  42. data/tests/magellan_test.rb +12 -11
  43. data/tests/output_test.rb +93 -94
  44. data/tests/route_test.rb +75 -30
  45. data/tests/segment_test.rb +104 -93
  46. data/tests/track_file_test.rb +50 -70
  47. data/tests/track_point_test.rb +22 -11
  48. data/tests/track_test.rb +73 -61
  49. data/tests/waypoint_test.rb +46 -48
  50. metadata +45 -13
  51. 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: 0.8.3
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: 2017-01-05 00:00:00.000000000 Z
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: nokogiri
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: :runtime
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: bundler
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: minitest
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/trackpoint.rb
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: '0'
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
- rubyforge_project:
142
- rubygems_version: 2.4.8
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: []
@@ -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