Editorial Workflows

Lido2mPilotWorkflow

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Copy route from Lido Smartsuite PDF into clipboard in a format suitable for Lido mPilot App

https://workflow.is/workflows/e2c0fd70d15d494fb9ffd9ac874e87c4

Version 1.1 : mise a jour regex pour prendre en compte la syntaxe utilisée pour les waypoint random.

Version 1.2:
- Utilise le FPL summary Iso WPT COORDINATES pour éviter les mauvais positionnement de waypoints (les points du départ sont forcés en géographique, les points des tracks sont extraits du TRACKSNAT)
- la route utilise les Airways

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Run Python Script ?
Source Code
#coding: utf-8
# version 1.2
import re
try:
	import workflow
	action_in = workflow.get_input()
except ImportError:
	action_in = """
	retrieved: 08Nov/1800zAF  393  SAEZ/LFPG  08Nov2015/2055z3OFP 13/0/1Main OFP (Long copy #1)WPT COORDINATESSAEZ  S3449.3W05832.2  EZE12 S3451.5W05827.8  PTA   S3458.6W05753.9DORVO S3443.0W05731.0  PABOT S3415.6W05651.6  LOMID S3353.1W05619.8ANDAN S3347.7W05612.2  MLO   S3220.5W05413.3  AKNEN S3200.5W05353.2PAUTA S3041.0W05235.4  OBLAD S3022.3W05217.0  ISOGU S3007.6W05203.4COVER S2933.1W05131.0  CXS   S2911.9W05111.3  NADAR S2812.0W05011.6GLOVE S2645.1W04847.7  OSAMU S2556.8W04801.3  RONUT S2512.6W04715.1NEGUS S2430.4W04658.1  MUBIP S2427.1W04655.8  RDE   S2353.5W04631.7BCO   S2324.4W04623.1  UTGER S2245.3W04613.8  AKVUM S2231.6W04603.1UBRIR S2212.2W04548.1  MAVMO S2146.6W04528.3  UKAKI S2107.2W04458.2MOXIK S2056.7W04450.2  OPKES S2041.3W04438.6  PONVU S2019.7W04422.3BHZ   S1950.1W04400.2  DEPOT S1918.3W04349.2  NINSA S1900.6W04343.1TOMOP S1844.7W04337.6  OBGAR S1830.8W04332.9  MUDOL S1813.3W04327.0QUARU S1719.6W04308.7  RUBIC S1624.6W04240.7  MIKUV S1414.7W04135.7SPINO S1351.5W04124.4  ZAMBI S1306.6W04102.5  EDRIX S1226.0W04042.9MANPI S1204.5W04032.3  TROVA S1122.3W04011.9  ADEMI S1033.2W03949.0BANGU S0735.8W03827.3  TEGIM S0725.5W03822.5  EDITE S0654.5W03808.4KIGUK S0549.7W03739.0  MSS   S0511.8W03721.9  GIBTO S0442.0W03704.9XOLER S0435.0W03700.2  MAGNO S0144.6W03527.7  SAKSI N0050.6W03402.4CRUDE N0144.3W03333.0  OBKUT N0325.8W03237.1  DEKON N0513.0W03137.9SAGRO N1035.0W03051.8  TARIM N1510.4W02932.5  BAMUX N2313.3W02632.5IXIKU N2700.0W02500.0  RIPOD N3000.0W02400.0        N3500.0W02200.0      N4000.0W02000.0        N4400.0W01500.0  PASAS N4500.0W01300.0SEPAL N4700.0W00845.0  LAPEX N4700.0W00800.0  XIDAN N4702.7W00613.1COQUE N4704.8W00459.4  AKEMO N4708.4W00300.0  OLEBA N4709.4W00150.9NTS   N4709.7W00136.8  ANG   N4732.2W00051.1  TEMTO N4735.7W00036.9KEPER N4748.4E00016.4  LUMAN N4756.4E00024.8  ROMGO N4820.8E00050.6FF501 N4824.7E00102.0  NERKI N4830.8E00119.6  BANOX N4834.5E00130.3SULAX N4845.0E00138.1  LFPG  N4900.6E00232.9--------------------------------------------------------------------LFPG  N4900.6E00232.9  OLDGT N4825.8E00213.8  LFPO  N4843.4E00222.8ATC FLIGHT PLANFF SAEZZPZX SAEZZTZX SAEZZRZX SUEOZQZX SUMUZQZX SBCWZQZX SBRJZXNBSBRJZXIP SBBSZQZX SBREZQZX SBAOZQZX GOZZZQZX GOOOZQZX GOOOZIZXGVSCZQZX GVACYSYX GVACFDPX LPPOZQZX LPPOZOZX EUCHZMFP EUCBZMFP       LFBOAFMI(FPL-AFR393-IS-B772/H-SDE2E3FGHIJ3J5J6M1M2RWXY/LB1D1-SAEZ2055-N0482F330 PTA6B DORVO UN857 MLO UM671 RONUT DCT NEGUS UW47 RDE UZ14 BCO UZ23 BHZ UW13 QUARU UN866 TEGIM/N0487F350 UN866 MSS/M083F350 UN866 MAGNO/M083F350 UN866 DEKON/M083F350 DCT SAGRO/M083F370 DCT TARIM/M083F370 DCT BAMUX DCT IXIKU/N0478F370 DCT RIPOD/M083F370 DCT 35N022W 40N020W/M083F410 44N015W DCT PASAS DCT SEPAL UN470 LAPEX/N0467F400 UN471 AKEMO/N0464F360 UN471 OLEBA/N0459F340 UN471 NTS/N0452F300 UN741 TEMTO/N0412F240 UN741 KEPER KEPER6E-LFPG1236 LFPO-PBN/A1B1C1D1L1O1S1 DOF/151108 REG/FGSPT EET/SUEO0011 SBCW0040 SBBS0157 SBRE0254 SBAO0452 GOOO0549 SAGRO0627 GVSC0700 TARIM0700 LPPO0756 GCCC0823 LPPO0846 35N022W092
	3 40N020W1002 44N015W1044 EGGX1058 SEPAL1124 LFFF1128 SEL/DJBH OPR/AFR RALT/SBFZ GVAC LPPT RVR/075 RMK/ACAS TCAS)Generated at 08Nov/1800zPage 14 of
	retrieved: 08Nov/1800zAF  393  SAEZ/LFPG  08Nov2015/2055z3OFP 13/0/1Main OFP (Long copy #1)TRACKSNAT EASTBND TRACKS FL 320/400 INCLUSIVE 09NOV0100-09NOV0800Z* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Generated at 08Nov/1800zPage 15 ofT   NICSO 48N050W 50N040W 52N030W 54N020W DOGAL BEXET   LVLS EB 320 330 340 350 360 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR N201B N211E U   PORTI 47N050W 49N040W 51N030W 53N020W MALOT GISTI   LVLS EB 320 330 340 350 360 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR N141D N155A V   SUPRY 46N050W 48N040W 50N030W 52N020W LIMRI XETBO   LVLS EB 320 330 340 350 360 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR N79A N93A W   RAFIN 45N050W 47N040W 49N030W 51N020W DINIM ELSOX   LVLS EB 320 330 340 350 360 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR N49C N59C X   DOVEY 42N060W 44N050W 46N040W 48N030W 50N020W SOMAX ATSUR   LVLS EB 320 330 340 350 360 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR NIL Y   JOBOC 41N060W 43N050W 45N040W 47N030W 49N020W BEDRA NERTU   LVLS EB 320 330 340 350 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR NIL Z   MUNEY 40N060W 42N050W 44N040W 46N030W 48N020W 48N015W OMOKO   GUNSO   LVLS EB 320 330 340 350 370 380 390 400   LVLS WB NIL   EUR RTS EAST NIL   NAR NIL NOTES:1.TMI IS 313 AND OPERATORS ARE REMINDED TO INCLUDE THE TMI NUMBER ASPART OF THE OCEANIC CLEARANCE READ BACK.2.ADS-C AND CPDLC MANDATED OTS ARE AS FOLLOWSALL TRACKS 350 360 370 380 390END OF ADS-C AND CPDLC MANDATED OTS.3.CLEARANCE DELIVERY FREQUENCY ASSIGNMENTS FOR AIRCRAFT OPERATINGFROM AVPUT TO TALGO INCLUSIVE:AVPUT TO KETLA 132.02,MAXAR TO URTAK134.2,AVUTI TO HOIST 128.7,JANJO TO NEEKO 135.45,RIKAL TO ALLRY 135.05,ELSIR TO NICSO 128.45,PORTI TO TALGO 119.424.80PERCENT OF NAVIGATIONAL ERRORS RESULT FROM POOR COCKPITPROCEDURES.ALWAYS CARRY OUT PROPER WAYPOINT PROCEDURES.5.RLATSM PHASE 1 WILL COMMENCE NOVEMBER 12,2015.OPERATORS ATTENTION IS DRAWN TO AIC 25/15.6.OPERATORS ATTENTION IS DRAWN TO NOTAM A0017/13 RE: CHANGE INNEW YORK CENTER OCEANIC CLEARANCE PROCEDURES.7.OPERATORS ARE ADVISED THAT VERSION 23 OF THE GANDER DATA LINKOCEANIC CLEARANCE DELIVERY CREW PROCEDURES IS NOW VALID ANDAVAILABLE AS NAT OPS BULLETIN 2015-001 ON THE WWW.PARIS.ICAO.INTWEBSITE.8.OPERATORS ARE REMINDED TO FILE PRMS WITH NEW YORK AND GANDERCENTRES TO THE FOLLOWING ADDRESSES KZNYZRZD AND CZQXZQZX.9.OPERATORS ARE REMINDED OF THE REQUIREMENT TO CARRY OUT A HF RADIOCHECK AND SELCAL CHECK,IF SELCAL EQUIPED,WHEN CROSSING EACH OCEANIC


	"""

