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 3
3
import fetch from 'isomorphic-fetch'
4
4
import { decode as decodePolyline } from 'polyline'
5
5
import { isEqual as coordinatesAreEqual } from '@conveyal/lonlat'
6
- import qs from 'qs'
7
6
import lineString from 'turf-linestring'
8
7
9
8
// 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
204
203
}
205
204
// Use custom url if it exists, otherwise default to the hosted service.
206
205
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
+
214
207
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
+ }
216
228
) . then ( res => res . json ( ) )
217
229
}
You can’t perform that action at this time.
0 commit comments