Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document which routes are GTFS-based & which HAFAS-based #45

Open
Cediddi opened this issue Jan 20, 2021 · 6 comments
Open

document which routes are GTFS-based & which HAFAS-based #45

Cediddi opened this issue Jan 20, 2021 · 6 comments
Labels

Comments

@Cediddi
Copy link

Cediddi commented Jan 20, 2021

Hi, I'm trying to use this library and I'm following a workflow like this:

  • Find stations by name (query='mollstr')
  • Select a station and get details (name='Berlin, Mollstr./Otto-Braun-Str.' id='900000100040')
  • Select a line from the station (name=M8 id='17463_900')
  • Select the variant with most trips (the one with 371 trips)
  • Get the first and last stop of that variant (first_stop_id='070301009267' last_stop_id='070301008858')

Last step throws an error like this:

{
  "isHafasError": true,
  "request": "{\"lang\":\"en\",\"svcReqL\":[{\"meth\":\"LocDetails\",\"req\":{\"locL\":[{\"type\":\"S\",\"lid\":\"A=1@L=001009267@\"}]}}],\"client\":{\"type\":\"IPA\",\"id\":\"VBB\",\"name\":\"vbbPROD\",\"v\":\"4010300\"},\"ext\":\"VBB.1\",\"ver\":\"1.16\",\"auth\":{\"type\":\"AID\",\"aid\":\"hafas-vbb-apps\"}}",
  "url": "https://fahrinfo.vbb.de/bin/mgate.exe?mic=bb4618f0b209632fb61e9dae462aabe2&mac=a246d90418328ad9249c3dda23fdc111",
  "statusCode": 400,
  "isClient": true,
  "code": "INVALID_REQUEST",
  "message": "location/stop not found",
  "hafasErrorCode": "LOCATION",
  "hafasErrorMessage": "HCI Service: location missing or invalid",
  "error": true,
  "msg": "HAFAS error: location/stop not found"
}

The query I'm running looks like this https://v5.vbb.transport.rest/stops/070301009267

I think my workflow is correct and this is a bug. Can you confirm?

@derhuerst
Copy link
Owner

  • Select a station and get details (name='Berlin, Mollstr./Otto-Braun-Str.' id='900000100040')

You're fetching https://v5.vbb.transport.rest/stops/900000100040?linesOfStops=true I assume?

  • Select a line from the station (name=M8 id='17463_900')

An M8 line with an id of 17463_900 doesn't exist for me:

curl 'https://v5.vbb.transport.rest/stops/900000100040?linesOfStops=true' -s | jq
{
	"type": "stop",
	"id": "900000100040",
	"name": "Mollstr./Otto-Braun-Str.",
	"location": {
		"type": "location",
		"id": "900100040",
		"latitude": 52.525185,
		"longitude": 13.419942
	},
	"products": {
		"suburban": false,
		"subway": false,
		"tram": true,
		"bus": true,
		"ferry": false,
		"express": false,
		"regional": false
	},
	"lines": [
		{
			"type": "line",
			"id": "12",
			"fahrtNr": null,
			"name": "12",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": null,
			"nr": 12,
			"metro": false,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#6c5b98"
			}
		},
		{
			"type": "line",
			"id": "50",
			"fahrtNr": null,
			"name": "50",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": null,
			"nr": 50,
			"metro": false,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#16a696"
			}
		},
		{
			"type": "line",
			"id": "m1",
			"fahrtNr": null,
			"name": "M1",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 1,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#ed9222"
			}
		},
		{
			"type": "line",
			"id": "m2",
			"fahrtNr": null,
			"name": "M2",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 2,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#7eb43d"
			}
		},
		{
			"type": "line",
			"id": "m4",
			"fahrtNr": null,
			"name": "M4",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 4,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#d01c22"
			}
		},
		{
			"type": "line",
			"id": "m5",
			"fahrtNr": null,
			"name": "M5",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 5,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#c48946"
			}
		},
		{
			"type": "line",
			"id": "m6",
			"fahrtNr": null,
			"name": "M6",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 6,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#01609c"
			}
		},
		{
			"type": "line",
			"id": "m8",
			"fahrtNr": null,
			"name": "M8",
			"public": true,
			"mode": "train",
			"product": "tram",
			"symbol": "M",
			"nr": 8,
			"metro": true,
			"express": false,
			"night": false,
			"color": {
				"fg": "#fff",
				"bg": "#f47922"
			}
		},
		{
			"type": "line",
			"id": "142",
			"fahrtNr": null,
			"name": "142",
			"public": true,
			"mode": "bus",
			"product": "bus",
			"symbol": null,
			"nr": 142,
			"metro": false,
			"express": false,
			"night": false
		},
		{
			"type": "line",
			"id": "200",
			"fahrtNr": null,
			"name": "200",
			"public": true,
			"mode": "bus",
			"product": "bus",
			"symbol": null,
			"nr": 200,
			"metro": false,
			"express": false,
			"night": false
		}
	]
}
  • Select the variant with most trips (the one with 371 trips)

How do you do that? Where do you get the number of trips from?

@Cediddi
Copy link
Author

Cediddi commented Jan 20, 2021

I can provide a pseudo code.

response = GET https://v5.vbb.transport.rest/stations?query=mollstr
station = select first from request where name = 'Berlin, Mollstr./Otto-Braun-Str.'

response = GET https://v5.vbb.transport.rest/stations/{station['id']}
line = select first from response['lines'] where name = 'M8'

response = GET https://v5.vbb.transport.rest/lines/{line['id']}
variant = select first from response['variants'] order by trips descending

first_stop = select first from variant['stops'] 

response = GET https://v5.vbb.transport.rest/stops/{first_stop}
// response is 502

I'm using python, you can check the script that I'm writing. Problematic part is line 186

https://gist.github.com/Cediddi/cfcf84aa3541a46beeee4064e3e33e40#file-allons_y-py-L186

@derhuerst
Copy link
Owner

Ah, now I understand the problem!

These routes just return GTFS data:

  • /stations?…
  • /stations/{id}
  • /lines/{id}

The other routes (including /stops/{id}) query VBB's HAFAS API.

Unfortunately, the GTFS stop/station IDs & line IDs don't always match the HAFAS stop/station IDs & line IDs. Most of the times they work with HAFAS, but "haltepunkt"-like stop IDs (e.g. those of individual tram tracks at a station) apparently don't.

Sorry, this is really not documented at all. 😔

@derhuerst derhuerst changed the title 502 when /stations/:id document which routes are GTFS-based & which HAFAS-based Jan 22, 2021
@derhuerst
Copy link
Owner

Can you tell me what you would like to build? Maybe I can tell you how to solve this with the v5.vbb.transport.rest API.

@Cediddi
Copy link
Author

Cediddi commented Jan 22, 2021

It is a coding challenge for a job application, thus I cannot share the question.

I think this API needs an open api documentation, other than that I think it's a great api and really easy to use and understand.

@derhuerst
Copy link
Owner

Completely agree, I've been planning to add an Open API spec for a while, just haven't found the time & motivation to do it yet.

[...] I think it's a great api and really easy to use and understand.

Well, I disagree in regards to the opaque HAFAS/GTFS distinction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants