gpx_manipulator 0.1.0 → 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/gpx_manipulator-0.1.0.gem +0 -0
- data/gpx_manipulator.gemspec +3 -3
- data/lib/gpx_manipulator/track.rb +14 -0
- data/spec/lib/gpx_manipulator/track_spec.rb +8 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518f9ddcea094f55a14951e9a835f552f286acccde1cb2c7c9f03322bf9c9f7e
|
4
|
+
data.tar.gz: 4d718ca75ba079f8d672361319d9fe34da1306394e8b231225c89c16dd10c72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7df6ad3001342bfa2aff32f7e6e4d447d36725f24e7a6c5365ef403d2edc86142a2eba30e7ad64d926b9ee92d7429584cbd22ca6de6f5c2d9daba9a418b5de
|
7
|
+
data.tar.gz: 4e35ad6e29701aab43a23a4e4614e0053a5ea526c8d0e0405f5a95ffaed95b6b359daf96cc02a6fef8786f65b5aa3eeaa090ce3a3ab88fdf5b16a46d2646ac8e
|
Binary file
|
data/gpx_manipulator.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'gpx_manipulator'
|
8
|
-
s.version = '0.
|
8
|
+
s.version = '0.2.0'
|
9
9
|
s.date = '2020-04-15'
|
10
10
|
s.summary = 'Manipulating GPX file'
|
11
11
|
s.description = 'Optimazing and manipulating GPX file data. For my private purposes, but maybe you\'ll find it helpfull'
|
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.license = 'MIT'
|
19
19
|
s.add_dependency 'geokit', '1.13'
|
20
20
|
s.add_dependency 'gpx', '1.0'
|
21
|
-
s.add_development_dependency 'pry', '
|
22
|
-
s.add_development_dependency 'rspec', '
|
21
|
+
s.add_development_dependency 'pry', '~> 0.13'
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
23
23
|
end
|
@@ -13,6 +13,20 @@ class Track
|
|
13
13
|
@points ||= @track.points
|
14
14
|
end
|
15
15
|
|
16
|
+
def total_elevation_gain
|
17
|
+
sum = 0.0
|
18
|
+
pair_size = points.size - 1
|
19
|
+
|
20
|
+
pair_size.times do |i|
|
21
|
+
sum += ascent(points[i], points[i+1])
|
22
|
+
end
|
23
|
+
sum.floor
|
24
|
+
end
|
25
|
+
|
26
|
+
def ascent(start, finish)
|
27
|
+
[0, finish.elevation - start.elevation].max
|
28
|
+
end
|
29
|
+
|
16
30
|
def distance_in_straigh_line(start: points.first, finish: points.last)
|
17
31
|
Geokit::LatLng.new(*to_lat_lng(start))
|
18
32
|
.distance_to(to_lat_lng_str(finish)).round(3)
|
@@ -46,6 +46,14 @@ RSpec.describe Track do
|
|
46
46
|
expect(track.back_to_start?).to be(true)
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'counts total ascend' do
|
50
|
+
read_file = ReadGpx.new(file: './spec/example_files/small.gpx')
|
51
|
+
read_file.read
|
52
|
+
|
53
|
+
track = described_class.new(track: read_file.tracks.first)
|
54
|
+
expect(track.total_elevation_gain).to eq 2215
|
55
|
+
end
|
56
|
+
|
49
57
|
context 'with lat/lng optimization' do
|
50
58
|
it 'returns points in simple format' do
|
51
59
|
read_file = ReadGpx.new(file: './spec/example_files/tiny.gpx')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpx_manipulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Staszek Zawadzki
|
@@ -42,28 +42,28 @@ dependencies:
|
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.13'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.9'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.9'
|
69
69
|
description: Optimazing and manipulating GPX file data. For my private purposes, but
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- Gemfile.lock
|
81
81
|
- README.md
|
82
82
|
- gpx_manipulator-0.0.1.gem
|
83
|
+
- gpx_manipulator-0.1.0.gem
|
83
84
|
- gpx_manipulator.gemspec
|
84
85
|
- lib/gpx_manipulator.rb
|
85
86
|
- lib/gpx_manipulator/points.rb
|