Question

Extract Info from Live API Calls

  • 9 September 2016
  • 5 replies
  • 1 view

Badge +1

Hi. I am working on GTFS data and the information that is been provided for Hong Kong is in the Live API calls. By mentioning 'Live', I mean that the info for each vehicle changes every second with the location of the bus. Is there some method by which we can actually extract the correct information?

One method that I have thought is to get the data everyday at the same time.

Can anyone suggest me of some method which is more simpler and flexible.

http://ptx.transportdata.tw/MOTC/Swagger/#!/CityBusApi/CityBusApi_RealTimeByFrequency

Shivam


5 replies

Badge +16

Hi,

Maybe this fme server demo can set you on the right track.

https://knowledge.safe.com/articles/1112/live-spatial-dashboard.html

Userlevel 4

What do you mean by "correct information" in the context of buses that are constantly on the move?

The service itself can return the data in JSON (or XML, if you prefer), so it should be pretty straight-forward to work with in FME.

Badge +1

What do you mean by "correct information" in the context of buses that are constantly on the move?

The service itself can return the data in JSON (or XML, if you prefer), so it should be pretty straight-forward to work with in FME.

By correct info, I meant to extract the full information with correct lat/lon of each stop, since the lat/lon will change with the movement of the vehicle thus it would be difficult to extract the stop lat/lon.

 

 

Userlevel 4
By correct info, I meant to extract the full information with correct lat/lon of each stop, since the lat/lon will change with the movement of the vehicle thus it would be difficult to extract the stop lat/lon.

 

 

So you need to guess the bus stops from a live data feed, or do you just need the bus route?

 

Anyway, it is fairly easy to create a looping transformer that interrogates the webservice every second for, let's say, 24 hours and saves everything to a local database, then you can post-process the saved data the following day to assemble the bus positions into lines.

 

Userlevel 4
Badge +25

It sounds like you want the stop a bus is closest to? Maybe the closest previous or the closest next?

The API also seems to let you query a route and returns stops on that route.

So maybe it's as simple as a NeighborFinder transformer? The bus position becomes the Base feature and the stops are the Candidates. You just find the closest candidate (stop) to each base (bus).

Of course, if the route loops around the closest stop might not be the one it has just left. But it would be a start.

Or... if you did continuously monitor the bus then you would probably be able to track it from stop to stop fairly easily. Put a buffer around each stop (with the Bufferer transformer) and make a note of when the bus location falls inside that buffer (PointOnAreaOverlayer).

Maybe combine the two methods so you can tell what the next stop should be and test it with the NeighborFinder.

Lots of ways to do this, but FME Server is certainly a good tool for handling this type of live spatial data.

Reply