diff options
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | config/secrets.yml | 3 | ||||
| -rw-r--r-- | lib/osrm_route_section_processor.rb | 10 |
3 files changed, 18 insertions, 4 deletions
@@ -122,6 +122,10 @@ Configure the way that Chouette2 sends e-mail. * Edit [devise_async.rb](./config/initializer/devise_async.rb) and uncomment and set```Devise::Async.enabled``` ( true if you want to use asynchronously and false otherwise ) * see [Devise Async specification](https://github.com/mhfs/devise-async) +Configure OSRM Backend URL +* Edit [secrets.yml](./config/secrets.yml) and change```osrm_endpoint``` +* see [Project-OSRM](https://github.com/Project-OSRM/osrm-backend/wiki/Api-usage-policy) + Run --- @@ -169,6 +173,11 @@ License This project is licensed under the CeCILL-B license, a copy of which can be found in the [LICENSE](./LICENSE.md) file. +Project-OSRM Licence +------------------------- + +Project-OSRM is licensed under the [ODbL](http://opendatacommons.org/licenses/odbl/) licence. + Release Notes ------------- diff --git a/config/secrets.yml b/config/secrets.yml index 8b1ad59e2..a1eea33ac 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -16,12 +16,14 @@ development: google_analytic_tracker: "UA-AAAAAAAA" # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa" newrelic_licence_key: "" + osrm_endpoint: "http//router.project-osrm.org" test: secret_key_base: 54f61aab23322611dd0bbf73b7f034db34281f7f4b3c4992eaaff20ecc9673bbd467beaa6fcb48379ca69b80bc5662deac4e33ca144f2482146123d3e966016a api_endpoint: "http://localhost:8080/chouette_iev/" google_analytic_tracker: "UA-AAAAAAAA" # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa" + osrm_endpoint: "http//router.project-osrm.org" # Do not keep production secrets in the repository, # instead read values from the environment. @@ -31,3 +33,4 @@ production: google_analytic_tracker: "UA-AAAAAAAA" # geoportail_api_key: "aaaaaaaaaaaaaaaaaaaaaa" newrelic_licence_key: "" + osrm_endpoint: "" diff --git a/lib/osrm_route_section_processor.rb b/lib/osrm_route_section_processor.rb index 5f3bdef29..e9f92def0 100644 --- a/lib/osrm_route_section_processor.rb +++ b/lib/osrm_route_section_processor.rb @@ -3,13 +3,15 @@ require 'open-uri' class OsrmRouteSectionProcessor def call(route_section) + osrm_endpoint = Rails.application.secrets.osrm_endpoint + points_string = (route_section.input_geometry || route_section.default_geometry).points.map do |point| "loc=#{point.y.to_f},#{point.x.to_f}" end.join - Rails.logger.info "Invoke router.project-osrm.org for RouteSection StopArea:#{route_section.departure.id} -> StopArea:#{route_section.arrival.id}" + Rails.logger.info "Invoke #{osrm_endpoint} for RouteSection StopArea:#{route_section.departure.id} -> StopArea:#{route_section.arrival.id}" - response = open "http://router.project-osrm.org/viaroute?#{points_string}instructions=false" + response = open "#{osrm_endpoint}/viaroute?#{points_string}instructions=false" return nil unless response geometry = JSON.parse(response.read.to_s)['route_geometry'] @@ -21,10 +23,10 @@ class OsrmRouteSectionProcessor GeoRuby::SimpleFeatures::LineString.from_points(decoded_geometry).try(:to_rgeo) if decoded_geometry.many? end rescue OpenURI::HTTPError => e - Rails.logger.error "router.project-osrm.org failed: #{e}" + Rails.logger.error "#{osrm_endpoint} failed: #{e}" nil rescue IOError => e - Rails.logger.error "router.project-osrm.org failed: #{e}" + Rails.logger.error "#{osrm_endpoint} failed: #{e}" nil end |
