Class: Mapbox::Isochrone

Inherits:
Object
  • Object
show all
Includes:
APIOperations::Request
Defined in:
lib/mapbox/isochrone.rb

Class Method Summary collapse

Methods included from APIOperations::Request

included

Class Method Details

.assemble_params(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mapbox/isochrone.rb', line 5

def self.assemble_params(options={})
  contours_minutes = options[:contours_minutes]
  contours_colors = options[:contours_colors]
  
  params = ''
  opts = options.select { |key, value| key != :contours_minutes && key != :contours_colors }
  if opts.length > 0
    params += "#{params.length > 0 ? '&' : '?'}#{URI.encode_www_form(opts)}"
  end

  if contours_minutes  then
    params += "#{params.length > 0 ? '&' : '?'}contours_minutes=#{contours_minutes.join(',')}"
  end

  if contours_colors then
    params += "#{params.length > 0 ? '&' : '?'}contours_colors=#{contours_colors.join(',')}"
  end

  return params
end

.isochrone(profile, coordinates, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/mapbox/isochrone.rb', line 26

def self.isochrone(profile, coordinates, options={})
  params = self.assemble_params(options)
  
  return request(
      :get,
      "/isochrone/v1/mapbox/#{profile}/#{coordinates}#{params}",
      nil)
end