gpx_track_generator 0.1.1 → 0.2.0
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/README.md +22 -1
- data/features/create_gpx_track_file.feature +32 -0
- data/lib/gpx_track_generator/api.rb +2 -2
- data/lib/gpx_track_generator/runner.rb +2 -1
- data/lib/gpx_track_generator/track.rb +4 -3
- 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: f44774183c934f97efb98d4910bb2385086c1ecc
|
4
|
+
data.tar.gz: b940a57bc8c2ab82b9fdd651f4835febdad04e1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 034cb1be0f7e552973be8c614da2c40d936a461391ca5d3a03165b84a166f914ddd41515ab5f255b2d5b7f24d2491a068b7466e55a7cc78d6bfde4d55c15bad3
|
7
|
+
data.tar.gz: c1eba84912141b2485453c348eff409bbdbf79a6a8ee0fa8b38cc47959c012392df70dedec54eeb6d9dfbaf4a00f6a8d5b32d67b85b54d42b457722bbb3b48d9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,8 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
Create your track file from ruby code. This can be helpful in your `Rakefile`.
|
27
27
|
|
28
|
+
*Create track file*
|
29
|
+
|
28
30
|
```ruby
|
29
31
|
input_files = %w(track1.gpx route2.gpx)
|
30
32
|
track_name = 'Track ABC'
|
@@ -37,6 +39,21 @@ GpxTrackGenerator::Api.generate(
|
|
37
39
|
)
|
38
40
|
```
|
39
41
|
|
42
|
+
*Reverse track*
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
input_files = %w(track1.gpx route2.gpx)
|
46
|
+
track_name = 'Track ABC'
|
47
|
+
output_file = 'my_track.gpx'
|
48
|
+
|
49
|
+
GpxTrackGenerator::Api.generate(
|
50
|
+
input_files: input_files,
|
51
|
+
track_name: track_name,
|
52
|
+
output_file: output_file,
|
53
|
+
reverse: true
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
40
57
|
### CLI
|
41
58
|
|
42
59
|
*Create track file*
|
@@ -51,7 +68,11 @@ gpx_track *.gpx
|
|
51
68
|
gpx_track --name "Track Name" *.gpx
|
52
69
|
```
|
53
70
|
|
54
|
-
|
71
|
+
*Reverse track*
|
72
|
+
|
73
|
+
```
|
74
|
+
gpx_track --name "Track Name" --reverse *.gpx
|
75
|
+
```
|
55
76
|
|
56
77
|
## Contributing
|
57
78
|
|
@@ -38,3 +38,35 @@ Feature: Create GPX Track File
|
|
38
38
|
"""
|
39
39
|
<name>Track #1</name>
|
40
40
|
"""
|
41
|
+
|
42
|
+
Scenario: Normal order track
|
43
|
+
Given a gpx file named "track1.gpx"
|
44
|
+
And a gpx file named "track2.gpx"
|
45
|
+
When I successfully run `gpx_track g track1.gpx track2.gpx`
|
46
|
+
Then the gpx file "track.gpx" should contain:
|
47
|
+
"""
|
48
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
49
|
+
<name>WP 1</name>
|
50
|
+
<ele>16.232316396783801</ele>
|
51
|
+
</trkpt>
|
52
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
53
|
+
<name>WP 2</name>
|
54
|
+
<ele>16.232316396783801</ele>
|
55
|
+
</trkpt>
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: Reverse track
|
59
|
+
Given a gpx file named "track1.gpx"
|
60
|
+
And a gpx file named "track2.gpx"
|
61
|
+
When I successfully run `gpx_track g --reverse track1.gpx track2.gpx`
|
62
|
+
Then the gpx file "track.gpx" should contain:
|
63
|
+
"""
|
64
|
+
<trkpt lat="57.688634024660372" lon="-6.5744374090151107">
|
65
|
+
<name>WP 2</name>
|
66
|
+
<ele>16.232316396783801</ele>
|
67
|
+
</trkpt>
|
68
|
+
<trkpt lat="56.688634024660372" lon="-6.5744374090151107">
|
69
|
+
<name>WP 1</name>
|
70
|
+
<ele>16.232316396783801</ele>
|
71
|
+
</trkpt>
|
72
|
+
"""
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module GpxTrackGenerator
|
3
3
|
# Main api
|
4
4
|
module Api
|
5
|
-
def self.generate(input_files:, track_name:, output_file:)
|
5
|
+
def self.generate(input_files:, track_name:, output_file:, reverse: false)
|
6
6
|
files = input_files.map { |f| GpxFile.new(File.expand_path(f)) }
|
7
|
-
track = Track.new(files, name: track_name)
|
7
|
+
track = Track.new(files, name: track_name, reverse: reverse)
|
8
8
|
|
9
9
|
File.write(output_file, track.to_s)
|
10
10
|
end
|
@@ -4,11 +4,12 @@ module GpxTrackGenerator
|
|
4
4
|
class Runner < Thor
|
5
5
|
option :file, default: 'track.gpx', desc: 'GPX track file name'
|
6
6
|
option :name, default: 'Track #1', required: true, desc: 'Name for track'
|
7
|
+
option :reverse, type: :boolean, desc: 'Reverse track'
|
7
8
|
argument :input_files, type: :array, desc: 'GPX track or route files'
|
8
9
|
|
9
10
|
desc 'generate', 'Generate gpx track'
|
10
11
|
def generate
|
11
|
-
Api.generate(input_files: input_files, track_name: options[:name], output_file: options[:file])
|
12
|
+
Api.generate(input_files: input_files, track_name: options[:name], output_file: options[:file], reverse: options[:reverse])
|
12
13
|
end
|
13
14
|
|
14
15
|
default_command :generate
|
@@ -4,13 +4,14 @@ module GpxTrackGenerator
|
|
4
4
|
class Track
|
5
5
|
private
|
6
6
|
|
7
|
-
attr_reader :files, :name
|
7
|
+
attr_reader :files, :name, :reverse
|
8
8
|
|
9
9
|
public
|
10
10
|
|
11
|
-
def initialize(files, name:)
|
11
|
+
def initialize(files, name:, reverse:)
|
12
12
|
@files = files
|
13
13
|
@name = name
|
14
|
+
@reverse = reverse
|
14
15
|
end
|
15
16
|
|
16
17
|
def to_s
|
@@ -37,7 +38,7 @@ module GpxTrackGenerator
|
|
37
38
|
files.each_with_object(document.css('trk').first) do |e, a|
|
38
39
|
a << "<!-- #{e.file_name} -->"
|
39
40
|
a << document.create_element('trkseg')
|
40
|
-
a.css('trkseg').last << e.nodes
|
41
|
+
a.css('trkseg').last << (reverse ? e.nodes.reverse : e.nodes)
|
41
42
|
end
|
42
43
|
|
43
44
|
document.human
|