Class: Polyline::Normalizer::RoadSegment
- Inherits:
-
Object
- Object
- Polyline::Normalizer::RoadSegment
- Defined in:
- lib/polyline/normalizer/road_segment.rb
Constant Summary collapse
- EARTHS_RADIUS =
meters
6_371_000.to_f
- DEGREES_TO_RADIANS =
Math::PI / 180
Instance Attribute Summary collapse
-
#distance_threshold ⇒ Object
Returns the value of attribute distance_threshold.
-
#input ⇒ Object
Returns the value of attribute input.
-
#points ⇒ Object
Returns the value of attribute points.
Instance Method Summary collapse
-
#initialize(input, distance_threshold: 5000) ⇒ RoadSegment
constructor
A new instance of RoadSegment.
- #normalize ⇒ Object
Constructor Details
#initialize(input, distance_threshold: 5000) ⇒ RoadSegment
Returns a new instance of RoadSegment.
15 16 17 18 19 |
# File 'lib/polyline/normalizer/road_segment.rb', line 15 def initialize(input, distance_threshold: 5000) self.input = input self.distance_threshold = distance_threshold self.points = FastPolylines.decode(input).uniq end |
Instance Attribute Details
#distance_threshold ⇒ Object
Returns the value of attribute distance_threshold.
9 10 11 |
# File 'lib/polyline/normalizer/road_segment.rb', line 9 def distance_threshold @distance_threshold end |
#input ⇒ Object
Returns the value of attribute input.
9 10 11 |
# File 'lib/polyline/normalizer/road_segment.rb', line 9 def input @input end |
#points ⇒ Object
Returns the value of attribute points.
9 10 11 |
# File 'lib/polyline/normalizer/road_segment.rb', line 9 def points @points end |
Instance Method Details
#normalize ⇒ Object
21 22 23 |
# File 'lib/polyline/normalizer/road_segment.rb', line 21 def normalize @normalize ||= FastPolylines.encode(join(divide)) end |