gpx 1.0.0 → 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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +37 -0
  3. data/.rubocop +1 -0
  4. data/.rubocop.yml +2 -5
  5. data/.ruby-version +1 -0
  6. data/.tool-versions +1 -0
  7. data/.travis.yml +4 -5
  8. data/CHANGELOG.md +14 -0
  9. data/Gemfile +2 -0
  10. data/README.md +21 -5
  11. data/Rakefile +7 -0
  12. data/UPGRADING.md +7 -0
  13. data/bin/gpx_distance +2 -0
  14. data/bin/gpx_smooth +5 -2
  15. data/gpx.gemspec +2 -2
  16. data/lib/gpx/bounds.rb +3 -0
  17. data/lib/gpx/geo_json.rb +199 -0
  18. data/lib/gpx/gpx.rb +2 -0
  19. data/lib/gpx/gpx_file.rb +53 -51
  20. data/lib/gpx/magellan_track_log.rb +3 -1
  21. data/lib/gpx/point.rb +5 -1
  22. data/lib/gpx/route.rb +4 -1
  23. data/lib/gpx/segment.rb +14 -9
  24. data/lib/gpx/track.rb +11 -4
  25. data/lib/gpx/track_point.rb +2 -0
  26. data/lib/gpx/version.rb +3 -1
  27. data/lib/gpx/waypoint.rb +3 -0
  28. data/lib/gpx.rb +3 -1
  29. data/tests/geojson_files/combined_data.json +68 -0
  30. data/tests/geojson_files/line_string_data.json +83 -0
  31. data/tests/geojson_files/multi_line_string_data.json +74 -0
  32. data/tests/geojson_files/multi_point_data.json +14 -0
  33. data/tests/geojson_files/point_data.json +22 -0
  34. data/tests/geojson_test.rb +92 -0
  35. data/tests/gpx10_test.rb +2 -0
  36. data/tests/gpx_file_test.rb +2 -0
  37. data/tests/gpx_files/one_segment_mixed_times.gpx +884 -0
  38. data/tests/gpx_files/routes_without_names.gpx +29 -0
  39. data/tests/magellan_test.rb +2 -0
  40. data/tests/output_test.rb +3 -1
  41. data/tests/route_test.rb +52 -0
  42. data/tests/segment_test.rb +13 -1
  43. data/tests/track_file_test.rb +3 -0
  44. data/tests/track_point_test.rb +2 -0
  45. data/tests/track_test.rb +2 -0
  46. data/tests/waypoint_test.rb +2 -0
  47. metadata +25 -9
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Link2GPS - 2.0.2 - http://www.hiketech.com" xsi:schemaLocation="ttp://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
3
+ <metadata>
4
+ <name><![CDATA[routes.gpx]]></name>
5
+ <time>2006-01-02T08:55:34Z</time>
6
+ <bounds min_lat="39.989739" min_lon="-105.295285" max_lat="39.999840" max_lon="-105.214696"/>
7
+ </metadata>
8
+ <extensions/>
9
+ <rte>
10
+ <rtept lat="39.997298" lon="-105.292674">
11
+ <sym>Waypoint</sym>
12
+ <ele>1766.535</ele>
13
+ </rtept>
14
+ <rtept lat="39.995700" lon="-105.292805">
15
+ <sym>Waypoint</sym>
16
+ <ele>1854.735</ele>
17
+ </rtept>
18
+ <rtept lat="39.989739" lon="-105.295285">
19
+ <sym>Waypoint</sym>
20
+ <ele>2163.556</ele>
21
+ </rtept>
22
+ </rte>
23
+ <rte>
24
+ <rtept lat="39.999840" lon="-105.214696">
25
+ <sym>Waypoint</sym>
26
+ <ele>1612.965</ele>
27
+ </rtept>
28
+ </rte>
29
+ </gpx>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
data/tests/output_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'fileutils'
3
5
  require 'gpx'
@@ -109,5 +111,5 @@ class OutputTest < Minitest::Test
109
111
  File.join(File.dirname(__FILE__), "output/#{test_name}.gpx")
110
112
  end
111
113
 
