<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>V1nz T3ch &#187; python</title>
	<atom:link href="http://v1nz.t3ch.free.fr/index.php/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://v1nz.t3ch.free.fr</link>
	<description></description>
	<lastBuildDate>Wed, 16 Oct 2019 18:25:52 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>Créer une trace GPS d&#8217;un vol en avion grâce au site Flightaware</title>
		<link>http://v1nz.t3ch.free.fr/index.php/cree-une-trace-gpx-dun-vol-en-avion-grace-au-site-flightaware/</link>
		<comments>http://v1nz.t3ch.free.fr/index.php/cree-une-trace-gpx-dun-vol-en-avion-grace-au-site-flightaware/#comments</comments>
		<pubDate>Fri, 02 Feb 2018 14:39:16 +0000</pubDate>
		<dc:creator><![CDATA[v1nz.t3ch]]></dc:creator>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[Flightaware]]></category>
		<category><![CDATA[gpx]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://v1nz.t3ch.free.fr/?p=7</guid>
		<description><![CDATA[Voici donc un petit script python qui va récupérer les infos d&#8217;un vol grâce a l&#8217;API de Flightaware et créer un fichier de trace Gps au format GPX Le site de référence pour toutes les infos sur les vol d’avions c’est Flightaware il regroupe tout un tas d’info . 1 &#8211;  créer un compte sur &#8230; <a href="http://v1nz.t3ch.free.fr/index.php/cree-une-trace-gpx-dun-vol-en-avion-grace-au-site-flightaware/" class="more-link">Continuer la lecture de <span class="screen-reader-text">Créer une trace GPS d&#8217;un vol en avion grâce au site Flightaware</span></a>]]></description>
				<content:encoded><![CDATA[<figure id="attachment_10" style="width: 660px;" class="wp-caption aligncenter"><a href="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-GPX-Editor.png"><img class="  wp-image-10 size-large" src="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-GPX-Editor-1024x485.png" alt="exemple de GPX pour un vol Newark Oslo" width="660" height="313" /></a><figcaption class="wp-caption-text">exemple de GPX pour un vol Newark Oslo</figcaption></figure>
<p>Voici donc un petit script python qui va récupérer les infos d&rsquo;un vol grâce a l&rsquo;API de Flightaware et créer un fichier de trace Gps au format GPX</p>
<p>Le site de référence pour toutes les infos sur les vol d’avions c’est <a href="https://fr.flightaware.com/">Flightaware</a> il regroupe tout un tas d’info .</p>
<h3>1 &#8211;  créer un compte sur Flightaware</h3>
<p>créer un compte qui vous permettra d’avoir accès à API du site<br />
<a href="https://fr.flightaware.com/account/join/">lien pour l&rsquo;inscription</a><br />
<a href="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-Devenez-membre-de-FlightAware-FlightAware.png"><img class="alignnone size-large wp-image-13" src="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-Devenez-membre-de-FlightAware-FlightAware-1024x548.png" alt="2018-02-02 Devenez membre de FlightAware - FlightAware" width="660" height="353" /></a><br />
Après avoir confirmer votre adresse mail<br />
Activer l’accès au api <a href="https://fr.flightaware.com/commercial/flightxml/v3/pricing.rvt">(lien)</a> et choisisser le compte STARTER<br />
<a href="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML-Version-302.jpg"><img class="alignnone size-large wp-image-11" src="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML-Version-302-845x1024.jpg" alt="2018-02-02 FlightXML - Version 3(02)" width="660" height="800" /></a></p>
<p><a href="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML3-Sign-Up-Flight-Status-API-Flight-Tracking-API-FlightAware-API-Commercial-Services-FlightAware.png"><img class="alignnone size-large wp-image-14" src="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML3-Sign-Up-Flight-Status-API-Flight-Tracking-API-FlightAware-API-Commercial-Services-FlightAware-1024x716.png" alt="2018-02-02 FlightXML3 Sign Up - Flight Status API - Flight Tracking API - FlightAware API - Commercial Services - FlightAware" width="660" height="461" /></a></p>
<p><a href="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML-Key-Generation-Flight-Status-API-Flight-Tracking-API-FlightAware-API-Commercial-Services-FlightAware02.jpg"><img class="alignnone size-large wp-image-12" src="http://v1nz.t3ch.free.fr/wp-content/uploads/2018/02/2018-02-02-FlightXML-Key-Generation-Flight-Status-API-Flight-Tracking-API-FlightAware-API-Commercial-Services-FlightAware02-1024x485.jpg" alt="2018-02-02 FlightXML Key Generation - Flight Status API - Flight Tracking API - FlightAware API - Commercial Services - FlightAware(02)" width="660" height="313" /></a></p>
<p>récupérer votre identifiant ,l’ API Key et les mettre de coté</p>
<h3>2 -le script</h3>
<p>Récupérer le script suivant et copier dans un fichier &laquo;&nbsp;Flightaware vers gpx.py&nbsp;&raquo; a l’endroit de votre choix</p>
<p></p><pre class="crayon-plain-tag">#!//usr/bin/env python

import requests
import os
import datetime
import json
import time

username = "votre identiviant"
apiKey = "votre apikey"
fxmlUrl = "https://flightxml.flightaware.com/json/FlightXML3/"

tbVols = ["votre_vol1","votre_vol2"]

CheminData = "votre chemin"

Hier = datetime.datetime.now() - datetime.timedelta(days = 1)
LeJour = Hier.strftime('%d/%m/%Y')
LeJourN = Hier.strftime('%Y-%m-%d')

print LeJour

for x in enumerate(tbVols):
	LeVol = x[1]
	payload = {'ident':LeVol,'howMany':'10'}
	response = requests.get(fxmlUrl + "FlightInfoStatus",params=payload, auth=(username, apiKey))
	Mon_faFlightID  = ''
	if response.status_code == 200:
		#Creation d'un fichier avec Infos Status 
		NomFich = LeJourN+'_'+LeVol+'_'+"FlightInfoStatus.txt"
		FichierData = os.path.join(CheminData,NomFich)	
		print FichierData
		fichier = open(FichierData,"a")
		
		decodedResponse = response.json()
		for flight in decodedResponse['FlightInfoStatusResult']['flights']:
			if flight['filed_departure_time']['date'] == LeJour :
				Mon_faFlightID = flight['faFlightID']
				print Mon_faFlightID
		json.dump(response.json(), fichier)
		fichier.close()	


		if Mon_faFlightID&lt;&gt;'':	
			#Creation du fichier Flight Trach			
			NomFich = LeJourN+'_'+LeVol+'_'+"FlightTrack.txt"
			FichierData = os.path.join(CheminData,NomFich)	
			print FichierData
			fichier = open(FichierData,"a")		
			payload = {'ident': Mon_faFlightID}
			response = requests.get(fxmlUrl + "GetFlightTrack",params=payload, auth=(username, apiKey))
			json.dump(response.json(), fichier)
			fichier.close()	
			
			#Creation du fichier GPX
			FichierGPX = LeJourN+'_'+LeVol+'_'+"FlightTrack.gpx"
			NomFichierGPX =  os.path.join(CheminData,FichierGPX)
			fd = open(NomFichierGPX, 'w')
			fd.write("""&lt;?xml version="1.0" encoding="UTF-8" standalone="no" ?&gt;
			&lt;gpx xmlns="http://www.topografix.com/GPX/1/1"&gt;&lt;trk&gt;&lt;name&gt;%s&lt;/name&gt;&lt;trkseg&gt;""" % (LeVol+" vol du "+LeJourN))
			lastloc = None
			
			decodedJson = response.json()
			for Mon_Track in decodedJson['GetFlightTrackResult']['tracks']:
				LeTemps = str(datetime.datetime.fromtimestamp(int(Mon_Track['timestamp']))).replace(' ', 'T') + 'Z'
				Laltidute =  round(Mon_Track['altitude']*100*0.3048,3)

				if lastloc:
					timedelta =  (int(Mon_Track['timestamp']) - int(lastloc))
					if timedelta &gt; 600:
						fd.write( "&lt;/trkseg&gt;&lt;trkseg&gt;")
				fd.write( '&lt;trkpt lat="%s" lon="%s"&gt;' % (Mon_Track['latitude'], Mon_Track['longitude']))
				fd.write( '&lt;ele&gt;%s&lt;/ele&gt;' % (Laltidute))
				fd.write( '&lt;time&gt;%s&lt;/time&gt;&lt;/trkpt&gt;' % (LeTemps))
				fd.write("\n")
				lastloc = Mon_Track['timestamp']
				
			fd.write( "&lt;/trkseg&gt;&lt;/trk&gt;&lt;/gpx&gt;")

	else:
		print "Verifie le numero du vol"
		
	time.sleep(60)</pre><p> </p>
<p>Modifier les informations avec les votres<br />
  Username :  votre identifiant Flightawar<br />
  apiKey : votre apikey recuperer dans fligntaware.com<br />
  tbVols = la liste des vol que vous souhaite recuperer de type &laquo;&nbsp;SAS908&Prime;<br />
  Hier = datetime.datetime.now() &#8211; datetime.timedelta(days = 1)<br />
    Le chiffre 1 vous donnera le vol d’hier<br />
    Le chiffre 2 le vol d’avant hier ainsi de suite<br />
  CheminData : le chemin ou vous souhaiter récupère vos infos</p>
<p>Enregister et lancer le script avec un logiciel comme <a href="http://portablepython.com/wiki/Download/" target="_blank">Python-Scripter</a> sur windows ou excuter le directement sur linux (apres avoir rendu le fichier excitable bien sur)</p>
<p>Normalement si tout ce passe bien vous devriez avoir 3 fichier par vol :<br />
LeJour_LeVol_FlightInfoStatus.txt : avec toutes les info sur tous les vol<br />
LeJourN_LeVol_FlightTrack.txt : avec toutes les infos sur le trajet du jour sélectionne<br />
C’est deux fichier sont des info brute du json recuperer sur flightaware il comporte enormément d’info comme le terminal de départ et d’arrivé ce sera a vous de récupérer les infos a l’aide de<br />
<a href="https://flightaware.com/commercial/flightxml/v3/apiref.rvt#op_AirportBoards">API référence de Flightaware</a></p>
<p>et enfin<br />
LeJourN_LeVol_FlightTrack.gpx : c’est la trace du vol vous pouvez le voir avec des application de visualisation de gpx comme <a href="http://www.gpxeditor.co.uk">www.gpxeditor.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://v1nz.t3ch.free.fr/index.php/cree-une-trace-gpx-dun-vol-en-avion-grace-au-site-flightaware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
