jesperorb / sthlm-uppsala Goto Github PK
View Code? Open in Web Editor NEWDisplays traffic info for trains between Stockholm and Uppsala.
Home Page: https://sthlm-uppsala.vercel.app/
Displays traffic info for trains between Stockholm and Uppsala.
Home Page: https://sthlm-uppsala.vercel.app/
ℹ️ Just close this issue if you don't want feedback this way, I'll just choose a way to fix it in my fork if so. It's totally fine, I understand this is just a simple little utility 👍
It appears that only comparing the desired departure location to the location of an announcement (and then afterwards filtering on to-location or via-to-location) can miss some trains that don't include all information. The 08:11 stops at Uppsala and Stockholm and allows travel with Movingo. But Stockholm is not announced in the ViaToLocation
so the app doesn't show it.
This query can be used for debugging:
<QUERY objecttype="TrainAnnouncement" schemaversion="1.3" orderby="AdvertisedTimeAtLocation">
<FILTER>
<AND>
<EQ name="LocationSignature" value="U" />
<EQ name="ActivityType" value="Avgang" />
<GT name="AdvertisedTimeAtLocation" value="2023-01-20T08:10:00.000+01:00" />
<LT name="AdvertisedTimeAtLocation" value="2023-01-20T08:15:00.000+01:00" />
</AND>
</FILTER>
</QUERY>
It gives a response (using no "include" projection) containing the following train announcement:
{
"ActivityId": "1500adde-f75d-3909-08da-ef867f2d5fd2",
"ActivityType": "Avgang",
"Advertised": true,
"AdvertisedTimeAtLocation": "2023-01-20T08:11:00.000+01:00",
"AdvertisedTrainIdent": "919",
"Booking": [
"Hela tåget är obokat."
],
"Canceled": false,
"Deleted": false,
"EstimatedTimeIsPreliminary": false,
"FromLocation": [
{
"LocationName": "U",
"Priority": 1,
"Order": 0
}
],
"InformationOwner": "Mälardalstrafik AB",
"LocationSignature": "U",
"ModifiedTime": "2023-01-10T04:22:53.491Z",
"NewEquipment": 0,
"OtherInformation": [
"Stannar ej vid Märsta.",
"Buss ers. Eskilstuna - Arboga.",
"Movingo gäller."
],
"PlannedEstimatedTimeAtLocationIsValid": false,
"ProductInformation": [
"Mälartåg"
],
"ScheduledDepartureDateTime": "2023-01-20T00:00:00.000+01:00",
"TechnicalTrainIdent": "919",
"ToLocation": [
{
"LocationName": "Arb",
"Priority": 1,
"Order": 0
}
],
"TrackAtLocation": "8",
"TrainComposition": [
"Långt tåg."
],
"TypeOfTraffic": "Tåg",
"WebLink": "https://malartag.se/",
"WebLinkName": "Mälartåg Kundservice"
}
The code in api/index.ts cannot see that this train also can be taken from U
to Cst
, because the announcement has no ViaToLocation
.
Perhaps this is a bug in the data Mälartåg publishes? I do believe the data on the displays at the station show the train stopping in Sthlm, so not sure how they integrate this. Or perhaps it is expected one should combine all announcements for a given train to find this (I have never built a trip planner). Using the SJ App on my phone to plan a trip in the morning from U to Cst it shows train 919.
Note: This example is departing from Uppsala and arriving in Stockholm, but there might be trains the other way that have similar problems with the ViaToLocation
attribute.
Finding the Arboga train could be done by (pseudo query) (Location=U && (ToLocation==Cst || ViaToLocation==Cst)) || (Location=Cst && (FromLocation==U || ViaFromLocation==U))
. I.e. move some more filtering up into the API request, and lookin for either of {Location, ToLocation}
or {FromLocation,Location}
combination (or the Via variants).
The announcements found tying U to Cst will then be for the train arriving at Cst
(because the announcement data for location U has no data at all about Cst), so the train ident (919) would need to be used to go back and find announcements for the same train with location U
to show the right time for departure. I think this requires an extra API call unless we make the first API call include all departures from U regardless of the other information (because it is not until we have looked at the Cst arrivals we can identify the relevant U departures).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.