112
- THE_WORKS = "<?xml version=\"1.0\"?>\n<gpx xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" version=\"1.1\" creator=\"GPX RubyGem #{GPX::VERSION} Copyright 2006-2009 Doug Fales -- http://gpx.rubyforge.org/\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n <metadata>\n <name>new_gpx_file_from_scratch.gpx</name>\n <time>%s</time>\n <bounds minlat=\"90.0\" minlon=\"180.0\" maxlat=\"-90.0\" maxlon=\"-180.0\"/>\n </metadata>\n <trk>\n <name/>\n <trkseg>\n <trkpt lat=\"40.036926\" lon=\"-105.253487\">\n <time>2005-12-31T22:01:24Z</time>\n <ele>1737.24</ele>\n </trkpt>\n <trkpt lat=\"40.036604\" lon=\"-105.253487\">\n <time>2005-12-31T22:02:01Z</time>\n <ele>1738.682</ele>\n </trkpt>\n <trkpt lat=\"40.036347\" lon=\"-105.25383\">\n <time>2005-12-31T22:02:08Z</time>\n <ele>1738.682</ele>\n </trkpt>\n <trkpt lat=\"40.035574\" lon=\"-105.254045\">\n <time>2005-12-31T22:02:20Z</time>\n <ele>1737.24</ele>\n </trkpt>\n <trkpt lat=\"40.035467\" lon=\"-105.254366\">\n <time>2005-12-31T22:02:29Z</time>\n <ele>1735.798</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254388\">\n <time>2005-12-31T22:02:33Z</time>\n <ele>1735.798</ele>\n </trkpt>\n <trkpt lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:49Z</time>\n <ele>1736.278</ele>\n </trkpt>\n <trkpt lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:54Z</time>\n <ele>1739.643</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254431\">\n <time>2005-12-31T22:05:08Z</time>\n <ele>1732.433</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254431\">\n <time>2005-12-31T22:05:09Z</time>\n <ele>1726.665</ele>\n </trkpt>\n </trkseg>\n </trk>\n <wpt lat=\"39.997298\" lon=\"-105.292674\">\n <name>GRG-CA</name>\n <sym>Waypoint</sym>\n <ele>1766.535</ele>\n </wpt>\n <wpt lat=\"33.33019\" lon=\"-111.94611\">\n <name>GRMPHX</name>\n <cmt>Hey here's a comment.</cmt>\n <desc>Somewhere in my backyard.</desc>\n <sym>Waypoint</sym>\n <fix>3d</fix>\n <sat>8</sat>\n <hdop>50.5</hdop>\n <vdop>6.8</vdop>\n <pdop>7.6</pdop>\n <ele>361.0981</ele>\n </wpt>\n <wpt lat=\"25.061783\" lon=\"121.640267\">\n <name>GRMTWN</name>\n <sym>Waypoint</sym>\n <ele>38.09766</ele>\n </wpt>\n <wpt lat=\"39.99984\" lon=\"-105.214696\">\n <name>SBDR</name>\n <sym>Waypoint</sym>\n <ele>1612.965</ele>\n </wpt>\n <wpt lat=\"39.989739\" lon=\"-105.295285\">\n <name>TO</name>\n <sym>Waypoint</sym>\n <ele>2163.556</ele>\n </wpt>\n <wpt lat=\"40.035301\" lon=\"-105.254443\">\n <name>VICS</name>\n <sym>Waypoint</sym>\n <ele>1535.34</ele>\n </wpt>\n <rte>\n <name/>\n <rtept lat=\"40.035467\" lon=\"-105.254366\">\n <time>2005-12-31T22:02:29Z</time>\n <ele>1735.798</ele>\n </rtept>\n <rtept lat=\"40.035317\" lon=\"-105.254388\">\n <time>2005-12-31T22:02:33Z</time>\n <ele>1735.798</ele>\n </rtept>\n <rtept lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:49Z</time>\n <ele>1736.278</ele>\n </rtept>\n </rte>\n</gpx>\n".freeze
114
+ THE_WORKS = "<?xml version=\"1.0\"?>\n<gpx xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" version=\"1.1\" creator=\"GPX RubyGem #{GPX::VERSION} Copyright 2006-2009 Doug Fales -- http://gpx.rubyforge.org/\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n <metadata>\n <name>new_gpx_file_from_scratch.gpx</name>\n <time>%s</time>\n <bounds minlat=\"90.0\" minlon=\"180.0\" maxlat=\"-90.0\" maxlon=\"-180.0\"/>\n </metadata>\n <trk>\n <name/>\n <trkseg>\n <trkpt lat=\"40.036926\" lon=\"-105.253487\">\n <time>2005-12-31T22:01:24Z</time>\n <ele>1737.24</ele>\n </trkpt>\n <trkpt lat=\"40.036604\" lon=\"-105.253487\">\n <time>2005-12-31T22:02:01Z</time>\n <ele>1738.682</ele>\n </trkpt>\n <trkpt lat=\"40.036347\" lon=\"-105.25383\">\n <time>2005-12-31T22:02:08Z</time>\n <ele>1738.682</ele>\n </trkpt>\n <trkpt lat=\"40.035574\" lon=\"-105.254045\">\n <time>2005-12-31T22:02:20Z</time>\n <ele>1737.24</ele>\n </trkpt>\n <trkpt lat=\"40.035467\" lon=\"-105.254366\">\n <time>2005-12-31T22:02:29Z</time>\n <ele>1735.798</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254388\">\n <time>2005-12-31T22:02:33Z</time>\n <ele>1735.798</ele>\n </trkpt>\n <trkpt lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:49Z</time>\n <ele>1736.278</ele>\n </trkpt>\n <trkpt lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:54Z</time>\n <ele>1739.643</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254431\">\n <time>2005-12-31T22:05:08Z</time>\n <ele>1732.433</ele>\n </trkpt>\n <trkpt lat=\"40.035317\" lon=\"-105.254431\">\n <time>2005-12-31T22:05:09Z</time>\n <ele>1726.665</ele>\n </trkpt>\n </trkseg>\n </trk>\n <wpt lat=\"39.997298\" lon=\"-105.292674\">\n <name>GRG-CA</name>\n <sym>Waypoint</sym>\n <ele>1766.535</ele>\n </wpt>\n <wpt lat=\"33.33019\" lon=\"-111.94611\">\n <name>GRMPHX</name>\n <cmt>Hey here's a comment.</cmt>\n <desc>Somewhere in my backyard.</desc>\n <sym>Waypoint</sym>\n <fix>3d</fix>\n <sat>8</sat>\n <hdop>50.5</hdop>\n <vdop>6.8</vdop>\n <pdop>7.6</pdop>\n <ele>361.0981</ele>\n </wpt>\n <wpt lat=\"25.061783\" lon=\"121.640267\">\n <name>GRMTWN</name>\n <sym>Waypoint</sym>\n <ele>38.09766</ele>\n </wpt>\n <wpt lat=\"39.99984\" lon=\"-105.214696\">\n <name>SBDR</name>\n <sym>Waypoint</sym>\n <ele>1612.965</ele>\n </wpt>\n <wpt lat=\"39.989739\" lon=\"-105.295285\">\n <name>TO</name>\n <sym>Waypoint</sym>\n <ele>2163.556</ele>\n </wpt>\n <wpt lat=\"40.035301\" lon=\"-105.254443\">\n <name>VICS</name>\n <sym>Waypoint</sym>\n <ele>1535.34</ele>\n </wpt>\n <rte>\n <name/>\n <rtept lat=\"40.035467\" lon=\"-105.254366\">\n <time>2005-12-31T22:02:29Z</time>\n <ele>1735.798</ele>\n </rtept>\n <rtept lat=\"40.035317\" lon=\"-105.254388\">\n <time>2005-12-31T22:02:33Z</time>\n <ele>1735.798</ele>\n </rtept>\n <rtept lat=\"40.035274\" lon=\"-105.254431\">\n <time>2005-12-31T22:02:49Z</time>\n <ele>1736.278</ele>\n </rtept>\n </rte>\n</gpx>\n"
113
115
  end
