- Go to Flightradar24 flights database and find your flight
- Get URL like this:
http://www.flightradar24.com/data/flights/UA853/#38ae207
./fr24togpx.rb 38ae207 > FILENAME.gpx
- Check you output file using GPS Visualizer
Created
June 17, 2014 15:51
-
-
Save dlackty/a35d1908fb41776920b2 to your computer and use it in GitHub Desktop.
Ruby version of https://gist.github.com/gslin/cfc326728c1d4e73589e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
if ARGV.empty? | |
puts "usage: ./fr24togpx.rb flight-id" | |
exit | |
end | |
SMOOTH = 10 | |
uri = URI.parse'http://api.fr24.com/api/common/v1/json-rpc/' | |
data = { | |
jsonrpc: '2.0', | |
method: 'Aircraft.doGetPlaybackSingle', | |
params: [ARGV[0].hex], | |
id: 1, | |
} | |
http = Net::HTTP.new(uri.host, uri.port) | |
request = Net::HTTP::Post.new(uri.request_uri) | |
request.body = data.to_json | |
response = http.request(request) | |
points = JSON.parse(response.body) | |
puts <<-EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<gpx> | |
<trk> | |
<name>fr24-to-gpx</name> | |
<desc>fr24-to-gpx</desc> | |
<trkseg> | |
EOF | |
last = [] | |
points["result"]["data"]["track"].each do |p| | |
unless last.empty? | |
SMOOTH.times do |i| | |
puts "<trkpt lat=\"#{(p[0].to_f * i + last[0].to_f * (SMOOTH - i)) / SMOOTH}\" lon=\"#{(p[1].to_f * i + last[1].to_f * (SMOOTH - i)) / SMOOTH}\"></trkpt>" | |
end | |
end | |
puts "<trkpt lat=\"#{p[0]}\" lon=\"#{p[1]}\"></trkpt>" | |
last = p | |
end | |
puts <<-EOF | |
</trkseg> | |
</trk> | |
</gpx> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://api.fr24.com/api/common/v1/json-rpc
403 - Forbidden....QQ