βHow to convert a CSV file into a routing requestβ
βI have a list of GPS points in a CSV file and I want to build a route from it using TraceRoute.β
Hereβs a sample of the CSV you might have:
latitude;longitude;date;section;speed;time;heading
43.7316541;7.4207476;23/10/2020;1;6;09:43:35;90.0
43.7310649;7.4184731;23/10/2020;1;6;09:43:38;93.0
...
What we care about:
latitudeandlongitudeβ GPS positionspeedβ speed in km/htimeβ the hour/minute/secondheadingβ optional direction We will ignoredate,section, etc. for now.
Each row becomes a destination in the request. For example:
{
"coordinateSat": {
"lon": 7.4207476,
"lat": 43.7316541,
"speed": 6.0,
"time": 1603446215000,
"heading": 90.0
}
}π The
timemust be converted into Unix timestamp in milliseconds. If you donβt know how to do this, just use tools or ask for help β itβs usually okay to reuse existing examples.
We will add:
- A transport mode (e.g. CAR)
- Options like
ROUTESHEETandPOLYLINE - The list of destinations from your CSV
Hereβs a complete JSON built from the first 10 rows of your CSV:
{
"routingVehicleProfile": {
"transportMode": "CAR"
},
"options": ["ROUTESHEET", "POLYLINE"],
"destinations": [
{
"coordinateSat": {
"lon": 7.4207476,
"lat": 43.7316541,
"speed": 6.0,
"time": 1603446215000,
"heading": 90.0
}
},
{
"coordinateSat": {
"lon": 7.4184731,
"lat": 43.7310649,
"speed": 6.0,
"time": 1603446218000,
"heading": 93.0
}
},
{
"coordinateSat": {
"lon": 7.4166278,
"lat": 43.7298245,
"speed": 6.0,
"time": 1603446230000,
"heading": 77.8
}
},
{
"coordinateSat": {
"lon": 7.4155120,
"lat": 43.7290182,
"speed": 6.0,
"time": 1603446236000,
"heading": -33.4
}
},
{
"coordinateSat": {
"lon": 7.4143962,
"lat": 43.7279638,
"speed": 6.0,
"time": 1603446244000,
"heading": -31.4
}
},
{
"coordinateSat": {
"lon": 7.4138383,
"lat": 43.7273746,
"speed": 6.0,
"time": 1603446254000,
"heading": -33.4
}
},
{
"coordinateSat": {
"lon": 7.4128512,
"lat": 43.7279328,
"speed": 6.0,
"time": 1603446269000,
"heading": -37.6
}
},
{
"coordinateSat": {
"lon": 7.4137954,
"lat": 43.7286461,
"speed": 6.0,
"time": 1603446333000,
"heading": -34.7
}
},
{
"coordinateSat": {
"lon": 7.4137954,
"lat": 43.7297935,
"speed": 6.0,
"time": 1603446348000,
"heading": -21.2
}
},
{
"coordinateSat": {
"lon": 7.4123792,
"lat": 43.7311890,
"speed": 6.0,
"time": 1603446360000,
"heading": -28.3
}
}
]
}