data/tests/route_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
@@ -53,4 +55,54 @@ class RouteTest < Minitest::Test
53
55
  assert_equal(-105.214696, second_route.points[0].lon)
54
56
  assert_equal(1612.965, second_route.points[0].elevation)
55
57
  end
58
+
59
+ def test_read_routes_without_name_fields
60
+ file = File.join(File.dirname(__FILE__), 'gpx_files/routes_without_names.gpx')
61
+ gpx = GPX::GPXFile.new(gpx_file: file)
62
+ assert_equal(2, gpx.routes.size)
63
+ first_route = gpx.routes.first
64
+ assert_equal(3, first_route.points.size)
65
+ assert_nil(first_route.name)
66
+
67
+ # Route 1, First Point
68
+ # <rtept lat="39.997298" lon="-105.292674">
69
+ # <sym>Waypoint</sym>
70
+ # <ele>1766.535</ele>
71
+ # </rtept>
72
+ assert_equal(39.997298, first_route.points[0].lat)
73
+ assert_equal(-105.292674, first_route.points[0].lon)
74
+ assert_equal(1766.535, first_route.points[0].elevation)
75
+
76
+ # Route 1, Second Point
77
+ # <rtept lat="39.995700" lon="-105.292805">
78
+ # <name><![CDATA[AMPTHT]]></name>
79
+ # <sym>Waypoint</sym>
80
+ # <ele>1854.735</ele>
81
+ # </rtept>
82
+ assert_equal(39.995700, first_route.points[1].lat)
83
+ assert_equal(-105.292805, first_route.points[1].lon)
84
+ assert_equal(1854.735, first_route.points[1].elevation)
85
+
86
+ # Route 1, Third Point
87
+ # <rtept lat="39.989739" lon="-105.295285">
88
+ # <sym>Waypoint</sym>
89
+ # <ele>2163.556</ele>
90
+ # </rtept>
91
+ assert_equal(39.989739, first_route.points[2].lat)
92
+ assert_equal(-105.295285, first_route.points[2].lon)
93
+ assert_equal(2163.556, first_route.points[2].elevation)
94
+
95
+ second_route = gpx.routes[1]
96
+ assert_equal(1, second_route.points.size)
97
+ assert_nil(second_route.name)
98
+
99
+ # Route 2, Only Point
100
+ # <rtept lat="39.999840" lon="-105.214696">
101
+ # <sym>Waypoint</sym>
102
+ # <ele>1612.965</ele>
103
+ # </rtept>
104
+ assert_equal(39.999840, second_route.points[0].lat)
105
+ assert_equal(-105.214696, second_route.points[0].lon)
106
+ assert_equal(1612.965, second_route.points[0].elevation)
107
+ end
56
108
  end
