Attālumu matricas serviss
The service allows you to get a matrix of distances (points between which you need to determine the distance and the time).
API URL
The request URL should match the following pattern:
https://api.kartes.lv/v3//calculate_matrix?
By default, the response is given in JSON (JSONP and XML are also available).
The HTTP GET request method is used.
- klienta_atslega: Your authorisation key.
Query parameters
The request consists of the following GET parameters:
Parameter | Description | Possible values |
---|---|---|
p | Teksts, kurā iekodētas punktu koordinātas, starp kurām jāveic attāluma aprēķināšana. Maksimālais punktu skaits - 15. | Jāatbilst šādam formātam: [[x1,y1],[x2,y2],…,[xn,yn]], kur:
|
wgs84 | Ja tiek padots šis parametrs, tad koordinātas parametrā p tiek padotas WGS84 (EPSG:4326) koordinātu sistēmā. Pēc noklusējuma koordinātas tiek padotas TM Baltic93 (EPSG:25884) koordinātu sistēmā. | |
weight | Autotransporta pašmasa kilogramos. | |
emergency | Ja tiek padots šis parametrs, tad maršrutēšana tiek veikta, pieņemot, ka transportlīdzeklis ir operatīvais transportlīdzeklis. | |
noentry | Teksts, kurā padod punktus, starp kuriem braukt ir aizliegts. Ievades formāts atbilst p parametra ievades formātam. | |
result_data_type | Nosaka atgriežamo datu formātu, ja netiek norādīts, tad pēc noklusējuma atgriež JSON. | Pieejami 3 formāti:
|
callback | Parametrs aktuāls, ja izvēlas result_data_type=jsonp, tad šī parametra funkcija tiek izsaukta, kad dati tiek atgriezti. |
Response parameters
Atbildē tiek atgriezta pati matrica, katrā rezultāta "šūnā" pieejami šādi dati:
- Distance - attālums no punkta A uz punktu B metros.
- Time - attāluma no punkta A uz punktu B veikšanai nepieciešamais laiks sekundēs.
- Score, Direction - tehniskie parametri, kurus klients var ignorēt.
Error codes
Status code | Description |
---|---|
200 | Missing input data. Tiek atgriezts, ja vaicājumā nav ievadītas punktu koordinātas. |
200 | Wrong input data. Server can’t respond due to client error. |
200 | Too many points, maximum allowed 15. Tiek atgriezts, ja vaicājumā norādīto punktu skaits pārsniedz 15. |
200 | Iespējamas kļūdas, ko ģenerē loģistikas serviss, piemēram Route not found (Flags: …) u.c. |
404 | No location found. The URL is not recognized; the resource does not exist. |
5xx | Server error. |
Examples
Input:
https://api.kartes.lv/v3//calculate_matrix?p=[[56.77017,24.77124],[56.66856,25.42099]]&wgs84&weight=50000&noentry=[[56.95138,24.09656],[56.96305,24.09539],[56.91045,24.7637]]
Response:
{
"matrix": {
"Dimension": 2,
"Matrix": [
[
[
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
},
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
}
],
[
{
"Distance": 46700.74,
"Time": 2150,
"Score": 0.0035773059353232,
"Direction": 0
},
{
"Distance": 47852.94,
"Time": 2265,
"Score": 0.0039888578467071,
"Direction": 0
}
]
],
[
[
{
"Distance": 46799.57,
"Time": 2155,
"Score": 0.0035754146520048,
"Direction": 1
},
{
"Distance": 46799.57,
"Time": 2155,
"Score": 0.0035754146520048,
"Direction": 1
}
],
[
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
},
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
}
]
]
]
},
"calc": 0.20980906486511
}
Input:
https://api.kartes.lv/v3//calculate_matrix?p=[[512159,6306468],[512133,6306442],[510561,6308316],[512367,6306283]]
Response:
{
"matrix": {
"Dimension": 4,
"Matrix": [
[
[
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
},
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
}
],
[
{
"Distance": 477.8,
"Time": 64,
"Score": 0.0001012386273942,
"Direction": 1
},
{
"Distance": 477.8,
"Time": 64,
"Score": 0.0001012386273942,
"Direction": 1
}
],
[
{
"Distance": 2526.01,
"Time": 182,
"Score": 0.00026312601403333,
"Direction": 1
},
{
"Distance": 2526.01,
"Time": 182,
"Score": 0.00026312601403333,
"Direction": 1
}
],
[
{
"Distance": 761.26,
"Time": 85,
"Score": 0.00013076540199108,
"Direction": 1
},
{
"Distance": 761.26,
"Time": 85,
"Score": 0.00013076540199108,
"Direction": 1
}
]
],
....
[
[
{
"Distance": 371.69,
"Time": 57,
"Score": 0.00010561797535047,
"Direction": 1
},
{
"Distance": 371.69,
"Time": 57,
"Score": 0.00010561797535047,
"Direction": 1
}
],
[
{
"Distance": 849.5,
"Time": 121,
"Score": 0.00020685661002062,
"Direction": 1
},
{
"Distance": 849.5,
"Time": 121,
"Score": 0.00020685661002062,
"Direction": 1
}
],
[
{
"Distance": 2897.7,
"Time": 239,
"Score": 0.0003687439893838,
"Direction": 1
},
{
"Distance": 2897.7,
"Time": 239,
"Score": 0.0003687439893838,
"Direction": 1
}
],
[
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
},
{
"Distance": 0,
"Time": 0,
"Score": 0,
"Direction": 0
}
]
]
]
},
"calc": 0.21299600601196
}