simple-trail 0.2.1 → 0.2.3
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 +4 -4
- data/README.md +13 -0
- data/build.sh +1 -0
- data/lib/simple_trail/generator/gpx.rb +1 -1
- data/lib/simple_trail/manipulation/enricher.rb +6 -3
- data/simple-trail.gemspec +1 -1
- data/spec/manipulation/enricher_spec.rb +25 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c180996e2776e5fb60fdf00b41066805dce00d7d565bb976f78323ea5219f31a
|
4
|
+
data.tar.gz: 6b0fd52172d3e74cdeca5a93835a7475fd13260a565c1bf204cbf0f7999c163f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b974bb1e33754b9c48e58ff10db10d558e0ce12acda9ec292f63e5bef128e1d6fd03a2c96fbf81fb0c5c30d0fc44478566c5f8be317129fea6d7b926cb4cf0
|
7
|
+
data.tar.gz: bd5e486c6b1e8dbf29fbc56fefdc0fbdc386e306d13d59f3bd1e98cc27028655fee69455690e37beef1f5c12abbfe3f43cade3b2f3b80e12cbeadc6927f7dfb3
|
data/README.md
CHANGED
@@ -3,4 +3,17 @@
|
|
3
3
|
.h3 Purpose
|
4
4
|
Reading and interpretation on trail files (GPX,...)
|
5
5
|
|
6
|
+
.h3 Usage
|
7
|
+
|
8
|
+
```
|
9
|
+
@parser = Parser::Gpx.new(@file)
|
10
|
+
|
11
|
+
@parser.read
|
12
|
+
@points = @parser.points
|
13
|
+
```
|
14
|
+
|
15
|
+
```
|
16
|
+
Manipulation::Enricher.new(@points, @enrichment_level, @offset).enrich
|
17
|
+
```
|
18
|
+
|
6
19
|
Licence: MIT
|
data/build.sh
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem build *.gemspec -o pkg/simple-trail.gem
|
@@ -20,8 +20,8 @@ module Generator
|
|
20
20
|
def gpx
|
21
21
|
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
22
22
|
xml.gpx(version: '1.0') {
|
23
|
-
xml.name { @name }
|
24
23
|
xml.trk {
|
24
|
+
xml.name { @name }
|
25
25
|
xml.trkseg {
|
26
26
|
@points.map do |point|
|
27
27
|
xml.trkpt(lat: point[:lat], lon: point[:lon]) {
|
@@ -4,9 +4,10 @@ module Manipulation
|
|
4
4
|
class Enricher
|
5
5
|
attr_reader :enriched_points
|
6
6
|
|
7
|
-
def initialize(points, distance_limit=nil)
|
7
|
+
def initialize(points, distance_limit=nil, offset=0)
|
8
8
|
@points = points
|
9
9
|
@distance_limit = distance_limit
|
10
|
+
@offset = offset
|
10
11
|
@counter = 3
|
11
12
|
end
|
12
13
|
|
@@ -75,13 +76,15 @@ module Manipulation
|
|
75
76
|
|
76
77
|
def add_km_markers
|
77
78
|
total_distance = @points[-1][:total_distance].floor - 1
|
78
|
-
|
79
|
+
start_v = @offset.to_f.ceil
|
80
|
+
|
81
|
+
(start_v..start_v+total_distance).each do |i|
|
79
82
|
find_and_enrich_first_occurence(i+1)
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
83
86
|
def find_and_enrich_first_occurence(i)
|
84
|
-
index = @points.find_index{|point| point[:total_distance] > i}
|
87
|
+
index = @points.find_index{|point| point[:total_distance] + @offset > i}
|
85
88
|
@points[index].merge!(label: i)
|
86
89
|
end
|
87
90
|
|
data/simple-trail.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 = 'simple-trail'
|
8
|
-
s.version = '0.2.
|
8
|
+
s.version = '0.2.3'
|
9
9
|
s.date = '2020-08-03'
|
10
10
|
s.summary = 'Readind and manipulating GPX and other trail representation file'
|
11
11
|
s.description = 'Optimazing and manipulating GPX file data. For my private purposes mostly'
|
@@ -36,4 +36,29 @@ RSpec.describe Manipulation::Enricher do
|
|
36
36
|
expect(enrichement_logic.enriched_points.count).not_to eq point_count
|
37
37
|
expect(enrichement_logic.enriched_points.all?{|point| !point[:ele].nil?}).to be(true)
|
38
38
|
end
|
39
|
+
|
40
|
+
it 'adds labels' do
|
41
|
+
parser = Parser::Gpx.new('./spec/examples/gss20-full-official.gpx')
|
42
|
+
parser.read
|
43
|
+
|
44
|
+
enrichement_logic = described_class.new(parser.points, 0.1)
|
45
|
+
enrichement_logic.enrich
|
46
|
+
|
47
|
+
labels = enrichement_logic.enriched_points.map{|h| h[:label]}.compact.uniq
|
48
|
+
expect(labels.size).to eq 506
|
49
|
+
expect(labels.include?(1)).to be(true)
|
50
|
+
expect(labels.include?(535)).to be(false)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'adds labels with offset' do
|
54
|
+
parser = Parser::Gpx.new('./spec/examples/gss20-full-official.gpx')
|
55
|
+
parser.read
|
56
|
+
|
57
|
+
enrichement_logic = described_class.new(parser.points, 0.1, 50)
|
58
|
+
enrichement_logic.enrich
|
59
|
+
labels = enrichement_logic.enriched_points.map{|h| h[:label]}.compact.uniq
|
60
|
+
expect(labels.size).to eq 506
|
61
|
+
expect(labels.include?(1)).to be(false)
|
62
|
+
expect(labels.include?(535)).to be(true)
|
63
|
+
end
|
39
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Staszek Zawadzki
|
@@ -88,6 +88,7 @@ extra_rdoc_files: []
|
|
88
88
|
files:
|
89
89
|
- ".rubocop.yml"
|
90
90
|
- README.md
|
91
|
+
- build.sh
|
91
92
|
- install.sh
|
92
93
|
- lib/simple_trail.rb
|
93
94
|
- lib/simple_trail/generator/gpx.rb
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.1.4
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Readind and manipulating GPX and other trail representation file
|