simple-trail 0.0.1 → 0.0.3

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: 771ec560b97a81804d55ad4c0531618fed43ac6464c792d87886d75b36e8f533
4
- data.tar.gz: ace4e431118ca132f53c8c020342cf8708ed6cfb29b919fba6438fe266ea7595
3
+ metadata.gz: 4708a23602be79835bd4571f488ea1a6bb34cb27077ed7a3ee27b2b9085c4f10
4
+ data.tar.gz: 34b942f6bca75eb207ec7a12c1950ebf4d17b2bae740d0b2d678a2df11a4b00c
5
5
  SHA512:
6
- metadata.gz: 60f8b68d945a6f0965496820336c826622ec28266ee9aaa6c2919b7351f88685f26bc3562c03a15964904af3225482d47f11ac2a5e69cf5fe91211d413e3263f
7
- data.tar.gz: cebe448307ebde21a25ec57b91e01d90f4d85e58517f2eeebe1f5673b7503b39acba4ffb015ff8cbc333259b4f7eb7149b0b6be2a9cee14856d77e46e8ddb7b4
6
+ metadata.gz: 5ffae4a26011fe622d7acbb1eb70bd5e3814051356e611e60dfba8cdaac4964ed40d5331629a382d1f6833ff5e9719269144fc9854bbc78f07f1f42dfc94f97a
7
+ data.tar.gz: 0e70b0dc79e59266e53479cffd4464bd543a4288b8b111e3b0aa90dca700ad8b554c4285e687709006ea0656920ca5eba1704d3374122e487640fb8ce19b65ba
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Manipulation
4
4
  class Straightener
5
+ attr_reader :points, :cluster_groups
6
+
5
7
  def initialize(points)
6
8
  @points = points
7
9
  @latlng_points = @points.map { |p| Geokit::LatLng.new(p[:lat], p[:lon]) }
@@ -10,12 +12,11 @@ module Manipulation
10
12
  def points_without_clusters
11
13
  @average_distance_between ||= average_distance_between
12
14
  @possible_clusters = detect_clusters
13
- smoothe_points!
15
+ straighten_points!
14
16
  end
15
17
 
16
- def smoothe_points!
17
- group_clusters
18
- straighten_points!
18
+ def cluster_groups
19
+ @cluster_groups ||= group_clusters
19
20
  end
20
21
 
21
22
  private
@@ -42,7 +43,7 @@ module Manipulation
42
43
  end
43
44
 
44
45
  def straighten_points!
45
- @cluster_groups.each do |cluster_group|
46
+ cluster_groups.each do |cluster_group|
46
47
  cluster_coords = @points.values_at(*cluster_group)
47
48
  avg_lat = cluster_coords.map { |cc| cc[:lat].to_f }.inject(:+) / cluster_coords.size
48
49
  avg_lon = cluster_coords.map { |cc| cc[:lon].to_f }.inject(:+) / cluster_coords.size
@@ -11,6 +11,7 @@ module Parser
11
11
  def read
12
12
  file = File.new(@filename)
13
13
  @parsed_file = XmlHasher.parse(file)[:gpx]
14
+ fail unless @parsed_file
14
15
  extract_points
15
16
  end
16
17
 
@@ -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.0.1'
8
+ s.version = '0.0.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'
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.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staszek Zawadzki
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.1.2
123
+ rubygems_version: 3.0.8
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Readind and manipulating GPX and other trail representation file