-
Notifications
You must be signed in to change notification settings - Fork 1
/
experimentalAPI.ts
57 lines (54 loc) · 1.62 KB
/
experimentalAPI.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Axios, { AxiosPromise } from "axios";
import { RouteResponse } from "./generated/graphhopper-api/model/route-response";
import * as papa from "papaparse";
// TODO: if the binary endpoint in https://github.com/graphhopper/isochrone-experiments/
// is significantly faster, consider updating and supporting that
/**
* Get SPT info to be used as basis for Isochrone visualization.
* This endpoint isn't in the OpenAPI spec yet, and thus not in our generated client
*/
export async function getSPT(params: any, basePath: string) {
const data = await Axios.request<any, AxiosPromise<any>>({
url: basePath + "/spt",
params,
method: "GET",
});
if (data.status == 200) {
const parseResult = papa.parse(data.data, {
header: true,
dynamicTyping: true,
skipEmptyLines: true,
});
if (parseResult.errors.length) {
throw new Error("error during parsing of csv");
}
data.data = parseResult.data as any;
}
return data;
}
export type GraphHopperInfo = {
bbox: [number, number, number, number];
profiles: Array<{
name: string;
vehicle: string;
}>;
supported_vehicles: string[];
version: string;
elevation: boolean;
encoded_values: { [encoded_value: string]: string[] };
import_date: string;
data_date: string;
prepare_ch_date: string;
prepare_date: string;
};
/**
* Get info about the GraphHopper instance
* This endpoint isn't in the OpenAPI spec yet, and thus not in our generated client
*/
export async function getInfo(params: any, basePath: string) {
return Axios.request<GraphHopperInfo>({
url: basePath + "/info",
method: "GET",
params,
});
}