@@ -1,4 +1,5 @@
1
- # require 'minitest/autorun'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'minitest/autorun'
3
4
  require 'yaml'
4
5
  require 'gpx'
@@ -6,6 +7,7 @@ require 'gpx'
6
7
  class SegmentTest < Minitest::Test
7
8
  ONE_SEGMENT = File.join(File.dirname(__FILE__), 'gpx_files/one_segment.gpx')
8
9
  ONE_SEGMENT_NO_TIME = File.join(File.dirname(__FILE__), 'gpx_files/one_segment_no_time.gpx')
10
+ ONE_SEGMENT_MIXED_TIMES = File.join(File.dirname(__FILE__), 'gpx_files/one_segment_mixed_times.gpx')
9
11
 
10
12
  def setup
11
13
  @gpx_file = GPX::GPXFile.new(gpx_file: ONE_SEGMENT)
@@ -105,4 +107,14 @@ class SegmentTest < Minitest::Test
105
107
  assert_in_delta(6.900813095, @segment.distance, 0.001)
106
108
  assert_equal(4466.0, @segment.duration)
107
109
  end
110
+
111
+ def test_segment_mixed_times
112
+ gpx_file_mixed_times = GPX::GPXFile.new(gpx_file: ONE_SEGMENT_MIXED_TIMES)
113
+ segment_mixed_times = gpx_file_mixed_times.tracks.first.segments.first
114
+ assert_equal(588, segment_mixed_times.points.size)
115
+ assert_equal(0, segment_mixed_times.earliest_point.time.to_i)
116
+ assert_equal(0, segment_mixed_times.latest_point.time.to_i)
117
+ assert_in_delta(40.763726054, segment_mixed_times.distance, 0.001)
118
+ assert_equal(0.0, segment_mixed_times.duration)
119
+ end
108
120
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
@@ -8,6 +10,7 @@ class TrackFileTest < Minitest::Test
8
10
  def setup
