From: Simon Poole Date: Tue, 29 Jan 2019 19:03:30 +0000 (+0000) Subject: Remove old MapQuest Directions routing support X-Git-Tag: live~2699^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/26102f581fbd88449b3c850685c4e4058fec0df9?ds=inline Remove old MapQuest Directions routing support --- diff --git a/app/assets/javascripts/index/directions/mapquest.js b/app/assets/javascripts/index/directions/mapquest.js deleted file mode 100644 index 739ce6539..000000000 --- a/app/assets/javascripts/index/directions/mapquest.js +++ /dev/null @@ -1,105 +0,0 @@ -// For docs, see: -// https://developer.mapquest.com/web/products/open/directions-service -// https://open.mapquestapi.com/directions/ -// https://github.com/apmon/openstreetmap-website/blob/21edc353a4558006f0ce23f5ec3930be6a7d4c8b/app/controllers/routing_controller.rb#L153 - -function MapQuestEngine(id, routeType) { - var MQ_SPRITE_MAP = { - 0: 0, // straight - 1: 1, // slight right - 2: 2, // right - 3: 3, // sharp right - 4: 4, // reverse - 5: 7, // sharp left - 6: 6, // left - 7: 5, // slight left - 8: 4, // right U-turn - 9: 4, // left U-turn - 10: 21, // right merge - 11: 20, // left merge - 12: 21, // right on-ramp - 13: 20, // left on-ramp - 14: 24, // right off-ramp - 15: 25, // left off-ramp - 16: 18, // right fork - 17: 19, // left fork - 18: 0 // straight fork - }; - - return { - id: id, - creditline: 'MapQuest ', - draggable: false, - - getRoute: function (points, callback) { - var from = points[0]; - var to = points[points.length - 1]; - - return $.ajax({ - url: OSM.MAPQUEST_DIRECTIONS_URL, - data: { - key: OSM.MAPQUEST_KEY, - from: from.lat + "," + from.lng, - to: to.lat + "," + to.lng, - routeType: routeType, - // locale: I18n.currentLocale(), //Doesn't actually work. MapQuest requires full locale e.g. "de_DE", but I18n may only provides language, e.g. "de" - manMaps: false, - shapeFormat: "raw", - generalize: 0, - unit: "k" - }, - dataType: "jsonp", - success: function (data) { - if (data.info.statuscode !== 0) - return callback(true); - - var i; - var line = []; - var shape = data.route.shape.shapePoints; - for (i = 0; i < shape.length; i += 2) { - line.push(L.latLng(shape[i], shape[i + 1])); - } - - // data.route.shape.maneuverIndexes links turns to polyline positions - // data.route.legs[0].maneuvers is list of turns - var steps = []; - var mq = data.route.legs[0].maneuvers; - for (i = 0; i < mq.length; i++) { - var s = mq[i]; - var d; - var linesegstart, linesegend, lineseg; - linesegstart = data.route.shape.maneuverIndexes[i]; - if (i === mq.length - 1) { - d = 15; - linesegend = linesegstart + 1; - } else { - d = MQ_SPRITE_MAP[s.turnType]; - linesegend = data.route.shape.maneuverIndexes[i + 1] + 1; - } - lineseg = []; - for (var j = linesegstart; j < linesegend; j++) { - lineseg.push(L.latLng(data.route.shape.shapePoints[j * 2], data.route.shape.shapePoints[j * 2 + 1])); - } - steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance * 1000, lineseg]); - } - - callback(false, { - line: line, - steps: steps, - distance: data.route.distance * 1000, - time: data.route.time - }); - }, - error: function () { - callback(true); - } - }); - } - }; -} - -if (OSM.MAPQUEST_KEY) { - OSM.Directions.addEngine(new MapQuestEngine("mapquest_bicycle", "bicycle"), true); - OSM.Directions.addEngine(new MapQuestEngine("mapquest_foot", "pedestrian"), true); - OSM.Directions.addEngine(new MapQuestEngine("mapquest_car", "fastest"), true); -} diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 7e7e6a5fa..a9e1a475e 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -14,13 +14,9 @@ OSM = { OVERPASS_URL: <%= OVERPASS_URL.to_json %>, NOMINATIM_URL: <%= NOMINATIM_URL.to_json %>, GRAPHHOPPER_URL: <%= GRAPHHOPPER_URL.to_json %>, - MAPQUEST_DIRECTIONS_URL: <%= MAPQUEST_DIRECTIONS_URL.to_json %>, FOSSGIS_OSRM_URL: <%= FOSSGIS_OSRM_URL.to_json %>, DEFAULT_LOCALE: <%= I18n.default_locale.to_json %>, -<% if defined?(MAPQUEST_KEY) %> - MAPQUEST_KEY: <%= MAPQUEST_KEY.to_json %>, -<% end %> <% if defined?(THUNDERFOREST_KEY) %> THUNDERFOREST_KEY: <%= THUNDERFOREST_KEY.to_json %>, <% end %> diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 71d5e8231..9666adf12 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -335,9 +335,7 @@ class ApplicationController < ActionController::Base :frame_src => %w[http://127.0.0.1:8111 https://127.0.0.1:8112], :connect_src => [NOMINATIM_URL, OVERPASS_URL, FOSSGIS_OSRM_URL, GRAPHHOPPER_URL], :form_action => %w[render.openstreetmap.org], - :style_src => %w['unsafe-inline'], - :script_src => [MAPQUEST_DIRECTIONS_URL], - :img_src => %w[developer.mapquest.com] + :style_src => %w['unsafe-inline'] ) if STATUS == :database_offline || STATUS == :api_offline diff --git a/config/example.application.yml b/config/example.application.yml index fc9b795db..7db7861b2 100644 --- a/config/example.application.yml +++ b/config/example.application.yml @@ -104,7 +104,6 @@ defaults: &defaults overpass_url: "https://overpass-api.de/api/interpreter" # Routing endpoints graphhopper_url: "https://graphhopper.com/api/1/route" - mapquest_directions_url: "https://open.mapquestapi.com/directions/v2/route" fossgis_osrm_url: "https://routing.openstreetmap.de/" # External authentication credentials #google_auth_id: "" @@ -118,8 +117,6 @@ defaults: &defaults #github_auth_secret: "" #wikipedia_auth_id: "" #wikipedia_auth_secret: "" - # MapQuest authentication details - #mapquest_key: "" # Thunderforest authentication details #thunderforest_key: "" # Key for generating TOTP tokens diff --git a/config/locales/en.yml b/config/locales/en.yml index 958f109b9..a81172de2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2444,9 +2444,6 @@ en: graphhopper_bicycle: "Bicycle (GraphHopper)" graphhopper_car: "Car (GraphHopper)" graphhopper_foot: "Foot (GraphHopper)" - mapquest_bicycle: "Bicycle (MapQuest)" - mapquest_car: "Car (MapQuest)" - mapquest_foot: "Foot (MapQuest)" descend: "Descend" directions: "Directions" distance: "Distance"