diff options
| author | Zog | 2018-03-05 12:00:29 +0100 |
|---|---|---|
| committer | Zog | 2018-03-05 12:00:29 +0100 |
| commit | a412f915c885f3bf2962d0b786ff864f1b0e120e (patch) | |
| tree | 3352d379f3d5c963f4382c374c6e78eea33cb2e1 /app/models/chouette/journey_pattern.rb | |
| parent | ea3de6035cdf9fbbcd92f51c90e5a2c5c3400cb3 (diff) | |
| download | chouette-core-a412f915c885f3bf2962d0b786ff864f1b0e120e.tar.bz2 | |
Refs #6068; Add some helpers in the models
Diffstat (limited to 'app/models/chouette/journey_pattern.rb')
| -rw-r--r-- | app/models/chouette/journey_pattern.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb index 830e985d9..10c8b5439 100644 --- a/app/models/chouette/journey_pattern.rb +++ b/app/models/chouette/journey_pattern.rb @@ -171,6 +171,19 @@ module Chouette full end + def distance_to stop + val = 0 + i = 0 + _end = stop_points.first + while _end != stop + i += 1 + _start = _end + _end = stop_points[i] + val += costs_between(_start, _end)[:distance] + end + val + end + def set_distances distances raise "inconsistent data: #{distances.count} values for #{stop_points.count} stops" unless distances.count == stop_points.count prev = distances[0].to_i |
