Giter Site home page Giter Site logo

jesperorb / sthlm-uppsala Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 160 KB

Displays traffic info for trains between Stockholm and Uppsala.

Home Page: https://sthlm-uppsala.vercel.app/

HTML 2.33% JavaScript 11.95% Svelte 26.69% TypeScript 59.03%
svelte trafikinfo trafikverket

sthlm-uppsala's People

Contributors

fabjan avatar jesperorb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sthlm-uppsala's Issues

The 08:11 from Uppsala to Arboga via Sthlm is not showing

Description

ℹ️ 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.

Details

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.

A Possible Solution

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.