Search for content

Use Case

How to show the travel times forecast at +30 minutes

The use case reflects the common need of a system integrator that must shows on the GUI the layer of forecast results at +30 minutes.

GET
https://api.dev.myptv.com/mlf/v1/forecast/realtime

The result is an object description serialized with protobuf format (for more details, see here).

When you get a protobuf object, you must decode it for getting the object description.

Here, an example of the de-serialized object:

{
 "streetForecast": [
   {
     "street": 0,
     "fromnode": 0,
     "openLRcode": "CwjonR3U/yKDbaDPAMYiM+k=",
     "forecast": [
       {
         "start": "2023-12-21T16:08:44.554Z",
         "end": "2023-12-21T16:38:44.554Z",
         "flow_valid": true,
         "speed_valid": true,
         "speed": 37.5,
         "flow": 50,
         "timezone": "UTC"
       }
     ]
   }
    {
     "street": 1,
     "fromnode": 1,
     "openLRcode": "Cwjonr1U/yKDbA3pAMYiM+k+",
     "forecast": [
       {
         "start": "2023-12-21T16:08:44.554Z",
         "end": "2023-12-21T16:38:44.554Z",
         "flow_valid": true,
         "speed_valid": true,
         "speed": 42.3,
         "flow": 40,
         "timezone": "UTC"
       }
     ]
   }
    {
     "street": 2,
     "fromnode": 2,
     "openLRcode": "Czjonr1U/yKDBA3pAMYi3+k=",
     "forecast": [
       {
         "start": "2023-12-21T16:08:44.554Z",
         "end": "2023-12-21T16:38:44.554Z",
         "flow_valid": true,
         "speed_valid": true,
         "speed": 21.5,
         "flow": 50,
         "timezone": "UTC"
       }
     ]
   }
    {
     "street": 3,
     "fromnode": 3,
     "openLRcode": "CzjOnr1U/yKDBa3pAmYi3+k1",
     "forecast": [
       {
         "start": "2023-12-21T16:08:44.554Z",
         "end": "2023-12-21T16:38:44.554Z",
         "flow_valid": true,
         "speed_valid": true,
         "speed": 56.7,
         "flow": 40,
         "timezone": "UTC"
       }
     ]
   }
 ]
}

In the de-serialized object, you can distinguish four streets identified by:

  • street: N
  • fromnode: N
  • openLRcode: string

...with N=0,1,2,3

For every street, a specific set of parameters characterizing the forecast:

  • start: the start time of the forecast period
  • end: the end time of the forecast period
  • flow_vaild: for a future use
  • speed_valid: currently always true
  • speed: the value of forecast speed
  • flow: for a future use
  • timezone: the timezone associated to the API user