gpx 1.0.0 → 1.1.0

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.
@@ -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.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: 2018-03-06 00:00:00.000000000 Z
13
+ date: 2023-05-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -91,8 +91,10 @@ executables: []
91
91
  extensions: []
92
92
  extra_rdoc_files: []
93
93
  files:
94
+ - ".github/workflows/ruby.yml"
94
95
  - ".gitignore"
95
96
  - ".rubocop.yml"
97
+ - ".ruby-version"
96
98
  - ".travis.yml"
97
99
  - CHANGELOG.md
98
100
  - Gemfile
@@ -104,6 +106,7 @@ files:
104
106
  - gpx.gemspec
105
107
  - lib/gpx.rb
106
108
  - lib/gpx/bounds.rb
109
+ - lib/gpx/geo_json.rb
107
110
  - lib/gpx/gpx.rb
108
111
  - lib/gpx/gpx_file.rb
109
112
  - lib/gpx/magellan_track_log.rb
@@ -114,6 +117,12 @@ files:
114
117
  - lib/gpx/track_point.rb
115
118
  - lib/gpx/version.rb
116
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
117
126
  - tests/gpx10_test.rb
118
127
  - tests/gpx_file_test.rb
119
128
  - tests/gpx_files/arches.gpx
@@ -121,9 +130,11 @@ files:
121
130
  - tests/gpx_files/gpx10.gpx
122
131
  - tests/gpx_files/magellan_track.log
123
132
  - tests/gpx_files/one_segment.gpx
133
+ - tests/gpx_files/one_segment_mixed_times.gpx
124
134
  - tests/gpx_files/one_segment_no_time.gpx
125
135
  - tests/gpx_files/one_track.gpx
126
136
  - tests/gpx_files/routes.gpx
137
+ - tests/gpx_files/routes_without_names.gpx
127
138
  - tests/gpx_files/tracks.gpx
128
139
  - tests/gpx_files/waypoints.gpx
129
140
  - tests/gpx_files/with_empty_tracks.gpx
@@ -139,24 +150,26 @@ files:
139
150
  homepage: http://www.github.com/dougfales/gpx
140
151
  licenses: []
141
152
  metadata: {}
142
- post_install_message:
153
+ post_install_message:
143
154
  rdoc_options: []
144
155
  require_paths:
145
156
  - lib
146
157
  required_ruby_version: !ruby/object:Gem::Requirement
147
158
  requirements:
148
- - - "~>"
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '2.5'
162
+ - - "<"
149
163
  - !ruby/object:Gem::Version
150
- version: '2.2'
164
+ version: '4'
151
165
  required_rubygems_version: !ruby/object:Gem::Requirement
152
166
  requirements:
153
167
  - - ">="
154
168
  - !ruby/object:Gem::Version
155
169
  version: '0'
156
170
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.7.3
159
- signing_key:
171
+ rubygems_version: 3.2.22
172
+ signing_key:
160
173
  specification_version: 4
161
174
  summary: A basic API for reading and writing GPX files.
162
175
  test_files: []