Add route lookup via a route API server #232
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So far there are two servers that I'm aware of that offer this API service: api.adsb.lol and adsbdb.com.
The api.adsb.lol code is open source and can also be run locally in a container. Either way, that code uses the VirtualRaderServer route data as published on GitHub, adsbdb uses its own, independently maintained data.
For use with remote servers like adsbdb.com this commit also adds a rate limiting library and a reference to axios in order to easily and cleanly allow API accesses without exceeding the rate limits of the API provider.
Once the app receives a callsign for a flight (and that is different from the registration - as none of the free providers track 'live flight plans'; they all only include information about scheduled flights), it checks if there is already route information for this flight cached and if not it makes an API call to look up the origin and destination of that flight.
If the API service is using the second generation API service that works with the VRS data, it also implements a (somewhat simplistic) plausibility check to ensure that obviously questionable route information isn't shown to the user (assuming the user enables passing lat/lng data to the server.
The code tries to be very careful not to run afoul of rate limits of route API sites - right now this is hopefully conservative enough that even people running a couple of different tar1090 instances won't get in trouble - but one can create a scenario where power users with many windows open might still end up with too many API requests. The number of requests and the corresponding time slice can be configured.