gpx 0.9.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +36 -0
  3. data/.gitignore +4 -0
  4. data/.rubocop.yml +162 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +6 -5
  7. data/CHANGELOG.md +15 -0
  8. data/Gemfile +2 -0
  9. data/LICENSE.txt +1 -1
  10. data/README.md +20 -5
  11. data/Rakefile +22 -12
  12. data/bin/gpx_distance +5 -6
  13. data/bin/gpx_smooth +25 -26
  14. data/gpx.gemspec +13 -12
  15. data/lib/gpx/bounds.rb +13 -31
  16. data/lib/gpx/geo_json.rb +199 -0
  17. data/lib/gpx/gpx.rb +4 -26
  18. data/lib/gpx/gpx_file.rb +140 -134
  19. data/lib/gpx/magellan_track_log.rb +34 -66
  20. data/lib/gpx/point.rb +22 -35
  21. data/lib/gpx/route.rb +10 -31
  22. data/lib/gpx/segment.rb +63 -90
  23. data/lib/gpx/track.rb +38 -42
  24. data/lib/gpx/track_point.rb +32 -0
  25. data/lib/gpx/version.rb +3 -1
  26. data/lib/gpx/waypoint.rb +10 -34
  27. data/lib/gpx.rb +13 -34
  28. data/tests/geojson_files/combined_data.json +68 -0
  29. data/tests/geojson_files/line_string_data.json +83 -0
  30. data/tests/geojson_files/multi_line_string_data.json +74 -0
  31. data/tests/geojson_files/multi_point_data.json +14 -0
  32. data/tests/geojson_files/point_data.json +22 -0
  33. data/tests/geojson_test.rb +92 -0
  34. data/tests/gpx10_test.rb +7 -6
  35. data/tests/gpx_file_test.rb +31 -19
  36. data/tests/gpx_files/one_segment_mixed_times.gpx +884 -0
  37. data/tests/gpx_files/routes_without_names.gpx +29 -0
  38. data/tests/gpx_files/with_empty_tracks.gpx +72 -0
  39. data/tests/magellan_test.rb +12 -11
  40. data/tests/output_test.rb +93 -94
  41. data/tests/route_test.rb +75 -30
  42. data/tests/segment_test.rb +104 -93
  43. data/tests/track_file_test.rb +50 -70
  44. data/tests/track_point_test.rb +22 -11
  45. data/tests/track_test.rb +73 -61
  46. data/tests/waypoint_test.rb +46 -48
  47. metadata +47 -18
  48. 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.9.0
4
+ version: 1.1.0
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-19 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,21 +41,21 @@ 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
- version: '1.7'
36
- type: :runtime
49
+ version: '0'
50
+ type: :development
37
51
  prerelease: false
38
52
  version_requirements: !ruby/object:Gem::Requirement
39
53
  requirements:
40
- - - "~>"
54
+ - - ">="
41
55
  - !ruby/object:Gem::Version
42
- version: '1.7'
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,7 +91,10 @@ executables: []
77
91
  extensions: []
78
92
  extra_rdoc_files: []
79
93
  files:
94
+ - ".github/workflows/ruby.yml"
80
95
  - ".gitignore"
96
+ - ".rubocop.yml"
97
+ - ".ruby-version"
81
98
  - ".travis.yml"
82
99
  - CHANGELOG.md
83
100
  - Gemfile
@@ -89,6 +106,7 @@ files:
89
106
  - gpx.gemspec
90
107
  - lib/gpx.rb
91
108
  - lib/gpx/bounds.rb
109
+ - lib/gpx/geo_json.rb
92
110
  - lib/gpx/gpx.rb
93
111
  - lib/gpx/gpx_file.rb
94
112
  - lib/gpx/magellan_track_log.rb
@@ -96,9 +114,15 @@ files:
96
114
  - lib/gpx/route.rb
97
115
  - lib/gpx/segment.rb
98
116
  - lib/gpx/track.rb
99
- - lib/gpx/trackpoint.rb
117
+ - lib/gpx/track_point.rb
100
118
  - lib/gpx/version.rb
101
119
  - lib/gpx/waypoint.rb
120
+ - tests/geojson_files/combined_data.json
121
+ - tests/geojson_files/line_string_data.json
122
+ - tests/geojson_files/multi_line_string_data.json
123
+ - tests/geojson_files/multi_point_data.json
124
+ - tests/geojson_files/point_data.json
125
+ - tests/geojson_test.rb
102
126
  - tests/gpx10_test.rb
103
127
  - tests/gpx_file_test.rb
104
128
  - tests/gpx_files/arches.gpx
@@ -106,11 +130,14 @@ files:
106
130
  - tests/gpx_files/gpx10.gpx
107
131
  - tests/gpx_files/magellan_track.log
108
132
  - tests/gpx_files/one_segment.gpx
133
+ - tests/gpx_files/one_segment_mixed_times.gpx
109
134
  - tests/gpx_files/one_segment_no_time.gpx
110
135
  - tests/gpx_files/one_track.gpx
111
136
  - tests/gpx_files/routes.gpx
137
+ - tests/gpx_files/routes_without_names.gpx
112
138
  - tests/gpx_files/tracks.gpx
113
139
  - tests/gpx_files/waypoints.gpx
140
+ - tests/gpx_files/with_empty_tracks.gpx
114
141
  - tests/gpx_files/with_or_without_elev.gpx
115
142
  - tests/magellan_test.rb
116
143
  - tests/output_test.rb
@@ -123,24 +150,26 @@ files:
123
150
  homepage: http://www.github.com/dougfales/gpx
124
151
  licenses: []
125
152
  metadata: {}
126
- post_install_message:
153
+ post_install_message:
127
154
  rdoc_options: []
128
155
  require_paths:
129
156
  - lib
130
157
  required_ruby_version: !ruby/object:Gem::Requirement
131
158
  requirements:
132
- - - "~>"
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '2.5'
162
+ - - "<"
133
163
  - !ruby/object:Gem::Version
134
- version: '2.1'
164
+ version: '4'
135
165
  required_rubygems_version: !ruby/object:Gem::Requirement
136
166
  requirements:
137
167
  - - ">="
138
168
  - !ruby/object:Gem::Version
139
169
  version: '0'
140
170
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.4.8
143
- signing_key:
171
+ rubygems_version: 3.2.22
172
+ signing_key:
144
173
  specification_version: 4
145
174
  summary: A basic API for reading and writing GPX files.
146
175
  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