File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed
lib/scenario-editor/utils Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change 33import fetch from 'isomorphic-fetch'
44import { decode as decodePolyline } from 'polyline'
55import { isEqual as coordinatesAreEqual } from '@conveyal/lonlat'
6- import qs from 'qs'
76import lineString from 'turf-linestring'
87
98// This can be used for logging line strings to geojson.io URLs for easy
@@ -204,14 +203,27 @@ export function routeWithGraphHopper (points: Array<LatLng>): ?Promise<GraphHopp
204203 }
205204 // Use custom url if it exists, otherwise default to the hosted service.
206205 const GRAPH_HOPPER_URL = process . env . GRAPH_HOPPER_URL || 'https://graphhopper.com/api/1/'
207- const params = {
208- key : process . env . GRAPH_HOPPER_KEY ,
209- vehicle : 'car' ,
210- debug : true ,
211- type : 'json'
212- }
213- const locations = points . map ( p => ( `point=${ p . lat } ,${ p . lng } ` ) ) . join ( '&' )
206+
214207 return fetch (
215- `${ GRAPH_HOPPER_URL } route?${ locations } &${ qs . stringify ( params ) } `
208+ `${ GRAPH_HOPPER_URL } route?key=${ process . env . GRAPH_HOPPER_KEY } ` ,
209+ // New custom routing headers
210+ {
211+ method : 'POST' ,
212+ headers : {
213+ 'Content-Type' : 'application/json'
214+ } ,
215+ body : JSON . stringify ( {
216+ 'ch.disable' : true ,
217+ custom_model : {
218+ 'priority' : [ {
219+ 'if' : 'road_class == MOTORWAY' ,
220+ 'multiply_by' : 0.1
221+ } ]
222+ } ,
223+ key : process . env . GRAPH_HOPPER_KEY ,
224+ points : points . map ( p => [ p . lng , p . lat ] ) ,
225+ profile : 'car'
226+ } )
227+ }
216228 ) . then ( res => res . json ( ) )
217229}
You can’t perform that action at this time.
0 commit comments