Class: Polyline::Normalizer::RoadSegment

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_thresholdObject

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

#inputObject

Returns the value of attribute input.



9
10
11
# File 'lib/polyline/normalizer/road_segment.rb', line 9

def input
  @input
end

#pointsObject

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

#normalizeObject



21
22
23
# File 'lib/polyline/normalizer/road_segment.rb', line 21

def normalize
  @normalize ||= FastPolylines.encode(join(divide))
end