Die Haltestellen sind wichtig für viele andere Abfragen. Diese können entweder aus Didok (Beschreibung) oder aus der Bahnhofsliste (Beschreibung) bezogen werden.
Technische Aspekte
Mit dem CKAN-API ist es möglich, einen einfache Suche aufzusetzen. Beachten Sie, dass Sie dafür einen API-Schlüssel benötigen.
Abfragebeispiel Bahnhofliste
Suche nach Haltestellen mit Lausanne im Namen:
- Suchen Sie die Ressource-ID zur aktuellen Ressource aus der „bhlist“ mit dem CKAN-API:
1https://api.opentransportdata.swiss/ckan-api/package_show?id=bhlist
Die Ressource mit dem Identifier „Station list“ wird verwendet. Die „id“ wird dann im zweiten Schritt verwendet.
123456789101112131415161718192021222324252627282930313233343536{// headers"resources": [// other resources{//..."package_id": "695c7af6-d486-4cde-9bf0-a92fdd581a4e",//..."id": "bb43413d-c89c-49e8-869f-5575e63db9bb",//..."name": {"fr": "Station list","de": "Station list","en": "Station list","it": "Station list"},"language": [],"rights": "","url": "https:\/\/opentransportdata.swiss\/dataset\/695c7af6-d486-4cde-9bf0-a92fdd581a4e\/resource\/bb43413d-c89c-49e8-869f-5575e63db9bb\/download\/bahnhof.csv","created": "2016-11-08T12:53:53.025251","modified": "","webstore_url": null,"last_modified": "2016-11-08T12:53:52.974681","position": 1,"revision_id": "ca65cd4a-dbc5-4948-89d2-73e7532a7401","identifier": "Station list","resource_type": null}]//...}}
Verwenden Sie die Abfrage „https://opentransportdata.swiss/api/action/datastore_search?resource_id=<resource-id>&q=<search_string>“
1https://api.opentransportdata.swiss/ckan-api/datastore_search?resource_id=bb43413d-c89c-49e8-869f-5575e63db9bb&q=Lausanne
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253{"help": "https:\/\/opentransportdata.swiss\/api\/3\/action\/help_show?name=datastore_search","success": true,"result": {"resource_id": "bb43413d-c89c-49e8-869f-5575e63db9bb","fields": [{"type": "int4","id": "_id"},{"type": "numeric","id": "StationID"},{"type": "text","id": "Station"},{"type": "int8","id": "_full_count"},{"type": "float4","id": "rank"}],"q": "Lausanne","records": [{"Station": "Lausanne$<1>$LS$<4>$Losanna$<4>$LS$<3>","StationID": "8501120","_id": 828,"_full_count": "211","rank": 0.0573088},// more records{"Station": "Lausanne-Ouchy$<1>$LSO$<3>","StationID": "8501075","_id": 789,"_full_count": "211","rank": 0.0573088}],"_links": {"start": "\/api\/action\/datastore_search?q=Lausanne&resource_id=bb43413d-c89c-49e8-869f-5575e63db9bb","next": "\/api\/action\/datastore_search?q=Lausanne&offset=100&resource_id=bb43413d-c89c-49e8-869f-5575e63db9bb"},"total": 211}}
Abfragebeispiel Didok
Aus Didok suchen wir „Domodossola“ mit einem SQL-Query.
- Identifikation der Ressource in „Didok“:
1https://api.opentransportdata.swiss/ckan-api/package_show?id=didok
12345678910111213141516171819{//..."resources": [{"url_type": "upload","cache_last_updated": null,"issued": "2016-11-08T12:59:39.053524","package_id": "f26dee75-1ed0-4c07-ac19-c98249e94bc5","relations": "[]","datastore_active": true,"id": "079e10fc-c212-4fc8-a75d-d02028f1539c",//..."identifier": "Didok.xlsx",//...}]}
- Anhand der ID in der Ressource mit dem Identifier „Didok.xlsx“ suchen wir jetzt nach Domodossola
1https://api.opentransportdata.swiss/ckan-apin/datastore_search_sql?sql=SELECT * from "079e10fc-c212-4fc8-a75d-d02028f1539c" WHERE "Dst-Bezeichnung-offiziell" LIKE 'Domodossola'
Statt „079e10fc-c212-4fc8-a75d-d02028f1539c“ muss der aktuell gültige Code für eine Ressource eingefügt werden.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798{"help": "https:\/\/opentransportdata.swiss\/api\/3\/action\/help_show?name=datastore_search_sql","success": true,"result": {"records": [{"Dst-Bezeichung-offiziell": "Domodossola","GO-Nr": "11","GO-Abk": "FFS","VD": "","VPP": "*","KOORDY": "666.299999999999954525264911353588104248046875","KOORDX": "107.4500000000000028421709430404007434844970703125","Dst-Nr.": "1607","_full_text": "'1':6 '107.4500000000000028421709430404007434844970703125':8 '11':1 '1607':5 '270':3 '666.299999999999954525264911353588104248046875':9 '9998':7 'domodossola':10 'ffs':4","Dst-Abk": "DO","VPG": "","BP": "*","KZ": "1","_id": 6602,"Dst-Bezeichnung lang": "","Gde-Nr": "9998","KOORDZ": "270"}],"fields": [{"type": "int4","id": "_id"},{"type": "tsvector","id": "_full_text"},{"type": "numeric","id": "Dst-Nr."},{"type": "numeric","id": "KZ"},{"type": "text","id": "Dst-Bezeichung-offiziell"},{"type": "text","id": "Dst-Bezeichnung lang"},{"type": "text","id": "Dst-Abk"},{"type": "numeric","id": "GO-Nr"},{"type": "text","id": "GO-Abk"},{"type": "numeric","id": "Gde-Nr"},{"type": "text","id": "BP"},{"type": "text","id": "VPP"},{"type": "text","id": "VPG"},{"type": "text","id": "VD"},{"type": "numeric","id": "KOORDY"},{"type": "numeric","id": "KOORDX"},{"type": "numeric","id": "KOORDZ"}],"sql": "SELECT * from \"079e10fc-c212-4fc8-a75d-d02028f1539c\" WHERE \"Dst-Bezeichung-offiziell\" LIKE 'Domodossola'"}}
Diskussion beginnen auf disc.opentransportdata.swiss