Class: Polylines::Encoder

Inherits:
Base
  • Object
show all
Defined in:
lib/polylines/encoder.rb

Instance Attribute Summary

Attributes inherited from Base

#current_value, #negative

Class Method Summary collapse

Methods inherited from Base

#decode!, #decoding?, #encode!, #encoding?, #initialize, #step_10, #step_11, #step_2, #step_3, #step_4, #step_5, #step_6, #step_7, #step_8, transform_to_array_of_lat_lng_and_deltas

Constructor Details

This class inherits a constructor from Polylines::Base

Class Method Details

.encode(number, precision = 1e5) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/polylines/encoder.rb', line 8

def self.encode(number, precision = 1e5)
  self.new(number).tap do |encoding|
    encoding.step_2 precision
    encoding.step_3
    encoding.step_4
    encoding.step_5
    encoding.step_6
    encoding.step_7
    encoding.step_8
    encoding.step_10
    encoding.step_11
  end.current_value
end

.encode_points(points, precision = 1e5) ⇒ Object


3
4
5
6
# File 'lib/polylines/encoder.rb', line 3

def self.encode_points(points, precision = 1e5)
  points_with_deltas = transform_to_array_of_lat_lng_and_deltas(points, precision)
  points_with_deltas.map {|point| encode(point, precision) }.join
end