# filter the main route part
# RegexMatch returns a list of tuples (name, lat, long)
# lat and long are in text format NSEW prefixed, in degree/minute format
s = action_in.split('WPT COORDINATES', 1)[1]
try:
	s = s.split('----', 1)[0]
except IndexError:
	pass  # will process till the end of file
m = re.findall(r'(\S+|\s+)\s+([NS]\d{4}\.\d)([EW]\d{5}\.\d)', s)

# In previous versions, we defined points as either
# - a name
# - a geo coordinates if name was empty or containing a digit
# We add raw_points, a list of "geographical points" like "N4500.0W01000.0"
points = []
raw_points = []

for name, lat, lon in m:
	name = name.strip()
	geo = "%s%s" % (lat, lon)  # N4500.0W01000.0
	raw_points.append(geo)
	if re.search(r'\d+', name) or not name:
		points.append(geo)
	else:
		points.append(name)

departure = points[0]
destination = points[-1]

# filter the optional TRACKS part
# build a list of tuples [('NATA', [points in the tracks])]
try:
	s = action_in.split('TRACKSNAT', 1)[1]
	s = s.split('NOTES:', 1)[0]
	it = iter(re.split(r'(?:\s|[^A-Z])([A-Z])\s{3}', s)[1:])
	tracks = zip(it, it)
