JanusRekoj / Transportastic

1 stars 1 forks source link

Python, Web team: Interface definition #6

Open JanusRekoj opened 3 years ago

JanusRekoj commented 3 years ago

Define how the data pipeline looks like

invisible24 commented 3 years ago

I suggest using an MVC like approach. I've already created a controller class which can serve as our interface. If data is requested from the webpage, the server class calls appropriate functions in the controller class which then need to somehow fetch the correct data from our model (probably with further function calls so that no logic is inside the controller).

dmilz commented 3 years ago

GET requests:

/data?start=UNIXTIME1&end=UNIXTIME2&line=LINEID&bus=BUSID&station=STATIONNAME

{

  "LinienID1":{
    
"BusID1":{

      "Businfo": {
        "Seats": 100,
        "Capacity": 100
      },
      
"Trajectory": [{

        "Timestamp": UNIXTIME,
        "Position": {"lat": 10.0, "lon": 10.0, "speed": 10, "heading": 200},
        "station": None / "Hauptbahnhof"
        "
Occupancy": 10

      }, {..}
      ]
    }
  }
}
dmilz commented 3 years ago

Proposing a slight change (essentially all characters are lowered)

{
    "line123": {
        "bus1": {
            "businfo": {
                "capacity": 100,
                "seats": 50
            },
            "trajectory": [
                {
                    "occupancy": 10,
                    "position": {
                        "heading": 200,
                        "lat": 10,
                        "lon": 10,
                        "speed": 10
                    },
                    "station": null,
                    "timestamp": 10000
                },
                {
                    "occupancy": 10,
                    "position": {
                        "heading": 100,
                        "lat": 10.1,
                        "lon": 10.1,
                        "speed": 0
                    },
                    "station": "Hauptbahnhof",
                    "timestamp": 10010
                }
            ]
        }
    }
}