mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
radar(): relax bounding box checks 🐛✅
to allow crossing the antimeridian & poles fixes https://github.com/derhuerst/hafas-monitor-trips/issues/12
This commit is contained in:
parent
66d9fb5194
commit
90b1140401
3 changed files with 158 additions and 4 deletions
13
index.js
13
index.js
|
@ -657,11 +657,16 @@ const createClient = (profile, userAgent, opt = {}) => {
|
|||
if ('number' !== typeof east) {
|
||||
throw new TypeError('east must be a number.');
|
||||
}
|
||||
if (north <= south) {
|
||||
throw new Error('north must be larger than south.');
|
||||
// With a bounding box across the antimeridian, east (e.g. -175) might be smaller than west (e.g. 175).
|
||||
// Likewise, across the north/south poles, north (e.g. -85) might be smaller than south (e.g. 85).
|
||||
// In these cases, the terms north/south & east/west become rather arbitrary of couse.
|
||||
// see also https://antimeridian.readthedocs.io/en/stable/
|
||||
// todo: how does HAFAS handle this?
|
||||
if (north === south) {
|
||||
throw new Error('bbox.north must not be equal to bbox.south.');
|
||||
}
|
||||
if (east <= west) {
|
||||
throw new Error('east must be larger than west.');
|
||||
if (east === west) {
|
||||
throw new Error('bbox.east must not be equal to bbox.west.');
|
||||
}
|
||||
|
||||
opt = Object.assign({
|
||||
|
|
|
@ -477,6 +477,19 @@ tap.test('radar', async (t) => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
tap.test('radar works across the antimeridian', async (t) => {
|
||||
await client.radar({
|
||||
north: -8,
|
||||
west: 179,
|
||||
south: -10,
|
||||
east: -179,
|
||||
}, {
|
||||
// todo: update `when`, re-record all fixtures, remove this special handling
|
||||
when: process.env.VCR_MODE ? '2024-02-22T16:00+01:00' : when,
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tap.test('reachableFrom', {timeout: 20 * 1000}, async (t) => {
|
||||
const torfstr17 = {
|
||||
type: 'location',
|
||||
|
|
|
@ -39368,6 +39368,142 @@
|
|||
"ssl": -1,
|
||||
"wait": 326
|
||||
}
|
||||
},
|
||||
{
|
||||
"_id": "e53d1b456d5b350c0572302394c4c4fb",
|
||||
"_order": 0,
|
||||
"cache": {},
|
||||
"request": {
|
||||
"bodySize": 512,
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "content-type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "accept-encoding",
|
||||
"value": "gzip, br, deflate"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "accept",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "user-agent",
|
||||
"value": "public50c138-transpor50c138t/haf50c138as-client50c138:test"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "content-length",
|
||||
"value": "512"
|
||||
},
|
||||
{
|
||||
"name": "host",
|
||||
"value": "reiseauskunft.bahn.de"
|
||||
}
|
||||
],
|
||||
"headersSize": 343,
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"method": "POST",
|
||||
"postData": {
|
||||
"mimeType": "application/json",
|
||||
"params": [],
|
||||
"text": "{\"lang\":\"en\",\"svcReqL\":[{\"meth\":\"JourneyGeoPos\",\"req\":{\"maxJny\":256,\"onlyRT\":false,\"date\":\"20240222\",\"time\":\"160000\",\"rect\":{\"llCrd\":{\"x\":179000000,\"y\":-10000000},\"urCrd\":{\"x\":-179000000,\"y\":-8000000}},\"perSize\":30000,\"perStep\":10000,\"ageOfReport\":true,\"jnyFltrL\":[{\"type\":\"PROD\",\"mode\":\"INC\",\"value\":\"1023\"}],\"trainPosMode\":\"CALC\"},\"cfg\":{\"rtMode\":\"REALTIME\"}}],\"client\":{\"type\":\"AND\",\"id\":\"DB\",\"v\":21120000,\"name\":\"DB Navigator\"},\"ext\":\"DB.R21.12.a\",\"ver\":\"1.34\",\"auth\":{\"type\":\"AID\",\"aid\":\"n91dB8Z77MLdoR0K\"}}"
|
||||
},
|
||||
"queryString": [
|
||||
{
|
||||
"name": "checksum",
|
||||
"value": "31be3d1db3730c00b04bc2c1f0fc35a6"
|
||||
}
|
||||
],
|
||||
"url": "https://reiseauskunft.bahn.de/bin/mgate.exe?checksum=31be3d1db3730c00b04bc2c1f0fc35a6"
|
||||
},
|
||||
"response": {
|
||||
"bodySize": 375,
|
||||
"content": {
|
||||
"mimeType": "application/json; charset=utf-8",
|
||||
"size": 375,
|
||||
"text": "{\"ver\":\"1.34\",\"ext\":\"DB.R21.12.a\",\"lang\":\"eng\",\"id\":\"vw22fngkmwkj928g\",\"err\":\"OK\",\"cInfo\":{\"code\":\"OK\"},\"graph\":{\"id\":\"standard\",\"index\":0},\"subGraph\":{\"id\":\"global\",\"index\":0},\"view\":{\"id\":\"standard\",\"index\":0,\"type\":\"WGS84\"},\"svcResL\":[{\"meth\":\"JourneyGeoPos\",\"err\":\"OK\",\"res\":{\"date\":\"20240222\",\"time\":\"160000\",\"fpB\":\"20231210\",\"fpE\":\"20241214\",\"planrtTS\":\"1708893245\"}}]}"
|
||||
},
|
||||
"cookies": [
|
||||
{
|
||||
"expires": "2024-03-03T20:36:02.000Z",
|
||||
"name": "AWSALB",
|
||||
"path": "/",
|
||||
"value": "J4t7tXbMG2lg31nXIBTJH3zo8sDRsTUIEnqOmiBhEoDtYGBpxR52hu2wfQP5+eCT0INYC8MaWym6BW20GoBKDszyAKMOExAMLZNzboW2HDerOk836by5gCycxCfp"
|
||||
},
|
||||
{
|
||||
"expires": "2024-03-03T20:36:02.000Z",
|
||||
"name": "AWSALBCORS",
|
||||
"path": "/",
|
||||
"sameSite": "None",
|
||||
"secure": true,
|
||||
"value": "J4t7tXbMG2lg31nXIBTJH3zo8sDRsTUIEnqOmiBhEoDtYGBpxR52hu2wfQP5+eCT0INYC8MaWym6BW20GoBKDszyAKMOExAMLZNzboW2HDerOk836by5gCycxCfp"
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "date",
|
||||
"value": "Sun, 25 Feb 2024 20:36:02 GMT"
|
||||
},
|
||||
{
|
||||
"name": "content-type",
|
||||
"value": "application/json; charset=utf-8"
|
||||
},
|
||||
{
|
||||
"name": "content-length",
|
||||
"value": 375
|
||||
},
|
||||
{
|
||||
"name": "connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "set-cookie",
|
||||
"value": "AWSALB=J4t7tXbMG2lg31nXIBTJH3zo8sDRsTUIEnqOmiBhEoDtYGBpxR52hu2wfQP5+eCT0INYC8MaWym6BW20GoBKDszyAKMOExAMLZNzboW2HDerOk836by5gCycxCfp; Expires=Sun, 03 Mar 2024 20:36:02 GMT; Path=/"
|
||||
},
|
||||
{
|
||||
"_fromType": "array",
|
||||
"name": "set-cookie",
|
||||
"value": "AWSALBCORS=J4t7tXbMG2lg31nXIBTJH3zo8sDRsTUIEnqOmiBhEoDtYGBpxR52hu2wfQP5+eCT0INYC8MaWym6BW20GoBKDszyAKMOExAMLZNzboW2HDerOk836by5gCycxCfp; Expires=Sun, 03 Mar 2024 20:36:02 GMT; Path=/; SameSite=None; Secure"
|
||||
},
|
||||
{
|
||||
"name": "server",
|
||||
"value": "Apache"
|
||||
},
|
||||
{
|
||||
"name": "strict-transport-security",
|
||||
"value": "max-age=16070400; includeSubDomains"
|
||||
}
|
||||
],
|
||||
"headersSize": 622,
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"redirectURL": "",
|
||||
"status": 200,
|
||||
"statusText": "OK"
|
||||
},
|
||||
"startedDateTime": "2024-02-25T20:35:53.142Z",
|
||||
"time": 205,
|
||||
"timings": {
|
||||
"blocked": -1,
|
||||
"connect": -1,
|
||||
"dns": -1,
|
||||
"receive": 0,
|
||||
"send": 0,
|
||||
"ssl": -1,
|
||||
"wait": 205
|
||||
}
|
||||
}
|
||||
],
|
||||
"pages": [],
|
||||
|
|
Loading…
Add table
Reference in a new issue