gpx_track_generator 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/features/create_gpx_track_file-cli.feature +2 -2
- data/features/create_gpx_track_file-ruby.feature +2 -2
- data/lib/gpx_track_generator/api.rb +6 -1
- data/lib/gpx_track_generator/track.rb +6 -10
- data/lib/gpx_track_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cd0de5a966c6ba0dc5ff1bba79a36f05340ecfc
|
4
|
+
data.tar.gz: dcde233fec80ff4ad38b038be88934a0970b1fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ca48ed209bba159b632fb28a21b46ef06c8c5eddb8e3437de4bf16f34893f93f9c46830c2600bca799cb3c479f0667d10ef7cd45fc7319110cb10d52e03f03
|
7
|
+
data.tar.gz: 1a0698ed9d5697f6f4535ef9994714ac9bd76f8838c2ec443af3813fa556960c8637ff8677260b58a29dece647a8359e1780fb7ff57fef354014c76e6c0e4326
|
data/Gemfile.lock
CHANGED
@@ -67,11 +67,11 @@ Feature: Create GPX Track File
|
|
67
67
|
<!-- track2.gpx -->
|
68
68
|
<trkseg>
|
69
69
|
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
70
|
-
<name>WP
|
70
|
+
<name>WP 2</name>
|
71
71
|
<ele>16.232316396783801</ele>
|
72
72
|
</trkpt>
|
73
73
|
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
74
|
-
<name>WP
|
74
|
+
<name>WP 1</name>
|
75
75
|
<ele>16.232316396783801</ele>
|
76
76
|
</trkpt>
|
77
77
|
</trkseg>
|
@@ -93,11 +93,11 @@ Feature: Create GPX Track File
|
|
93
93
|
<!-- track2.gpx -->
|
94
94
|
<trkseg>
|
95
95
|
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
96
|
-
<name>WP
|
96
|
+
<name>WP 2</name>
|
97
97
|
<ele>16.232316396783801</ele>
|
98
98
|
</trkpt>
|
99
99
|
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
100
|
-
<name>WP
|
100
|
+
<name>WP 1</name>
|
101
101
|
<ele>16.232316396783801</ele>
|
102
102
|
</trkpt>
|
103
103
|
</trkseg>
|
@@ -4,7 +4,12 @@ module GpxTrackGenerator
|
|
4
4
|
module Api
|
5
5
|
def self.generate(input_files:, track_name:, output_file:, reverse: false, single_segment: false)
|
6
6
|
files = input_files.map { |f| GpxFile.new(File.expand_path(f)) }
|
7
|
-
track = Track.new(
|
7
|
+
track = Track.new(
|
8
|
+
files,
|
9
|
+
name: track_name,
|
10
|
+
reverse: reverse,
|
11
|
+
single_segment: single_segment
|
12
|
+
)
|
8
13
|
|
9
14
|
File.write(output_file, track.to_s)
|
10
15
|
end
|
@@ -31,12 +31,6 @@ module GpxTrackGenerator
|
|
31
31
|
|
32
32
|
# rubocop:disable Metrics/PerceivedComplexity
|
33
33
|
def build_document
|
34
|
-
gpx_files = if reverse
|
35
|
-
files.reverse
|
36
|
-
else
|
37
|
-
files
|
38
|
-
end
|
39
|
-
|
40
34
|
document.child << metadata
|
41
35
|
|
42
36
|
document.child << document.create_element('trk')
|
@@ -46,16 +40,18 @@ module GpxTrackGenerator
|
|
46
40
|
if single_segment
|
47
41
|
document.css('trk').first << document.create_element('trkseg')
|
48
42
|
|
49
|
-
|
43
|
+
files.each_with_object(document.css('trk').first) do |e, a|
|
50
44
|
segment = a.css('trkseg').last
|
51
45
|
segment << "<!-- #{e.file_name} -->"
|
52
46
|
segment << (reverse ? e.nodes.reverse : e.nodes)
|
53
47
|
end
|
54
48
|
else
|
55
|
-
|
49
|
+
files.each_with_object(document.css('trk').first) do |e, a|
|
56
50
|
a << "<!-- #{e.file_name} -->"
|
57
51
|
a << document.create_element('trkseg')
|
58
|
-
|
52
|
+
|
53
|
+
segment = a.css('trkseg').last
|
54
|
+
segment << (reverse ? e.nodes.reverse : e.nodes)
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
@@ -65,7 +61,7 @@ module GpxTrackGenerator
|
|
65
61
|
document.css('trkpt').each_with_index { |e, i| e.css('name').first.content = "WP #{i + 1}" }
|
66
62
|
end
|
67
63
|
|
68
|
-
document.human
|
64
|
+
document.dup.human
|
69
65
|
end
|
70
66
|
# rubocop:enable Metrics/PerceivedComplexity
|
71
67
|
|