gpx 0.9.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +36 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +162 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -5
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +20 -5
- data/Rakefile +22 -12
- data/bin/gpx_distance +5 -6
- data/bin/gpx_smooth +25 -26
- data/gpx.gemspec +13 -12
- 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 +47 -18
- data/lib/gpx/trackpoint.rb +0 -60
data/tests/gpx10_test.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'minitest/autorun'
|
2
4
|
require 'gpx'
|
3
5
|
|
4
6
|
class GPX10Test < Minitest::Test
|
5
|
-
|
6
|
-
|
7
|
-
def test_read
|
8
|
-
# make sure we can read a GPX 1.0 file
|
9
|
-
@gpx_file = GPX::GPXFile.new(:gpx_file => GPX_FILE)
|
10
|
-
end
|
7
|
+
GPX_FILE = File.join(File.dirname(__FILE__), 'gpx_files/gpx10.gpx')
|
11
8
|
|
9
|
+
def test_read
|
10
|
+
# make sure we can read a GPX 1.0 file
|
11
|
+
@gpx_file = GPX::GPXFile.new(gpx_file: GPX_FILE)
|
12
|
+
end
|
12
13
|
end
|
data/tests/gpx_file_test.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'minitest/autorun'
|
2
4
|
require 'gpx'
|
3
5
|
|
4
6
|
class GPXFileTest < Minitest::Test
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
BIG_FILE = File.join(File.dirname(__FILE__),
|
7
|
+
ONE_TRACK_FILE = File.join(File.dirname(__FILE__), 'gpx_files/one_track.gpx')
|
8
|
+
WITH_OR_WITHOUT_ELEV_FILE = File.join(File.dirname(__FILE__), 'gpx_files/with_or_without_elev.gpx')
|
9
|
+
WITH_EMPTY_TRACKS = File.join(File.dirname(__FILE__), 'gpx_files/with_empty_tracks.gpx')
|
10
|
+
BIG_FILE = File.join(File.dirname(__FILE__), 'gpx_files/big.gpx')
|
9
11
|
|
10
12
|
def test_load_data_from_string
|
11
|
-
gpx_file = GPX::GPXFile.new(:
|
13
|
+
gpx_file = GPX::GPXFile.new(gpx_data: File.open(ONE_TRACK_FILE).read)
|
12
14
|
assert_equal(1, gpx_file.tracks.size)
|
13
15
|
assert_equal(8, gpx_file.tracks.first.segments.size)
|
14
|
-
assert_equal(
|
15
|
-
assert_equal(
|
16
|
-
assert_equal(
|
16
|
+
assert_equal('ACTIVE LOG', gpx_file.tracks.first.name)
|
17
|
+
assert_equal('active_log.gpx', gpx_file.name)
|
18
|
+
assert_equal('2006-04-08T16:44:28Z', gpx_file.time.xmlschema)
|
17
19
|
assert_equal(38.681488, gpx_file.bounds.min_lat)
|
18
20
|
assert_equal(-109.606948, gpx_file.bounds.min_lon)
|
19
21
|
assert_equal(38.791759, gpx_file.bounds.max_lat)
|
@@ -21,45 +23,55 @@ class GPXFileTest < Minitest::Test
|
|
21
23
|
assert_equal('description of my GPX file with special char like &, <, >', gpx_file.description)
|
22
24
|
assert_equal('description of my GPX file with special char like &, <, >', gpx_file.description)
|
23
25
|
assert_equal(3.0724966849262554, gpx_file.distance)
|
24
|
-
assert_equal(
|
26
|
+
assert_equal(15_237.0, gpx_file.duration)
|
25
27
|
assert_equal(3036.0, gpx_file.moving_duration)
|
26
28
|
assert_equal(3.6432767014935834, gpx_file.average_speed)
|
27
29
|
end
|
28
30
|
|
29
31
|
def test_load_data_from_file
|
30
|
-
gpx_file = GPX::GPXFile.new(:
|
32
|
+
gpx_file = GPX::GPXFile.new(gpx_file: ONE_TRACK_FILE)
|
31
33
|
assert_equal(1, gpx_file.tracks.size)
|
32
34
|
assert_equal(8, gpx_file.tracks.first.segments.size)
|
33
|
-
assert_equal(
|
34
|
-
assert_equal(
|
35
|
-
assert_equal(
|
35
|
+
assert_equal('ACTIVE LOG', gpx_file.tracks.first.name)
|
36
|
+
assert_equal('active_log.gpx', gpx_file.name)
|
37
|
+
assert_equal('2006-04-08T16:44:28Z', gpx_file.time.xmlschema)
|
36
38
|
assert_equal(38.681488, gpx_file.bounds.min_lat)
|
37
39
|
assert_equal(-109.606948, gpx_file.bounds.min_lon)
|
38
40
|
assert_equal(38.791759, gpx_file.bounds.max_lat)
|
39
41
|
assert_equal(-109.447045, gpx_file.bounds.max_lon)
|
40
42
|
assert_equal('description of my GPX file with special char like &, <, >', gpx_file.description)
|
41
43
|
assert_equal(3.0724966849262554, gpx_file.distance)
|
42
|
-
assert_equal(
|
44
|
+
assert_equal(15_237.0, gpx_file.duration)
|
43
45
|
assert_equal(3036.0, gpx_file.moving_duration)
|
44
46
|
assert_equal(3.6432767014935834, gpx_file.average_speed)
|
45
47
|
end
|
46
48
|
|
47
49
|
def test_big_file
|
48
|
-
gpx_file = GPX::GPXFile.new(:
|
50
|
+
gpx_file = GPX::GPXFile.new(gpx_file: BIG_FILE)
|
49
51
|
assert_equal(1, gpx_file.tracks.size)
|
50
52
|
assert_equal(7968, gpx_file.tracks.first.points.size)
|
51
|
-
assert_equal(
|
52
|
-
assert_equal(
|
53
|
+
assert_equal(105_508.0, gpx_file.duration)
|
54
|
+
assert_equal(57_645.0, gpx_file.moving_duration)
|
53
55
|
assert_in_delta(99.60738958686505, gpx_file.average_speed, 1e-13)
|
54
56
|
end
|
55
57
|
|
56
58
|
def test_with_or_with_elev
|
57
|
-
gpx_file = GPX::GPXFile.new(:
|
59
|
+
gpx_file = GPX::GPXFile.new(gpx_file: WITH_OR_WITHOUT_ELEV_FILE)
|
58
60
|
assert_equal(2, gpx_file.tracks.size)
|
59
61
|
assert_equal(0, gpx_file.duration)
|
60
62
|
assert_equal(0, gpx_file.moving_duration)
|
61
63
|
assert(gpx_file.average_speed.nan?)
|
62
|
-
#assert_equal(7968, gpx_file.tracks.first.points.size)
|
64
|
+
# assert_equal(7968, gpx_file.tracks.first.points.size)
|
63
65
|
end
|
64
66
|
|
67
|
+
def test_with_empty_tracks
|
68
|
+
gpx_file = GPX::GPXFile.new(gpx_file: WITH_EMPTY_TRACKS)
|
69
|
+
# is read correctly
|
70
|
+
assert_equal(1, gpx_file.tracks.size)
|
71
|
+
# and ignores empty segments
|
72
|
+
assert_equal(1, gpx_file.tracks.first.segments.size)
|
73
|
+
assert_equal(21.0, gpx_file.duration)
|
74
|
+
assert_equal(21.0, gpx_file.moving_duration)
|
75
|
+
assert_equal(6.674040636626879, gpx_file.average_speed)
|
76
|
+
end
|
65
77
|
end
|