Class: Routing::Adapter::Here

Inherits:
RestAdapter show all
Defined in:
lib/routing/adapter/here.rb

Overview

Adapter for a Nokia Here Routing Service v7 server. It passes the GeoPoints to the routing service and will return another Array of GeoPoints, representing the calculated route.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RestAdapter

#params

Constructor Details

#initialize(attrs = {}) ⇒ Here

Returns a new instance of Here.



21
22
23
24
25
26
# File 'lib/routing/adapter/here.rb', line 21

def initialize(attrs = {})
  attrs[:host] ||= 'route.api.here.com'
  attrs[:path] ||= '/routing/7.2/calculateroute.json'
  attrs[:parser] ||= ::Routing::Parser::HereSimple
  super(attrs)
end

Class Method Details

.default_paramsObject



11
12
13
14
15
16
17
18
19
# File 'lib/routing/adapter/here.rb', line 11

def self.default_params
  {
    departure:          Time.now.utc.iso8601,
    mode:               "fastest;car",
    language:           "de_DE",
    legattributes:      "all,-links",
    maneuverattributes: "position,travelTime,length,time"
  }
end

Instance Method Details

#calculate(geo_points) ⇒ Object



28
29
30
31
# File 'lib/routing/adapter/here.rb', line 28

def calculate(geo_points)
  response = request(params.merge(convert_geo_points_to_params(geo_points)).merge(credentials))
  parse(response.body)
end