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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11981b376cbfe1d0b53a536f9f68c2fbb911ef02cc9df102be4c65aa42b263da
4
- data.tar.gz: '080e35ec71f87733b3f7e2f283b911b075dd99e868bbda2b5cda9fffb18ad60c'
3
+ metadata.gz: 518f9ddcea094f55a14951e9a835f552f286acccde1cb2c7c9f03322bf9c9f7e
4
+ data.tar.gz: 4d718ca75ba079f8d672361319d9fe34da1306394e8b231225c89c16dd10c72b
5
5
  SHA512:
6
- metadata.gz: c77e82ab92aa50efebb3ebfa4129420adc12e89815366ec165a32ca28ee0f9d329c9a076d396d0eb4abff256aadba535ae235733c02d33c2c396af817495d353
7
- data.tar.gz: fc0a25a918be06e2b375bdb5936dd314858a10303665967407ec99ba248b0d5caa380d82e30d17e9ef7ba638a463b0a0bb1b2b4bea115f8c714989ac4add5ec9
6
+ metadata.gz: db7df6ad3001342bfa2aff32f7e6e4d447d36725f24e7a6c5365ef403d2edc86142a2eba30e7ad64d926b9ee92d7429584cbd22ca6de6f5c2d9daba9a418b5de
7
+ data.tar.gz: 4e35ad6e29701aab43a23a4e4614e0053a5ea526c8d0e0405f5a95ffaed95b6b359daf96cc02a6fef8786f65b5aa3eeaa090ce3a3ab88fdf5b16a46d2646ac8e
Binary file
@@ -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.1.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', '>= 0.13'
22
- s.add_development_dependency 'rspec', '>= 3.9'
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.1.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