gpx 0.9.0 → 1.0.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.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +165 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +15 -12
- data/bin/gpx_distance +3 -6
- data/bin/gpx_smooth +20 -24
- data/gpx.gemspec +12 -11
- data/lib/gpx.rb +11 -34
- data/lib/gpx/bounds.rb +10 -31
- data/lib/gpx/gpx.rb +2 -26
- data/lib/gpx/gpx_file.rb +112 -108
- data/lib/gpx/magellan_track_log.rb +32 -66
- data/lib/gpx/point.rb +18 -35
- data/lib/gpx/route.rb +7 -31
- data/lib/gpx/segment.rb +56 -88
- data/lib/gpx/track.rb +31 -42
- data/lib/gpx/track_point.rb +30 -0
- data/lib/gpx/version.rb +1 -1
- data/lib/gpx/waypoint.rb +7 -34
- data/tests/gpx10_test.rb +5 -6
- data/tests/gpx_file_test.rb +29 -19
- data/tests/gpx_files/with_empty_tracks.gpx +72 -0
- data/tests/magellan_test.rb +10 -11
- data/tests/output_test.rb +92 -95
- data/tests/route_test.rb +25 -32
- data/tests/segment_test.rb +93 -94
- data/tests/track_file_test.rb +47 -70
- data/tests/track_point_test.rb +20 -11
- data/tests/track_test.rb +71 -61
- data/tests/waypoint_test.rb +44 -48
- metadata +29 -13
- data/lib/gpx/trackpoint.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4aa764ea01fcc4255a69ff9bad6d1c159fc8ae8a1b29c0e54d05b9fe2b0e0bc9
|
4
|
+
data.tar.gz: 699edd3b9dec8cc83ac136c90b81f428a60ed8359aa01445ef3aead1a343c0d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43dc778d82e3b044ef872c219a60a703a6e4e53845817e783c464b36b37b60647eb5c390e2b16df1f1bb51b5359d2eae5a05e39fdb352ee3e2eaec179e007b9e
|
7
|
+
data.tar.gz: a6aa72c84b2ff150569506a27889835b818057a549a72d44ad163e81ef5000dd936ca91b8da7faf3a44150ec66bdbe6bb1630291dbeeca5c3416f676130c368a
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
|
4
|
+
Style/Alias:
|
5
|
+
Enabled: false
|
6
|
+
StyleGuide: http://relaxed.ruby.style/#stylealias
|
7
|
+
|
8
|
+
Style/AsciiComments:
|
9
|
+
Enabled: false
|
10
|
+
StyleGuide: http://relaxed.ruby.style/#styleasciicomments
|
11
|
+
|
12
|
+
Style/BeginBlock:
|
13
|
+
Enabled: false
|
14
|
+
StyleGuide: http://relaxed.ruby.style/#stylebeginblock
|
15
|
+
|
16
|
+
Style/BlockDelimiters:
|
17
|
+
Enabled: false
|
18
|
+
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
|
19
|
+
|
20
|
+
Style/CommentAnnotation:
|
21
|
+
Enabled: false
|
22
|
+
StyleGuide: http://relaxed.ruby.style/#stylecommentannotation
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
27
|
+
|
28
|
+
Layout/DotPosition:
|
29
|
+
Enabled: false
|
30
|
+
StyleGuide: http://relaxed.ruby.style/#layoutdotposition
|
31
|
+
|
32
|
+
Style/DoubleNegation:
|
33
|
+
Enabled: false
|
34
|
+
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
|
35
|
+
|
36
|
+
Style/EndBlock:
|
37
|
+
Enabled: false
|
38
|
+
StyleGuide: http://relaxed.ruby.style/#styleendblock
|
39
|
+
|
40
|
+
Style/FormatString:
|
41
|
+
Enabled: false
|
42
|
+
StyleGuide: http://relaxed.ruby.style/#styleformatstring
|
43
|
+
|
44
|
+
Style/IfUnlessModifier:
|
45
|
+
Enabled: false
|
46
|
+
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
|
47
|
+
|
48
|
+
Style/Lambda:
|
49
|
+
Enabled: false
|
50
|
+
StyleGuide: http://relaxed.ruby.style/#stylelambda
|
51
|
+
|
52
|
+
Style/ModuleFunction:
|
53
|
+
Enabled: false
|
54
|
+
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
|
55
|
+
|
56
|
+
Style/MultilineBlockChain:
|
57
|
+
Enabled: false
|
58
|
+
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
|
59
|
+
|
60
|
+
Style/NegatedIf:
|
61
|
+
Enabled: false
|
62
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
|
63
|
+
|
64
|
+
Style/NegatedWhile:
|
65
|
+
Enabled: false
|
66
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
|
67
|
+
|
68
|
+
Style/ParallelAssignment:
|
69
|
+
Enabled: false
|
70
|
+
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
|
71
|
+
|
72
|
+
Style/PercentLiteralDelimiters:
|
73
|
+
Enabled: false
|
74
|
+
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
|
75
|
+
|
76
|
+
Style/PerlBackrefs:
|
77
|
+
Enabled: false
|
78
|
+
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
|
79
|
+
|
80
|
+
Style/Semicolon:
|
81
|
+
Enabled: false
|
82
|
+
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
|
83
|
+
|
84
|
+
Style/SignalException:
|
85
|
+
Enabled: false
|
86
|
+
StyleGuide: http://relaxed.ruby.style/#stylesignalexception
|
87
|
+
|
88
|
+
Style/SingleLineBlockParams:
|
89
|
+
Enabled: false
|
90
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
|
91
|
+
|
92
|
+
Style/SingleLineMethods:
|
93
|
+
Enabled: false
|
94
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
|
95
|
+
|
96
|
+
Layout/SpaceBeforeBlockBraces:
|
97
|
+
Enabled: false
|
98
|
+
StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces
|
99
|
+
|
100
|
+
Layout/SpaceInsideParens:
|
101
|
+
Enabled: false
|
102
|
+
StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens
|
103
|
+
|
104
|
+
Style/SpecialGlobalVars:
|
105
|
+
Enabled: false
|
106
|
+
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
|
107
|
+
|
108
|
+
Style/StringLiterals:
|
109
|
+
Enabled: false
|
110
|
+
StyleGuide: http://relaxed.ruby.style/#stylestringliterals
|
111
|
+
|
112
|
+
Style/WhileUntilModifier:
|
113
|
+
Enabled: false
|
114
|
+
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
|
115
|
+
|
116
|
+
Style/WordArray:
|
117
|
+
Enabled: false
|
118
|
+
StyleGuide: http://relaxed.ruby.style/#stylewordarray
|
119
|
+
|
120
|
+
Lint/AmbiguousRegexpLiteral:
|
121
|
+
Enabled: false
|
122
|
+
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
|
123
|
+
|
124
|
+
Lint/AssignmentInCondition:
|
125
|
+
Enabled: false
|
126
|
+
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
|
127
|
+
|
128
|
+
Metrics/AbcSize:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
Metrics/BlockNesting:
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
Metrics/ClassLength:
|
135
|
+
Enabled: false
|
136
|
+
|
137
|
+
Metrics/ModuleLength:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
Metrics/CyclomaticComplexity:
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
Metrics/LineLength:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
Metrics/MethodLength:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
Metrics/ParameterLists:
|
150
|
+
Enabled: false
|
151
|
+
|
152
|
+
Metrics/PerceivedComplexity:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
Naming/UncommunicativeMethodParamName:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
Naming/VariableNumber:
|
159
|
+
Enabled: false
|
160
|
+
|
161
|
+
Style/DateTime:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
Performance/Caller:
|
165
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.0.0] - 2018-03-06
|
2
|
+
|
3
|
+
* Fix duplication of points on appending segment to track (#20 via @niborg)
|
4
|
+
* Remove pythagorean distance (#28 fixing #27, via @moveson)
|
5
|
+
* Ignore empty segments (#29 via @nathanvda)
|
6
|
+
* Introduce Rubocop (#31)
|
7
|
+
* Explicit test support for Ruby 2.5 (#30)
|
8
|
+
|
1
9
|
## [0.9.0] - 2017-01-05
|
2
10
|
|
3
11
|
* Upgrade Nokogiri deps to be more explicit, then explicitly bump the Ruby
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rdoc/task'
|
4
|
+
require 'rubocop/rake_task'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
RuboCop::RakeTask.new
|
7
|
+
|
8
|
+
desc 'Default Task'
|
9
|
+
task default: %i[test rubocop]
|
7
10
|
|
8
11
|
namespace :ci do
|
9
12
|
task :build do
|
10
|
-
puts
|
11
|
-
FileUtils.mkdir_p
|
13
|
+
puts 'Creating tests/output directory...'
|
14
|
+
FileUtils.mkdir_p 'tests/output'
|
12
15
|
Rake::Task[:test].invoke
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
19
|
# Run the unit tests
|
17
|
-
desc
|
18
|
-
Rake::TestTask.new(
|
19
|
-
t.libs <<
|
20
|
+
desc 'Run all unit tests'
|
21
|
+
Rake::TestTask.new('test') do |t|
|
22
|
+
t.libs << 'lib'
|
20
23
|
t.pattern = 'tests/*_test.rb'
|
21
24
|
t.verbose = true
|
22
|
-
|
25
|
+
end
|
23
26
|
|
24
27
|
# Genereate the RDoc documentation
|
25
|
-
desc
|
26
|
-
Rake::RDocTask.new(
|
27
|
-
rdoc.title =
|
28
|
+
desc 'Create documentation'
|
29
|
+
Rake::RDocTask.new('doc') do |rdoc|
|
30
|
+
rdoc.title = 'Ruby GPX API'
|
28
31
|
rdoc.rdoc_dir = 'html'
|
29
32
|
rdoc.rdoc_files.include('README')
|
30
33
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
|
-
|
34
|
+
end
|
data/bin/gpx_distance
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.expand_path('
|
2
|
+
|
3
|
+
require File.expand_path('../lib/gpx', __dir__)
|
4
4
|
|
5
5
|
filename = ARGV[0]
|
6
|
-
gpx =
|
6
|
+
gpx = GPX::GPXFile.new(gpx_file: filename)
|
7
7
|
puts "read track with distance #{gpx.distance}"
|
8
|
-
|
9
|
-
|
10
|
-
|
data/bin/gpx_smooth
CHANGED
@@ -1,63 +1,59 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.expand_path('../../lib/gpx', __FILE__)
|
4
|
-
require 'optparse'
|
5
2
|
|
3
|
+
require File.expand_path('../lib/gpx', __dir__)
|
4
|
+
require 'optparse'
|
6
5
|
|
7
6
|
def str_to_int_or_time(str)
|
8
7
|
if str =~ /\A\d{10}\Z/
|
9
|
-
|
8
|
+
Time.at(str.to_i)
|
10
9
|
elsif str =~ /\A\d+\Z/
|
11
|
-
|
10
|
+
str.to_i
|
12
11
|
else
|
13
|
-
|
12
|
+
DateTime.strptime(str, '%Y%m%d-%H:%M:%S').to_time
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
16
|
options = {}
|
19
17
|
OptionParser.new do |opts|
|
20
|
-
opts.banner =
|
18
|
+
opts.banner = 'Usage: smooth [options]'
|
21
19
|
|
22
|
-
opts.on(
|
20
|
+
opts.on('-i', '--input-file FILE', 'Input file to read gpx data from (if omitted, data will be read from stdin)') do |v|
|
23
21
|
options[:infile] = v
|
24
22
|
end
|
25
|
-
opts.on(
|
23
|
+
opts.on('-o', '--output-file FILE', 'Output file to write smoothed gpx data to (if omitted, data will be written to stdout)') do |v|
|
26
24
|
options[:outfile] = v
|
27
25
|
end
|
28
|
-
opts.on(
|
26
|
+
opts.on('-s', '--start-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]', 'Start smoothing from time or offset specified (if omitted start from the start of the file)') do |v|
|
29
27
|
options[:start] = v
|
30
28
|
end
|
31
|
-
opts.on(
|
29
|
+
opts.on('-e', '--end-time [YYYYMMDD-HH:MM:SS|EPOCH|OFFSET]', 'Finish smoothing from time or offset specified (if omitted finish at the end of the file)') do |v|
|
32
30
|
options[:end] = v
|
33
31
|
end
|
34
32
|
end.parse!
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
34
|
+
input = if options[:infile]
|
35
|
+
File.open(options[:infile])
|
36
|
+
else
|
37
|
+
$stdin
|
38
|
+
end
|
42
39
|
|
43
40
|
options[:start] = str_to_int_or_time(options[:start]) if options[:start]
|
44
41
|
options[:end] = str_to_int_or_time(options[:end]) if options[:end]
|
45
42
|
|
46
|
-
gpx =
|
47
|
-
|
43
|
+
gpx = GPX::GPXFile.new(gpx_data: input)
|
44
|
+
warn "read track with distance #{gpx.distance}"
|
48
45
|
|
49
|
-
#1419062980
|
46
|
+
# 1419062980
|
50
47
|
gpx.tracks.each do |track|
|
51
48
|
track.segments.each do |segment|
|
52
|
-
segment.smooth_location_by_average(
|
49
|
+
segment.smooth_location_by_average(end: options[:end], start: options[:start])
|
53
50
|
end
|
54
51
|
end
|
55
52
|
gpx.recalculate_distance
|
56
|
-
|
53
|
+
warn "smoothed distance #{gpx.distance}"
|
57
54
|
|
58
55
|
if options[:outfile]
|
59
56
|
gpx.write(options[:outfile], false)
|
60
57
|
else
|
61
58
|
puts gpx.to_s(false)
|
62
59
|
end
|
63
|
-
|
data/gpx.gemspec
CHANGED
@@ -1,26 +1,27 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('
|
1
|
+
|
2
|
+
lib = File.expand_path('lib', __dir__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'gpx/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'gpx'
|
8
8
|
s.version = GPX::VERSION
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
9
|
+
s.authors = ['Guillaume Dott', 'Doug Fales', 'Andrew Hao']
|
10
|
+
s.email = ['guillaume+github@dott.fr', 'doug.fales@gmail.com', 'andrewhao@gmail.com']
|
11
|
+
s.summary = 'A basic API for reading and writing GPX files.'
|
12
|
+
s.description = 'A basic API for reading and writing GPX files.'
|
13
13
|
|
14
|
-
s.required_ruby_version = '~>2.
|
14
|
+
s.required_ruby_version = '~>2.2'
|
15
15
|
|
16
|
-
s.files = `git ls-files`.split(
|
16
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
-
s.require_paths = [
|
18
|
+
s.require_paths = ['lib']
|
19
19
|
s.has_rdoc = true
|
20
20
|
|
21
|
-
s.homepage =
|
22
|
-
s.add_dependency 'rake'
|
21
|
+
s.homepage = 'http://www.github.com/dougfales/gpx'
|
23
22
|
s.add_dependency 'nokogiri', '~>1.7'
|
23
|
+
s.add_dependency 'rake'
|
24
24
|
s.add_development_dependency 'bundler'
|
25
25
|
s.add_development_dependency 'minitest'
|
26
|
+
s.add_development_dependency 'rubocop'
|
26
27
|
end
|
data/lib/gpx.rb
CHANGED
@@ -1,38 +1,15 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006 Doug Fales
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
1
|
require 'time'
|
25
2
|
require 'nokogiri'
|
26
3
|
|
27
|
-
require File.expand_path('
|
4
|
+
require File.expand_path('gpx/version', __dir__)
|
28
5
|
|
29
|
-
require File.expand_path('
|
30
|
-
require File.expand_path('
|
31
|
-
require File.expand_path('
|
32
|
-
require File.expand_path('
|
33
|
-
require File.expand_path('
|
34
|
-
require File.expand_path('
|
35
|
-
require File.expand_path('
|
36
|
-
require File.expand_path('
|
37
|
-
require File.expand_path('
|
38
|
-
require File.expand_path('
|
6
|
+
require File.expand_path('gpx/gpx', __dir__)
|
7
|
+
require File.expand_path('gpx/gpx_file', __dir__)
|
8
|
+
require File.expand_path('gpx/bounds', __dir__)
|
9
|
+
require File.expand_path('gpx/track', __dir__)
|
10
|
+
require File.expand_path('gpx/route', __dir__)
|
11
|
+
require File.expand_path('gpx/segment', __dir__)
|
12
|
+
require File.expand_path('gpx/point', __dir__)
|
13
|
+
require File.expand_path('gpx/track_point', __dir__)
|
14
|
+
require File.expand_path('gpx/waypoint', __dir__)
|
15
|
+
require File.expand_path('gpx/magellan_track_log', __dir__)
|