gpx_track_generator 0.3.1 → 0.3.3
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 -4
- data/README.md +5 -2
- data/config/rubocop/exclude.yml +0 -6
- data/config/rubocop/include.yml +3 -0
- data/features/{create_gpx_track_file.feature → create_gpx_track_file-cli.feature} +64 -54
- data/features/create_gpx_track_file-ruby.feature +180 -0
- data/features/step_definitions.rb +12 -0
- data/gpx_track_generator.gemspec +0 -1
- data/lib/gpx_track_generator.rb +1 -1
- data/lib/gpx_track_generator/api.rb +1 -1
- data/lib/gpx_track_generator/gpx_file.rb +0 -2
- data/lib/gpx_track_generator/pretty.rb +20 -0
- data/lib/gpx_track_generator/pretty.xslt +50 -0
- data/lib/gpx_track_generator/track.rb +12 -3
- data/lib/gpx_track_generator/version.rb +1 -1
- data/script/bootstrap +4 -0
- data/script/ci +3 -0
- metadata +10 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3db3b92d3d5ce67dadc6262e30758f7fe1a42189
|
4
|
+
data.tar.gz: 58539daf9e643ff4d71176ac7ed766f1ced030d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99f13854519d6f4825d70236b275deb586f435b0b6da2c95773cb0fec2e92493a19021ed3ba5cd337990b335c8d1dcc310fe23dad48f5ea470bcf099b17d0e69
|
7
|
+
data.tar.gz: 5e16184c3264b11a2166748144fe90b7cf398916565ed2ab6072b388b7ebbc5f6a5c6cad973344bbf10adb1a25281e3466d9639605c62bb06e348a423d485a8c
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gpx_track_generator (0.3.
|
4
|
+
gpx_track_generator (0.3.3)
|
5
5
|
activesupport
|
6
6
|
fedux_org-stdlib
|
7
7
|
nokogiri
|
8
|
-
nokogiri-pretty
|
9
8
|
thor
|
10
9
|
|
11
10
|
GEM
|
@@ -144,8 +143,6 @@ GEM
|
|
144
143
|
netrc (0.7.7)
|
145
144
|
nokogiri (1.6.3.1)
|
146
145
|
mini_portile (= 0.6.0)
|
147
|
-
nokogiri-pretty (0.1.0)
|
148
|
-
nokogiri
|
149
146
|
parallel (1.2.4)
|
150
147
|
parser (2.2.0.pre.4)
|
151
148
|
ast (>= 1.1, < 3.0)
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Gpx Track Generator
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/maxmeyer/gpx_track_generator.svg?branch=master)](https://travis-ci.org/maxmeyer/gpx_track_generator)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/gpx_track_generator.svg)](http://badge.fury.io/rb/gpx_track_generator)
|
5
|
+
|
3
6
|
This gem creates a single gpx track from all given gpx-files. Those files can
|
4
7
|
contain route- or track-points. This might be handy if you've got single
|
5
8
|
gpx-files for each part of a long distance walk, but don't want to litter your
|
@@ -24,8 +27,8 @@ Or install it yourself as:
|
|
24
27
|
### Introduction
|
25
28
|
|
26
29
|
The order of the gpx files which should be used by `gpx_track_generator` is
|
27
|
-
important.
|
28
|
-
another.
|
30
|
+
important. The script iterates over all files and concatenates the found nodes
|
31
|
+
one after another.
|
29
32
|
|
30
33
|
#### Example:
|
31
34
|
|
data/config/rubocop/exclude.yml
CHANGED
@@ -24,9 +24,3 @@ Metrics/CyclomaticComplexity:
|
|
24
24
|
Max: 9
|
25
25
|
Enabled: false
|
26
26
|
|
27
|
-
Metrics/PerceivedComplexity:
|
28
|
-
Exclude:
|
29
|
-
- lib/middleman-presentation/frontend_component.rb
|
30
|
-
- lib/middleman-presentation/assets_manager.rb
|
31
|
-
- lib/middleman-presentation/file_extensions.rb
|
32
|
-
- lib/middleman-presentation/commands/slide.rb
|
data/config/rubocop/include.yml
CHANGED
@@ -45,14 +45,17 @@ Feature: Create GPX Track File
|
|
45
45
|
When I successfully run `gpx_track g track1.gpx track2.gpx`
|
46
46
|
Then the gpx file "track.gpx" should contain:
|
47
47
|
"""
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
<!-- track2.gpx -->
|
49
|
+
<trkseg>
|
50
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
51
|
+
<name>WP 3</name>
|
52
|
+
<ele>16.232316396783801</ele>
|
53
|
+
</trkpt>
|
54
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
55
|
+
<name>WP 4</name>
|
56
|
+
<ele>16.232316396783801</ele>
|
57
|
+
</trkpt>
|
58
|
+
</trkseg>
|
56
59
|
"""
|
57
60
|
|
58
61
|
Scenario: Reverse track
|
@@ -61,14 +64,17 @@ Feature: Create GPX Track File
|
|
61
64
|
When I successfully run `gpx_track g --reverse track1.gpx track2.gpx`
|
62
65
|
Then the gpx file "track.gpx" should contain:
|
63
66
|
"""
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
<!-- track2.gpx -->
|
68
|
+
<trkseg>
|
69
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
70
|
+
<name>WP 4</name>
|
71
|
+
<ele>16.232316396783801</ele>
|
72
|
+
</trkpt>
|
73
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
74
|
+
<name>WP 3</name>
|
75
|
+
<ele>16.232316396783801</ele>
|
76
|
+
</trkpt>
|
77
|
+
</trkseg>
|
72
78
|
"""
|
73
79
|
|
74
80
|
Scenario: Single segment
|
@@ -77,24 +83,26 @@ Feature: Create GPX Track File
|
|
77
83
|
When I successfully run `gpx_track g --single-segment track1.gpx track2.gpx`
|
78
84
|
Then the gpx file "track.gpx" should contain:
|
79
85
|
"""
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
86
|
+
<trkseg>
|
87
|
+
<!-- track1.gpx -->
|
88
|
+
<trkpt lat="55.688634024660372" lon="-5.5744374090151107">
|
89
|
+
<name>WP 1</name>
|
90
|
+
<ele>15.232316396783801</ele>
|
91
|
+
</trkpt>
|
92
|
+
<trkpt lat="57.688634024660372" lon="-5.5744374090151107">
|
93
|
+
<name>WP 2</name>
|
94
|
+
<ele>15.232316396783801</ele>
|
95
|
+
</trkpt>
|
96
|
+
<!-- track2.gpx -->
|
97
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
98
|
+
<name>WP 3</name>
|
99
|
+
<ele>16.232316396783801</ele>
|
100
|
+
</trkpt>
|
101
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
102
|
+
<name>WP 4</name>
|
103
|
+
<ele>16.232316396783801</ele>
|
104
|
+
</trkpt>
|
105
|
+
</trkseg>
|
98
106
|
"""
|
99
107
|
|
100
108
|
Scenario: One segment per track file
|
@@ -103,24 +111,26 @@ Feature: Create GPX Track File
|
|
103
111
|
When I successfully run `gpx_track g --single-segment=false track1.gpx track2.gpx`
|
104
112
|
Then the gpx file "track.gpx" should contain:
|
105
113
|
"""
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
</
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
114
|
+
<!-- track1.gpx -->
|
115
|
+
<trkseg>
|
116
|
+
<trkpt lat="55.688634024660372" lon="-5.5744374090151107">
|
117
|
+
<name>WP 1</name>
|
118
|
+
<ele>15.232316396783801</ele>
|
119
|
+
</trkpt>
|
120
|
+
<trkpt lat="57.688634024660372" lon="-5.5744374090151107">
|
121
|
+
<name>WP 2</name>
|
122
|
+
<ele>15.232316396783801</ele>
|
123
|
+
</trkpt>
|
124
|
+
</trkseg>
|
125
|
+
<!-- track2.gpx -->
|
126
|
+
<trkseg>
|
127
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
128
|
+
<name>WP 3</name>
|
129
|
+
<ele>16.232316396783801</ele>
|
130
|
+
</trkpt>
|
131
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
132
|
+
<name>WP 4</name>
|
133
|
+
<ele>16.232316396783801</ele>
|
134
|
+
</trkpt>
|
135
|
+
</trkseg>
|
126
136
|
"""
|
@@ -0,0 +1,180 @@
|
|
1
|
+
Feature: Create GPX Track File
|
2
|
+
As a user
|
3
|
+
I want to transform existing gpx routes or multiple gpx tracks to one gpx track
|
4
|
+
In order to use them on my gps device
|
5
|
+
|
6
|
+
Scenario: Create from gpx route files
|
7
|
+
Given a gpx file named "route1.gpx"
|
8
|
+
And a gpx file named "route2.gpx"
|
9
|
+
And a converter script named "convert.rb" with
|
10
|
+
"""
|
11
|
+
GpxTrackGenerator::Api.generate(
|
12
|
+
input_files: %w(route1.gpx route2.gpx),
|
13
|
+
output_file: 'track.gpx',
|
14
|
+
track_name: 'My Name'
|
15
|
+
)
|
16
|
+
"""
|
17
|
+
When I successfully run `./convert.rb`
|
18
|
+
Then a gpx file named "track.gpx" should exist with "4" track nodes
|
19
|
+
|
20
|
+
Scenario: Create from gpx track files
|
21
|
+
Given a gpx file named "track1.gpx"
|
22
|
+
And a gpx file named "track2.gpx"
|
23
|
+
And a converter script named "convert.rb" with
|
24
|
+
"""
|
25
|
+
GpxTrackGenerator::Api.generate(
|
26
|
+
input_files: %w(track1.gpx track2.gpx),
|
27
|
+
output_file: 'track.gpx',
|
28
|
+
track_name: 'My Name'
|
29
|
+
)
|
30
|
+
"""
|
31
|
+
When I successfully run `./convert.rb`
|
32
|
+
Then a gpx file named "track.gpx" should exist with "4" track nodes
|
33
|
+
|
34
|
+
Scenario: Define name
|
35
|
+
Given a gpx file named "track1.gpx"
|
36
|
+
And a gpx file named "track2.gpx"
|
37
|
+
And a converter script named "convert.rb" with
|
38
|
+
"""
|
39
|
+
GpxTrackGenerator::Api.generate(
|
40
|
+
input_files: %w(track1.gpx track2.gpx),
|
41
|
+
output_file: 'track.gpx',
|
42
|
+
track_name: 'My Name'
|
43
|
+
)
|
44
|
+
"""
|
45
|
+
When I successfully run `./convert.rb`
|
46
|
+
Then the gpx file "track.gpx" should contain:
|
47
|
+
"""
|
48
|
+
<name>My Name</name>
|
49
|
+
"""
|
50
|
+
|
51
|
+
Scenario: Normal order track
|
52
|
+
Given a gpx file named "track1.gpx"
|
53
|
+
And a gpx file named "track2.gpx"
|
54
|
+
And a converter script named "convert.rb" with
|
55
|
+
"""
|
56
|
+
GpxTrackGenerator::Api.generate(
|
57
|
+
input_files: %w(track1.gpx track2.gpx),
|
58
|
+
output_file: 'track.gpx',
|
59
|
+
track_name: 'My Name'
|
60
|
+
)
|
61
|
+
"""
|
62
|
+
When I successfully run `./convert.rb`
|
63
|
+
Then the gpx file "track.gpx" should contain:
|
64
|
+
"""
|
65
|
+
<!-- track2.gpx -->
|
66
|
+
<trkseg>
|
67
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
68
|
+
<name>WP 3</name>
|
69
|
+
<ele>16.232316396783801</ele>
|
70
|
+
</trkpt>
|
71
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
72
|
+
<name>WP 4</name>
|
73
|
+
<ele>16.232316396783801</ele>
|
74
|
+
</trkpt>
|
75
|
+
</trkseg>
|
76
|
+
"""
|
77
|
+
|
78
|
+
Scenario: Reverse track
|
79
|
+
Given a gpx file named "track1.gpx"
|
80
|
+
And a gpx file named "track2.gpx"
|
81
|
+
And a converter script named "convert.rb" with
|
82
|
+
"""
|
83
|
+
GpxTrackGenerator::Api.generate(
|
84
|
+
input_files: %w(track1.gpx track2.gpx),
|
85
|
+
output_file: 'track.gpx',
|
86
|
+
track_name: 'My Name',
|
87
|
+
reverse: true
|
88
|
+
)
|
89
|
+
"""
|
90
|
+
When I successfully run `./convert.rb`
|
91
|
+
Then the gpx file "track.gpx" should contain:
|
92
|
+
"""
|
93
|
+
<!-- track2.gpx -->
|
94
|
+
<trkseg>
|
95
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
96
|
+
<name>WP 4</name>
|
97
|
+
<ele>16.232316396783801</ele>
|
98
|
+
</trkpt>
|
99
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
100
|
+
<name>WP 3</name>
|
101
|
+
<ele>16.232316396783801</ele>
|
102
|
+
</trkpt>
|
103
|
+
</trkseg>
|
104
|
+
"""
|
105
|
+
|
106
|
+
Scenario: Single segment
|
107
|
+
Given a gpx file named "track1.gpx"
|
108
|
+
And a gpx file named "track2.gpx"
|
109
|
+
And a converter script named "convert.rb" with
|
110
|
+
"""
|
111
|
+
GpxTrackGenerator::Api.generate(
|
112
|
+
input_files: %w(track1.gpx track2.gpx),
|
113
|
+
output_file: 'track.gpx',
|
114
|
+
track_name: 'My Name',
|
115
|
+
single_segment: true
|
116
|
+
)
|
117
|
+
"""
|
118
|
+
When I successfully run `./convert.rb`
|
119
|
+
Then the gpx file "track.gpx" should contain:
|
120
|
+
"""
|
121
|
+
<trkseg>
|
122
|
+
<!-- track1.gpx -->
|
123
|
+
<trkpt lat="55.688634024660372" lon="-5.5744374090151107">
|
124
|
+
<name>WP 1</name>
|
125
|
+
<ele>15.232316396783801</ele>
|
126
|
+
</trkpt>
|
127
|
+
<trkpt lat="57.688634024660372" lon="-5.5744374090151107">
|
128
|
+
<name>WP 2</name>
|
129
|
+
<ele>15.232316396783801</ele>
|
130
|
+
</trkpt>
|
131
|
+
<!-- track2.gpx -->
|
132
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
133
|
+
<name>WP 3</name>
|
134
|
+
<ele>16.232316396783801</ele>
|
135
|
+
</trkpt>
|
136
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
137
|
+
<name>WP 4</name>
|
138
|
+
<ele>16.232316396783801</ele>
|
139
|
+
</trkpt>
|
140
|
+
</trkseg>
|
141
|
+
"""
|
142
|
+
|
143
|
+
Scenario: One segment per track file
|
144
|
+
Given a gpx file named "track1.gpx"
|
145
|
+
And a gpx file named "track2.gpx"
|
146
|
+
And a converter script named "convert.rb" with
|
147
|
+
"""
|
148
|
+
GpxTrackGenerator::Api.generate(
|
149
|
+
input_files: %w(track1.gpx track2.gpx),
|
150
|
+
output_file: 'track.gpx',
|
151
|
+
track_name: 'My Name',
|
152
|
+
single_segment: false
|
153
|
+
)
|
154
|
+
"""
|
155
|
+
When I successfully run `./convert.rb`
|
156
|
+
Then the gpx file "track.gpx" should contain:
|
157
|
+
"""
|
158
|
+
<!-- track1.gpx -->
|
159
|
+
<trkseg>
|
160
|
+
<trkpt lat="55.688634024660372" lon="-5.5744374090151107">
|
161
|
+
<name>WP 1</name>
|
162
|
+
<ele>15.232316396783801</ele>
|
163
|
+
</trkpt>
|
164
|
+
<trkpt lat="57.688634024660372" lon="-5.5744374090151107">
|
165
|
+
<name>WP 2</name>
|
166
|
+
<ele>15.232316396783801</ele>
|
167
|
+
</trkpt>
|
168
|
+
</trkseg>
|
169
|
+
<!-- track2.gpx -->
|
170
|
+
<trkseg>
|
171
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
172
|
+
<name>WP 3</name>
|
173
|
+
<ele>16.232316396783801</ele>
|
174
|
+
</trkpt>
|
175
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
176
|
+
<name>WP 4</name>
|
177
|
+
<ele>16.232316396783801</ele>
|
178
|
+
</trkpt>
|
179
|
+
</trkseg>
|
180
|
+
"""
|
@@ -36,3 +36,15 @@ end
|
|
36
36
|
Then(/^the gpx file "(.*?)" should contain:$/) do |file, content|
|
37
37
|
step %(the file "#{file}" should contain:), content
|
38
38
|
end
|
39
|
+
|
40
|
+
Given(/^a converter script named "(.*?)" with$/) do |name, content|
|
41
|
+
header = <<-EOS.strip_heredoc
|
42
|
+
#!/usr/bin/env ruby
|
43
|
+
# encoding: utf-8
|
44
|
+
require 'gpx_track_generator'
|
45
|
+
EOS
|
46
|
+
|
47
|
+
content = header + content
|
48
|
+
|
49
|
+
step %(a file named "#{name}" with mode "0755" and with:), content
|
50
|
+
end
|
data/gpx_track_generator.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_runtime_dependency 'nokogiri'
|
21
|
-
spec.add_runtime_dependency 'nokogiri-pretty'
|
22
21
|
spec.add_runtime_dependency 'thor'
|
23
22
|
spec.add_runtime_dependency 'activesupport'
|
24
23
|
spec.add_runtime_dependency 'fedux_org-stdlib'
|
data/lib/gpx_track_generator.rb
CHANGED
@@ -4,7 +4,6 @@ require 'thor/actions'
|
|
4
4
|
require 'active_support/core_ext/string/strip'
|
5
5
|
require 'fedux_org_stdlib/logging/logger'
|
6
6
|
require 'fedux_org_stdlib/core_ext/array/list'
|
7
|
-
require 'nokogiri-pretty'
|
8
7
|
|
9
8
|
require 'gpx_track_generator/version'
|
10
9
|
require 'gpx_track_generator/logger'
|
@@ -13,6 +12,7 @@ require 'gpx_track_generator/gpx_file'
|
|
13
12
|
require 'gpx_track_generator/runner'
|
14
13
|
require 'gpx_track_generator/track'
|
15
14
|
require 'gpx_track_generator/api'
|
15
|
+
require 'gpx_track_generator/pretty'
|
16
16
|
|
17
17
|
# Track generator
|
18
18
|
module GpxTrackGenerator
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module GpxTrackGenerator
|
3
3
|
# Main api
|
4
4
|
module Api
|
5
|
-
def self.generate(input_files:, track_name:, output_file:, reverse: false, single_segment:
|
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
7
|
track = Track.new(files, name: track_name, reverse: reverse, single_segment: single_segment)
|
8
8
|
|
@@ -20,8 +20,6 @@ module GpxTrackGenerator
|
|
20
20
|
node_set += extract_route_nodes unless extract_route_nodes.empty?
|
21
21
|
node_set += extract_track_nodes unless extract_track_nodes.empty?
|
22
22
|
|
23
|
-
node_set.css('trkpt').each_with_index { |e, i| e.css('name').first.content = "WP #{i + 1}" }
|
24
|
-
|
25
23
|
node_set
|
26
24
|
end
|
27
25
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module GpxTrackGenerator
|
2
|
+
# Prettify XML
|
3
|
+
module PrettyXml
|
4
|
+
# Make xml pretty
|
5
|
+
def human
|
6
|
+
Nokogiri::XSLT(File.open(File.expand_path('../pretty.xslt', __FILE__))).apply_to self
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Nokogiri
|
12
|
+
module Nokogiri
|
13
|
+
# XML
|
14
|
+
module XML
|
15
|
+
# Node
|
16
|
+
class Node
|
17
|
+
include GpxTrackGenerator::PrettyXml
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
2
|
+
<xsl:output method="xml" indent="yes"/>
|
3
|
+
<xsl:strip-space elements="*"/>
|
4
|
+
|
5
|
+
<xsl:template match="node()|@*">
|
6
|
+
<xsl:copy>
|
7
|
+
<xsl:apply-templates select="node()|@*"/>
|
8
|
+
</xsl:copy>
|
9
|
+
</xsl:template>
|
10
|
+
|
11
|
+
|
12
|
+
<xsl:template match="things">
|
13
|
+
<mainElements>
|
14
|
+
<xsl:apply-templates select="thing|comment()"/>
|
15
|
+
</mainElements>
|
16
|
+
</xsl:template>
|
17
|
+
|
18
|
+
|
19
|
+
<xsl:template match="thing">
|
20
|
+
<specialThing>
|
21
|
+
<xsl:apply-templates select="weight"/>
|
22
|
+
<xsl:apply-templates select="color"/>
|
23
|
+
<xsl:apply-templates select="state"/>
|
24
|
+
</specialThing>
|
25
|
+
<xsl:apply-templates select="comment()[not(following-sibling::*)]"/>
|
26
|
+
</xsl:template>
|
27
|
+
|
28
|
+
|
29
|
+
<xsl:template match="weight">
|
30
|
+
<xsl:apply-templates select="preceding-sibling::comment()[generate-id(following-sibling::*[1])=generate-id(current())]"/>
|
31
|
+
<PropertyOne>
|
32
|
+
<xsl:value-of select="."/>
|
33
|
+
</PropertyOne>
|
34
|
+
</xsl:template>
|
35
|
+
|
36
|
+
<xsl:template match="color">
|
37
|
+
<xsl:apply-templates select="preceding-sibling::comment()[generate-id(following-sibling::*[1])=generate-id(current())]"/>
|
38
|
+
<PropertyTwo>
|
39
|
+
<xsl:value-of select="."/>
|
40
|
+
</PropertyTwo>
|
41
|
+
</xsl:template>
|
42
|
+
|
43
|
+
<xsl:template match="state">
|
44
|
+
<xsl:apply-templates select="preceding-sibling::comment()[generate-id(following-sibling::*[1])=generate-id(current())]"/>
|
45
|
+
<PropertyThree>
|
46
|
+
<xsl:value-of select="."/>
|
47
|
+
</PropertyThree>
|
48
|
+
</xsl:template>
|
49
|
+
|
50
|
+
</xsl:stylesheet>
|
@@ -29,6 +29,7 @@ module GpxTrackGenerator
|
|
29
29
|
'https://github.com/maxmeyer/gpx_track_generator'
|
30
30
|
end
|
31
31
|
|
32
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
32
33
|
def build_document
|
33
34
|
gpx_files = if reverse
|
34
35
|
files.reverse
|
@@ -46,19 +47,27 @@ module GpxTrackGenerator
|
|
46
47
|
document.css('trk').first << document.create_element('trkseg')
|
47
48
|
|
48
49
|
gpx_files.each_with_object(document.css('trk').first) do |e, a|
|
49
|
-
|
50
|
-
|
50
|
+
segment = a.css('trkseg').last
|
51
|
+
segment << "<!-- #{e.file_name} -->"
|
52
|
+
segment << (reverse ? e.nodes.reverse : e.nodes)
|
51
53
|
end
|
52
54
|
else
|
53
|
-
|
55
|
+
gpx_files.each_with_object(document.css('trk').first) do |e, a|
|
54
56
|
a << "<!-- #{e.file_name} -->"
|
55
57
|
a << document.create_element('trkseg')
|
56
58
|
a.css('trkseg').last << (reverse ? e.nodes.reverse : e.nodes)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
62
|
+
if reverse
|
63
|
+
document.css('trkpt').reverse.each_with_index { |e, i| e.css('name').first.content = "WP #{i + 1}" }
|
64
|
+
else
|
65
|
+
document.css('trkpt').each_with_index { |e, i| e.css('name').first.content = "WP #{i + 1}" }
|
66
|
+
end
|
67
|
+
|
60
68
|
document.human
|
61
69
|
end
|
70
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
62
71
|
|
63
72
|
def document
|
64
73
|
@document ||= Nokogiri::XML(
|
data/script/bootstrap
ADDED
data/script/ci
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpx_track_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: nokogiri-pretty
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: thor
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,7 +92,8 @@ files:
|
|
106
92
|
- config/rubocop/include.yml
|
107
93
|
- cucumber.yml
|
108
94
|
- doc/licenses/dependencies.db
|
109
|
-
- features/create_gpx_track_file.feature
|
95
|
+
- features/create_gpx_track_file-cli.feature
|
96
|
+
- features/create_gpx_track_file-ruby.feature
|
110
97
|
- features/step_definitions.rb
|
111
98
|
- features/support/aruba.rb
|
112
99
|
- features/support/ci.rb
|
@@ -123,9 +110,13 @@ files:
|
|
123
110
|
- lib/gpx_track_generator/gpx_file.rb
|
124
111
|
- lib/gpx_track_generator/logger.rb
|
125
112
|
- lib/gpx_track_generator/main.rb
|
113
|
+
- lib/gpx_track_generator/pretty.rb
|
114
|
+
- lib/gpx_track_generator/pretty.xslt
|
126
115
|
- lib/gpx_track_generator/runner.rb
|
127
116
|
- lib/gpx_track_generator/track.rb
|
128
117
|
- lib/gpx_track_generator/version.rb
|
118
|
+
- script/bootstrap
|
119
|
+
- script/ci
|
129
120
|
- spec/spec_helper.rb
|
130
121
|
- spec/support/aruba.rb
|
131
122
|
- spec/support/ci.rb
|
@@ -157,7 +148,8 @@ signing_key:
|
|
157
148
|
specification_version: 4
|
158
149
|
summary: Generate a gpx track from gpx tracks/routes
|
159
150
|
test_files:
|
160
|
-
- features/create_gpx_track_file.feature
|
151
|
+
- features/create_gpx_track_file-cli.feature
|
152
|
+
- features/create_gpx_track_file-ruby.feature
|
161
153
|
- features/step_definitions.rb
|
162
154
|
- features/support/aruba.rb
|
163
155
|
- features/support/ci.rb
|