Class: Routing::Parser::NavteqSimple
- Inherits:
-
Object
- Object
- Routing::Parser::NavteqSimple
- Defined in:
- lib/routing/parser/navteq_simple.rb
Overview
A very simple parser implementation for a NAVTEQ LBSP Routing Service v6. It converts the json response of the routing service to an Array of GeoPoints.
Instance Method Summary collapse
-
#initialize(response) ⇒ NavteqSimple
constructor
Creates a new instance of the parser.
-
#to_geo_points ⇒ Array<GeoPoint>
Converts the server response in an Array of GeoPoints.
Constructor Details
#initialize(response) ⇒ NavteqSimple
Creates a new instance of the parser.
12 13 14 15 16 17 18 19 |
# File 'lib/routing/parser/navteq_simple.rb', line 12 def initialize(response) response = JSON.parse(response) check_for_error(response) @route = response["Response"]["Route"].first @overall_covered_distance = 0 @overall_relative_time = 0 end |
Instance Method Details
#to_geo_points ⇒ Array<GeoPoint>
Converts the server response in an Array of GeoPoints
25 26 27 28 29 30 31 32 |
# File 'lib/routing/parser/navteq_simple.rb', line 25 def to_geo_points legs = @route["Leg"] geo_points = legs.map { |leg| parse_leg(leg) }.flatten # At last we add the destination point geo_points << parse_maneuver(legs.last["Maneuver"].last, waypoint: true) geo_points end |