except IndexError:
	tracks = []
for i, track in enumerate(tracks):
	letter, text = track
	text = text.split('LVLS',1)[0].strip()
	tracks[i] = ('NAT' + letter, [p for p in text.split(' ') if p])

# extract FPL, replace SID and STAR by raw_points, replace NAT by track_points
s = action_in.split('ATC FLIGHT PLAN', 1)[1]
try:
	s = s.split('TRACKSNAT', 1)[0]
except IndexError:
	pass  # will process till the end of file
try:
	# whithin our string,
	# fpl begins with -departure and then ends at destination
	# so, extract -SAEZ .... LFPG in our example
	s = departure + action_in.split('-%s' % departure, 1)[1]
	s = s.split(destination, 1)[0] + destination
except IndexError:
	print "incomplete Flight Plan"
	action_out = ' '.join(p for p in points)  # fallback
else:
	# get parts of the ATC Flight Plan, excluding start and destination
	fpl_route = s.split(' ')[1:-1]
	# strip speed and fl changes from waypoints
	fpl_route = [p.split('/', 1)[0] if '/' in p else p for p in fpl_route]
	lido_route = fpl_route[:]  # fallback copy of fpl_route

	# replace points by raw_points before first common waypoint in fpl_route
	for i, p in enumerate(fpl_route):
		if p in points:
			offset = points.index(p)
			lido_route = raw_points[1:offset] + fpl_route[i:]
			break

	# replace points after last common waypoint by raw_points
	for i, p in enumerate(reversed(lido_route)):
		if p in points:
			offset = points[::-1].index(p)
			if i > 0:
				lido_route = lido_route[0:-i]
			lido_route += raw_points[-offset:-1]
			break

	# replace known tracks (NATA, NATB...) by track_points 
	for track_name, track_points in tracks:
		try:
			offset = lido_route.index(track_name)
		except ValueError:
			pass
		else:
			lido_route[offset:offset+1] = track_points
			break

	# replace NAR by intermediate points if any
	# Should be correctly handheld by mPilot, but I leave the code just in case
	# for i, p in enumerate(lido_route):
	# 	if re.match(r'^N\d+A$', p.strip()):
	# 		try:
	# 			before = points.index(lido_route[i - 1])
	# 			after = len(points) - points[::-1].index(lido_route[i + 1])
	# 			lido_route[i:i + 1] = points[before + 1:after - 1]
	# 		except (ValueError, IndexError):
	# 			continue

	# add missing departure and destination
	lido_route = [departure] + lido_route + [destination]
	action_out = ' '.join(p for p in lido_route)
try:
	workflow.set_output(action_out)
except NameError:
	print action_out
Set Clipboard ?
Show HUD ?
HUD Text
le presse-papier contient la route à coller dans la route de mPilot
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"