9
11
  @track_file = GPX::GPXFile.new(gpx_file: TRACK_FILE)
10
12
  @other_track_file = GPX::GPXFile.new(gpx_file: OTHER_TRACK_FILE)
13
+ FileUtils.mkdir_p(File.join(File.dirname(__FILE__), 'output'))
11
14
  end
12
15
 
13
16
  def test_track_read
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
data/tests/track_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'gpx'
3
5
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
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: 2018-03-06 00:00:00.000000000 Z
13
+ date: 2023-05-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -91,19 +91,25 @@ executables: []
91
91
  extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
+ - ".github/workflows/ruby.yml"
94
95
  - ".gitignore"
96
+ - ".rubocop"
95
97
  - ".rubocop.yml"
98
+ - ".ruby-version"
99
+ - ".tool-versions"
96
100
  - ".travis.yml"
97
101
  - CHANGELOG.md
98
102
  - Gemfile
99
103
  - LICENSE.txt
100
104
  - README.md
101
105
  - Rakefile
106
+ - UPGRADING.md
102
107
  - bin/gpx_distance
103
108
  - bin/gpx_smooth
104
109
  - gpx.gemspec
105
110
  - lib/gpx.rb
106
111
  - lib/gpx/bounds.rb
112
+ - lib/gpx/geo_json.rb
107
113
  - lib/gpx/gpx.rb
108
114
  - lib/gpx/gpx_file.rb
109
115
  - lib/gpx/magellan_track_log.rb
@@ -114,6 +120,12 @@ files:
114
120
  - lib/gpx/track_point.rb
115
121
  - lib/gpx/version.rb
116
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
117
129
  - tests/gpx10_test.rb
118
130
  - tests/gpx_file_test.rb
119
131
  - tests/gpx_files/arches.gpx
@@ -121,9 +133,11 @@ files:
121
133
  - tests/gpx_files/gpx10.gpx
122
134
  - tests/gpx_files/magellan_track.log
123
135
  - tests/gpx_files/one_segment.gpx
136
+ - tests/gpx_files/one_segment_mixed_times.gpx
124
137
  - tests/gpx_files/one_segment_no_time.gpx
125
138
  - tests/gpx_files/one_track.gpx
126
139
  - tests/gpx_files/routes.gpx
140
+ - tests/gpx_files/routes_without_names.gpx
127
141
  - tests/gpx_files/tracks.gpx
128
142
  - tests/gpx_files/waypoints.gpx
129
143
  - tests/gpx_files/with_empty_tracks.gpx
@@ -139,24 +153,26 @@ files:
139
153
  homepage: http://www.github.com/dougfales/gpx
140
154
  licenses: []
141
155
  metadata: {}
142
- post_install_message:
156
+ post_install_message:
143
157
  rdoc_options: []
144
158
  require_paths:
145
159
  - lib
146
160
  required_ruby_version: !ruby/object:Gem::Requirement
147
161
  requirements:
148
- - - "~>"
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '2.7'
165
+ - - "<"
149
166
  - !ruby/object:Gem::Version
150
- version: '2.2'
167
+ version: '4'
151
168
  required_rubygems_version: !ruby/object:Gem::Requirement
152
169
  requirements:
153
170
  - - ">="
154
171
  - !ruby/object:Gem::Version
155
172
  version: '0'
156
173
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.7.3
159
- signing_key:
174
+ rubygems_version: 3.4.10
175
+ signing_key:
160
176
  specification_version: 4
161
177
  summary: A basic API for reading and writing GPX files.
162
178
  test_files: []