simple-trail 0.3.1 → 0.3.2

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: 80b11153dae6617beaa321a66212e18b3d2f10aa986cbaccc07904faa15be4dd
4
- data.tar.gz: a40a3b05bb2538c74f53185b5f2f5addc6932f14708e92d256be68ce26f21f7c
3
+ metadata.gz: 01fc41a9ee4029834332f22d8cc513e8b12e2d8490e91b144cdd10c9b04f8bab
4
+ data.tar.gz: 841468837b2f944c7825751b6ddee2d174caa2d4bc4b1e4933664969ef7e5b79
5
5
  SHA512:
6
- metadata.gz: 138f814cd98017dcd61aef761afc5c4a6ea1c21f426052ca56ed987928ce028e0d6da82e2aa13c2cdc03d41f93b9685fbfb0aa1dafc828b23357a758c8167bd0
7
- data.tar.gz: c81fb032d0e916da5624407741055741e50bc955d146b69599ac7a5270787bb41f02c4b7642d966a4e6c1fde8a56defb6134283593b9dedfdfee7410df61e72e
6
+ metadata.gz: 46b758ae075b90f1694c4ccb5a48926fefc835f274f0f62014e13f9c792f6c41e306e0fc39d36621f21f700f601f3b4d5652835bbac942891c7c9c1bfbef7406
7
+ data.tar.gz: e3dbb0f40a6f2b31b81f0e5be17762689ff4fcf08b57618bdcc1210c30d03df8fad70c278a94714551548123301c1ca6109756fce066296d2ba9ef7f1fa9a416
@@ -9,9 +9,34 @@ module Parser
9
9
  end
10
10
 
11
11
  def read_points
12
- segments = @parsed_file.dig(:trk, :trkseg)
13
- @points = segments.is_a?(Array) ? segments.map { |seg| seg[:trkpt] }.flatten : segments[:trkpt]
14
- @simplified_points = @points.map { |point| point.select { |key, _| [:lon, :lat].include? key } }
12
+
13
+ main_node = @parsed_file.fetch(:trk)
14
+
15
+ if main_node.is_a?(Array)
16
+ @simplified_points = []
17
+ @points = []
18
+
19
+ main_node.each do |segment|
20
+ @simplified_points << simplified_points_selection(segment)
21
+ @points << segment_points_selection(segment)
22
+ end
23
+
24
+ @simplified_points.flatten!
25
+ @points.flatten!
26
+ else
27
+ segments = main_node.fetch(:trkseg)
28
+ @points = segments.is_a?(Array) ? segments.map { |seg| seg[:trkpt] }.flatten : segments[:trkpt]
29
+ @simplified_points = @points.map { |point| point.select { |key, _| [:lon, :lat].include? key } }
30
+ end
31
+ end
32
+
33
+ def segment_points_selection(segment)
34
+ segments = segment.fetch(:trkseg)
35
+ segments.is_a?(Array) ? segments.map { |seg| seg[:trkpt] }.flatten : segments[:trkpt]
36
+ end
37
+
38
+ def simplified_points_selection(segment)
39
+ segment_points_selection(segment).map { |point| point.select { |key, _| [:lon, :lat].include? key } }
15
40
  end
16
41
  end
17
42
  end
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.3.1'
8
+ s.version = '0.3.2'
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'