simple-trail 0.1.3 → 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/lib/simple_trail/generator/gpx.rb +29 -0
- data/lib/simple_trail.rb +1 -0
- data/simple-trail.gemspec +2 -1
- data/spec/generator/gpx_spec.rb +21 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aba06ca65c57e7950b28e45822dcddaa944b6375eb6e8d1ceedaee8031f1e163
|
4
|
+
data.tar.gz: 3b82b1e9d848442630deaa9b09ea4fa02c51dce42cf86a980d1abb823746a82e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c43bd89ba95b26820580c88afbd6b327fac9c1edb4ab42a38441703d1d93be7c3f5cf33a9ee9fe99848875030a2de788a55c14db4c8fd7483090f154c7bd72
|
7
|
+
data.tar.gz: 98cd69d440cd930578cea1ebc9b0240f885fa508f62860e7acd75668a89b2e692304e8d5cc90720818b71dcb1bcaa6c5d5ca9abb0892b98c0ea79e3f9b2533c7
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Generator
|
4
|
+
class Gpx
|
5
|
+
attr_reader :output
|
6
|
+
|
7
|
+
def initialize(points:, name: 'GPX file')
|
8
|
+
@points = points
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def gpx
|
13
|
+
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
14
|
+
xml.gpx(version: '1.0') {
|
15
|
+
xml.name { @name }
|
16
|
+
xml.trk {
|
17
|
+
xml.trkseg {
|
18
|
+
@points.map do |point|
|
19
|
+
xml.trkpt(lat: point[:lat], lon: point[:lon])
|
20
|
+
end
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
@output = builder.to_xml
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/simple_trail.rb
CHANGED
@@ -8,6 +8,7 @@ require File.expand_path('simple_trail/manipulation/statistics', __dir__)
|
|
8
8
|
require File.expand_path('simple_trail/manipulation/straightener', __dir__)
|
9
9
|
require File.expand_path('simple_trail/manipulation/unifier', __dir__)
|
10
10
|
require File.expand_path('simple_trail/manipulation/enricher', __dir__)
|
11
|
+
require File.expand_path('simple_trail/generator/gpx', __dir__)
|
11
12
|
|
12
13
|
module SimpleTrail
|
13
14
|
Geokit.default_units = :kms
|
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.
|
8
|
+
s.version = '0.2.0'
|
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'
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.license = 'MIT'
|
19
19
|
s.add_dependency 'geokit', '1.13'
|
20
20
|
s.add_dependency 'xmlhasher', '~> 1.0'
|
21
|
+
s.add_dependency 'nokogiri', '~> 1.13'
|
21
22
|
s.add_development_dependency 'pry', '~> 0.13'
|
22
23
|
s.add_development_dependency 'rspec', '~> 3.9'
|
23
24
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Generator::Gpx do
|
6
|
+
it 'generates output' do
|
7
|
+
parser = Parser::Gpx.new('./spec/examples/test_1.gpx')
|
8
|
+
parser.read
|
9
|
+
|
10
|
+
points = parser.points
|
11
|
+
|
12
|
+
service = described_class.new(points: points)
|
13
|
+
expect{service.gpx}.not_to raise_error
|
14
|
+
output = service.output
|
15
|
+
expect(output).not_to be_nil
|
16
|
+
|
17
|
+
random_point = points.sample
|
18
|
+
expect(output.match(/#{random_point[:lon]}/)).not_to be_nil
|
19
|
+
expect(output.match(/#{random_point[:lat]}/)).not_to be_nil
|
20
|
+
end
|
21
|
+
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Staszek Zawadzki
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.13'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +90,7 @@ files:
|
|
76
90
|
- README.md
|
77
91
|
- install.sh
|
78
92
|
- lib/simple_trail.rb
|
93
|
+
- lib/simple_trail/generator/gpx.rb
|
79
94
|
- lib/simple_trail/manipulation/enricher.rb
|
80
95
|
- lib/simple_trail/manipulation/statistics.rb
|
81
96
|
- lib/simple_trail/manipulation/straightener.rb
|
@@ -100,6 +115,7 @@ files:
|
|
100
115
|
- spec/examples/test_9.gpx
|
101
116
|
- spec/examples/test_with_segments.gpx
|
102
117
|
- spec/examples/zyleta2021.gpx
|
118
|
+
- spec/generator/gpx_spec.rb
|
103
119
|
- spec/manipulation/enricher_spec.rb
|
104
120
|
- spec/manipulation/statistics_spec.rb
|
105
121
|
- spec/manipulation/straightener_spec.rb
|
@@ -126,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
142
|
- !ruby/object:Gem::Version
|
127
143
|
version: '0'
|
128
144
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.2.15
|
130
146
|
signing_key:
|
131
147
|
specification_version: 4
|
132
148
|
summary: Readind and manipulating GPX and other trail representation file
|
@@ -149,6 +165,7 @@ test_files:
|
|
149
165
|
- spec/examples/test_9.gpx
|
150
166
|
- spec/examples/test_with_segments.gpx
|
151
167
|
- spec/examples/zyleta2021.gpx
|
168
|
+
- spec/generator/gpx_spec.rb
|
152
169
|
- spec/manipulation/enricher_spec.rb
|
153
170
|
- spec/manipulation/statistics_spec.rb
|
154
171
|
- spec/manipulation/straightener_spec.rb
|