NOTAM::getAllNOTAMbyScope()   A
last analyzed

Complexity

Conditions 3
Paths 6

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 6
nop 1
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * This class is part of FlightAirmap. It's used to parse NOTAM
4
 *
5
 * Copyright (c) Ycarus (Yannick Chabanois) at Zugaina <[email protected]>
6
 * Licensed under AGPL license.
7
 * For more information see: https://www.flightairmap.com/
8
*/
9
require_once(dirname(__FILE__).'/settings.php');
10
require_once(dirname(__FILE__).'/class.Connection.php');
11
require_once(dirname(__FILE__).'/class.Common.php');
12
require_once(dirname(__FILE__).'/class.Spotter.php');
13
14
class NOTAM {
15
	public $db;
16
	private $abbr = array(
17
	                    'A/A' => 'Air-to-air',
18
	                    'A/G' => 'Air-to-ground',
19
	                    'AAL' => 'Above Aerodrome Level',
20
	                    'ABM' => 'Abeam',
21
	                    'ABN' => 'Aerodrome Beacon',
22
	                    'ABT' => 'About',
23
	                    'ABV' => 'Above',
24
	                    'ACC' => 'Area Control',
25
	                    'ACFT' => 'Aircraft',
26
	                    'ACK' => 'Acknowledge',
27
	                    'ACL' => 'Altimeter Check Location',
28
	                    'ACN' => 'Aircraft Classification Number',
29
	                    'ACPT' => 'Accepted',
30
	                    'ACT' => 'Active',
31
	                    'AD' => 'Aerodrome',
32
	                    'ADA' => 'Advisory Area',
33
	                    'ADC' => 'Aerodrome Chart',
34
	                    'ADDN' => 'Additional',
35
	                    'ADIZ' => 'Air defense identification zone',
36
	                    'ADJ' => 'Adjacent',
37
	                    'ADR' => 'Advisory Route',
38
	                    'ADS' => 'Automatic Dependent Surveillance',
39
	                    'ADVS' => 'Advisory Service',
40
	                    'ADZ' => 'Advised',
41
	                    'AFIL' => 'Flight Plan Filed In The Air',
42
	                    'AFIS' => 'Airport flight information service',
43
	                    'AFM' => 'Affirm',
44
	                    'AFT' => 'After',
45
	                    'AGA' => 'Aerodromes, Air Routes and Ground Aids',
46
	                    'AGN' => 'Again',
47
	                    'AIS' => 'Aeronautical information service',
48
	                    'ALERFA' => 'Alert Phase',
49
	                    'ALRS' => 'Alerting Service',
50
	                    'ALS' => 'Approach Lighting System',
51
	                    'ALT' => 'Altitude',
52
	                    'ALTN' => 'Alternate',
53
	                    'AMA' => 'Area Minimum Altitude',
54
	                    'ANC' => 'Aeronautical Chart',
55
	                    'ANCS' => 'Aeronautical Navigation Chart',
56
	                    'ANS' => 'Answer',
57
	                    'AOC' => 'Aerodrome Obstacle Chart',
58
	                    'AP' => 'Airport',
59
	                    'APCH' => 'Approach',
60
	                    'APDC' => 'Aircraft Parking/docking Chart',
61
	                    'APN' => 'Apron',
62
	                    'APNS' => 'Aprons',
63
	                    'APP' => 'Approach Control',
64
	                    'APR' => 'April',
65
	                    'APRX' => 'Approximately',
66
	                    'APSG' => 'After Passing',
67
	                    'APV' => 'Approved',
68
	                    'ARC' => 'Area Chart',
69
	                    'ARNG' => 'Arrange',
70
	                    'ARO' => 'Air Traffic Services Reporting Office',
71
	                    'ARP' => 'Aerodrome Reference Point',
72
	                    'ARR' => 'Arriving',
73
	                    'ARST' => 'Arresting',
74
	                    'ASC' => 'Ascend To',
75
	                    'ASDA' => 'Accelerate-Stop Distance Available',
76
	                    'ASPEEDG' => 'Airspeed Gain',
77
	                    'ASPEEDL' => 'Airspeed Loss',
78
	                    'ASPH' => 'Asphalt',
79
	                    'ATA' => 'Actual Time of Arrival',
80
	                    'ATD' => 'Actual Time of Departure',
81
	                    'ATFM' => 'Air Traffic Flow Management',
82
	                    'ATIS' => 'Automatic terminal information service',
83
	                    'ATM' => 'Air Traffic Management',
84
	                    'ATP' => 'At',
85
	                    'ATTN' => 'Attention',
86
	                    'ATZ' => 'Aerodrome Traffic Zone',
87
	                    'AUG' => 'August',
88
	                    'AUTH' => 'Authorization',
89
	                    'AUW' => 'All Up Weight',
90
	                    'AUX' => 'Auxiliary',
91
	                    'AVBL' => 'Available',
92
	                    'AVG' => 'Average',
93
	                    'AVGAS' => 'Aviation Gasoline',
94
	                    'AWTA' => 'Advise At What Time Able',
95
	                    'AWY' => 'Airway',
96
	                    'AWYS' => 'Airways',
97
	                    'AZM' => 'Azimuth',
98
	                    'BA' => 'Braking Action',
99
	                    'BCN' => 'Beacon',
100
	                    'BCST' => 'Broadcast',
101
	                    'BDRY' => 'Boundary',
102
	                    'BFR' => 'Before',
103
	                    'BLDG' => 'Building',
104
	                    'BLO' => 'Below Clouds',
105
	                    'BLW' => 'Below',
106
	                    'BRF' => 'Short',
107
	                    'BRG' => 'Bearing',
108
	                    'BRKG' => 'Breaking',
109
	                    'BTL' => 'Between Layers',
110
	                    'BTN' => 'Between',
111
	                    'CD' => 'Candela',
112
	                    'CDN' => 'Coordination',
113
	                    'CF' => 'Change Frequency To',
114
	                    'CFM' => 'Confirm',
115
	                    'CGL' => 'Circling Guidance Light(s)',
116
	                    'CH' => 'Channel',
117
	                    'CHG' => 'Changed',
118
	                    'CIT' => 'Near or Over Large Towns',
119
	                    'CIV' => 'Civil',
120
	                    'CK' => 'Check',
121
	                    'CL' => 'Centre Line',
122
	                    'CLBR' => 'Calibration',
123
	                    'CLD' => 'Cloud',
124
	                    'CLG' => 'Calling',
125
	                    'CLIMB-OUT' => 'Climb-out Area',
126
	                    'CLR' => 'Clearance',
127
	                    'CLRD' => 'Cleared',
128
	                    'CLSD' => 'Closed',
129
	                    'CMB' => 'Climb',
130
	                    'CMPL' => 'Complete',
131
	                    'CNL' => 'Cancel',
132
	                    'CNS' => 'Communications, Navigation And Surveillance',
133
	                    'COM' => 'Communications',
134
	                    'CONC' => 'Concrete',
135
	                    'COND' => 'Condition',
136
	                    'CONS' => 'Continuous',
137
	                    'CONST' => 'Construction',
138
	                    'CONT' => 'Continued',
139
	                    'COOR' => 'Coordination',
140
	                    'COORD' => 'Coordinates',
141
	                    'COP' => 'Change-over Point',
142
	                    'COR' => 'Correction',
143
	                    'COT' => 'At The Coast',
144
	                    'COV' => 'Covered',
145
	                    'CPDLC' => 'Controller-pilot Data Link Communications',
146
	                    'CPL' => 'Current Flight Plan',
147
	                    'CRC' => 'Cyclic Redundancy Check',
148
	                    'CRZ' => 'Cruise',
149
	                    'CTA' => 'Control area',
150
	                    'CTAM' => 'Climb To And Maintain',
151
	                    'CTC' => 'Contact',
152
	                    'CTL' => 'Control',
153
	                    'CTN' => 'Caution',
154
	                    'CTR' => 'Control Zone',
155
	                    'CVR' => 'Cockpit Voice Recorder',
156
	                    'CW' => 'Continuous Wave',
157
	                    'CWY' => 'Clearway',
158
	                    'DA' => 'Decision Altitude',
159
	                    'DCKG' => 'Docking',
160
	                    'DCP' => 'Datum Crossing Point',
161
	                    'DCPC' => 'Direct Controller-pilot Communications',
162
	                    'DCT' => 'Direct',
163
	                    'DEC' => 'December',
164
	                    'DEG' => 'Degrees',
165
	                    'DEP' => 'Departing',
166
	                    'DES' => 'Descend',
167
	                    'DEST' => 'Destination',
168
	                    'DETRESFA' => 'Distress Phase',
169
	                    'DEV' => 'Deviating',
170
	                    'DFDR' => 'Digital Flight Data Recorder',
171
	                    'DFTI' => 'Distance From Touchdown Indicator',
172
	                    'DH' => 'Decision Height',
173
	                    'DIP' => 'Diffuse',
174
	                    'DIST' => 'Distance',
175
	                    'DIV' => 'Divert',
176
	                    'DLA' => 'Delay',
177
	                    'DLY' => 'Daily',
178
	                    'DME' => 'Distance measuring equipment',
179
	                    'DNG' => 'Dangerous',
180
	                    'DOM' => 'Domestic',
181
	                    'DPT' => 'Depth',
182
	                    'DR' => 'Dead Reckoning',
183
	                    'DRG' => 'During',
184
	                    'DTAM' => 'Descend To And Maintain',
185
	                    'DTG' => 'Date-time Group',
186
	                    'DTHR' => 'Displaced Runway Threshold',
187
	                    'DTRT' => 'Deteriorating',
188
	                    'DTW' => 'Dual Tandem Wheels',
189
	                    'DUPE' => 'This Is A Duplicate Message',
190
	                    'DUR' => 'Duration',
191
	                    'DVOR' => 'Doppler VOR',
192
	                    'DW' => 'Dual Wheels',
193
	                    'EAT' => 'Expected Approach Time',
194
	                    'EB' => 'Eastbound',
195
	                    'EDA' => 'Elevation Differential Area',
196
	                    'EET' => 'Estimated Elapsed Time',
197
	                    'EFC' => 'Expect Further Clearance',
198
	                    'ELBA' => 'Emergency Location Beacon',
199
	                    'ELEV' => 'Elevation',
200
	                    'ELR' => 'Extra Long Range',
201
	                    'EM' => 'Emission',
202
	                    'EMERG' => 'Emergency',
203
	                    'END' => 'Stop-end',
204
	                    'ENE' => 'East-north-east',
205
	                    'ENG' => 'Engine',
206
	                    'ENR' => 'En-route',
207
	                    'ENRC' => 'En-route Chart',
208
	                    'EOBT' => 'Estimated Off-block Time',
209
	                    'EQPT' => 'Equipment',
210
	                    'ER' => 'Here',
211
	                    'ESE' => 'East-south-east',
212
	                    'EST' => 'Estimate',
213
	                    'ETA' => 'Estimated Time Of Arrival',
214
	                    'ETD' => 'Estimated Time Of Departure',
215
	                    'ETO' => 'Estimated Time Over Significant Point',
216
	                    'EV' => 'Every',
217
	                    'EXC' => 'Except',
218
	                    'EXER' => 'Exercise',
219
	                    'EXP' => 'Expect',
220
	                    'EXTD' => 'Extend',
221
	                    'FAC' => 'Facilities',
222
	                    'FAF' => 'Final Approach Fix',
223
	                    'FAL' => 'Facilitation of International Airtransport',
224
	                    'FAP' => 'Final Approach Point',
225
	                    'FATO' => 'Final Approach And Take-off Area',
226
	                    'FAX' => 'Fax',
227
	                    'FBL' => 'Light',
228
	                    'FCST' => 'Forecast',
229
	                    'FCT' => 'Friction Coefficient',
230
	                    'FDPS' => 'Flight Data Processing System',
231
	                    'FEB' => 'February',
232
	                    'FIR' => 'Flight information region',
233
	                    'FIS' => 'Flight information service',
234
	                    'FLD' => 'Field',
235
	                    'FLG' => 'Flashing',
236
	                    'FLR' => 'Flares',
237
	                    'FLT' => 'Flight',
238
	                    'FLTS' => 'Flights',
239
	                    'FLTCK' => 'Flight Check',
240
	                    'FLUC' => 'Fluctuating',
241
	                    'FLW' => 'Follow(s)',
242
	                    'FLY' => 'Fly',
243
	                    'FM' => 'From',
244
	                    'FMS' => 'Flight Management System',
245
	                    'FMU' => 'Flow Management Unit',
246
	                    'FNA' => 'Final Approach',
247
	                    'FPAP' => 'Flight Path Alignment Point',
248
	                    'FPL' => 'Flight Plan',
249
	                    'FPLS' => 'Flight Plans',
250
	                    'FPM' => 'Feet Per Minute',
251
	                    'FPR' => 'Flight Plan Route',
252
	                    'FR' => 'Fuel Remaining',
253
	                    'FREQ' => 'Frequency',
254
	                    'FRI' => 'Friday',
255
	                    'FRMG' => 'Missile, gun or rocket firing',
256
	                    'FRNG' => 'Firing',
257
	                    'FRONT' => 'Front',
258
	                    'FRQ' => 'Frequent',
259
	                    'FSL' => 'Full Stop Landing',
260
	                    'FSS' => 'Flight Service Station',
261
	                    'FST' => 'First',
262
	                    'FTP' => 'Fictitious Threshold Point',
263
	                    'G/A' => 'Ground-to-air',
264
	                    'G/A/G' => 'Ground-to-air and Air-to-ground',
265
	                    'GARP' => 'GBAS Azimuth Reference Point',
266
	                    'GBAS' => 'Ground-based Augmentation System',
267
	                    'GCAJ' => 'Ground Controlled Approach',
268
	                    'GCA' => 'Ground Controlled Approach System',
269
	                    'GEN' => 'General',
270
	                    'GEO' => 'Geographic or True',
271
	                    'GES' => 'Ground Earth Station',
272
	                    'GLD' => 'Glider',
273
	                    'GMC' => 'Ground Movement Chart',
274
	                    'GND' => 'Ground',
275
	                    'GNDCK' => 'Ground Check',
276
	                    'GP' => 'Glide Path',
277
	                    'GRASS' => 'Grass landing area',
278
	                    'GRVL' => 'Gravel',
279
	                    'GUND' => 'Geoid Undulation',
280
	                    'H24' => '24 Hours',
281
	                    'HAPI' => 'Helicopter Approach Path Indicator',
282
	                    'HBN' => 'Hazard Beacon',
283
	                    'HDG' => 'Heading',
284
	                    'HEL' => 'Helicopter',
285
	                    'HGT' => 'Height',
286
	                    'HJ' => 'Sunrise to Sunset',
287
	                    'HLDG' => 'Holding',
288
	                    'HN' => 'Sunset to Sunrise',
289
	                    'HO' => 'Service Available To Meet Operational Requirements',
290
	                    'HOL' => 'Holiday',
291
	                    'HOSP' => 'Hospital Aircraft',
292
	                    'HOT' => 'Height',
293
	                    'HPA' => 'Hectopascal',
294
	                    'HR' => 'Hours',
295
	                    'HRS' => 'Hours',
296
	                    'HS' => 'Service Available During Hours Of Scheduled Operations',
297
	                    'HURCN' => 'Hurricane',
298
	                    'HVY' => 'Heavy',
299
	                    'HX' => 'No Specific Working Hours',
300
	                    'HYR' => 'Higher',
301
	                    'IAC' => 'Instrument Approach Chart',
302
	                    'IAF' => 'Initial Approach Fix',
303
	                    'IAO' => 'In And Out Of Clouds',
304
	                    'IAP' => 'Instrument Approach Procedure',
305
	                    'IAR' => 'Intersection Of Air Routes',
306
	                    'IBN' => 'Identification Beacon',
307
	                    'ID' => 'Identifier',
308
	                    'IDENT' => 'Identification',
309
	                    'IFF' => 'Identification Friend/Foe',
310
	                    'IGA' => 'International General Aviation',
311
	                    'IM' => 'Inner Marker',
312
	                    'IMPR' => 'Improving',
313
	                    'IMT' => 'Immediately',
314
	                    'INA' => 'Initial Approach',
315
	                    'INBD' => 'Inbound',
316
	                    'INCERFA' => 'Uncertainty Phase',
317
	                    'INFO' => 'Information',
318
	                    'INOP' => 'Inoperative',
319
	                    'INP' => 'If Not Possible',
320
	                    'INPR' => 'In Progress',
321
	                    'INSTL' => 'Installation',
322
	                    'INSTR' => 'Instrument',
323
	                    'INT' => 'Intersection',
324
	                    'INTS' => 'Intersections',
325
	                    'INTL' => 'International',
326
	                    'INTRG' => 'Interrogator',
327
	                    'INTRP' => 'Interruption',
328
	                    'INTSF' => 'Intensifying',
329
	                    'INTST' => 'Intensity',
330
	                    'ISA' => 'International Standard Atmosphere',
331
	                    'JAN' => 'January',
332
	                    'JTST' => 'Jet stream',
333
	                    'JUL' => 'July',
334
	                    'JUN' => 'June',
335
	                    'KMH' => 'Kilometres Per Hour',
336
	                    'KPA' => 'Kilopascal',
337
	                    'KT' => 'Knots',
338
	                    'KW' => 'Kilowatts',
339
	                    'LAN' => 'Inland',
340
	                    'LAT' => 'Latitude',
341
	                    'LDA' => 'Landing Distance Available',
342
	                    'LDAH' => 'Landing Distance Available, Helicopter',
343
	                    'LDG' => 'Landing',
344
	                    'LDI' => 'Landing Direction Indicator',
345
	                    'LEN' => 'Length',
346
	                    'LGT' => 'Lighting',
347
	                    'LGTD' => 'Lighted',
348
	                    'LIH' => 'Light Intensity High',
349
	                    'LIL' => 'Light Intensity Low',
350
	                    'LIM' => 'Light Intensity Medium',
351
	                    'LLZ' => 'Localizer',
352
	                    'LM' => 'Locator, Middle',
353
	                    'LMT' => 'Local Mean Time',
354
	                    'LNG' => 'Long',
355
	                    'LO' => 'Locator, Outer',
356
	                    'LOG' => 'Located',
357
	                    'LONG' => 'Longitude',
358
	                    'LRG' => 'Long Range',
359
	                    'LTD' => 'Limited',
360
	                    'LTP' => 'Landing Threshold Point',
361
	                    'LVE' => 'Leaving',
362
	                    'LVL' => 'Level',
363
	                    'LYR' => 'Layer',
364
	                    'MAA' => 'Maximum Authorized Altitude',
365
	                    'MAG' => 'Magnetic',
366
	                    'MAINT' => 'Maintenance',
367
	                    'MAP' => 'Aeronautical Maps and Charts',
368
	                    'MAPT' => 'Missed Approach Point',
369
	                    'MAR' => 'March',
370
	                    'MAX' => 'Maximum',
371
	                    'MAY' => 'May',
372
	                    'MBST' => 'Microburst',
373
	                    'MCA' => 'Minimum Crossing Altitude',
374
	                    'MCW' => 'Modulated Continuous Wave',
375
	                    'MDA' => 'Minimum Descent Altitude',
376
	                    'MDH' => 'Minimum Descent Height',
377
	                    'MEA' => 'Minimum En-route Altitude',
378
	                    'MEHT' => 'Minimum Eye Height Over Threshold',
379
	                    'MET' => 'Meteorological',
380
	                    'MID' => 'Mid-point',
381
	                    'MIL' => 'Military',
382
	                    'MIN' => 'Minutes',
383
	                    'MKR' => 'Marker Radio Beacon',
384
	                    'MLS' => 'Microwave Landing System',
385
	                    'MM' => 'Middle Marker',
386
	                    'MNM' => 'Minimum',
387
	                    'MNPS' => 'Minimum Navigation Performance Specifications',
388
	                    'MNT' => 'Monitor',
389
	                    'MNTN' => 'Maintain',
390
	                    'MOA' => 'Military Operating Area',
391
	                    'MOC' => 'Minimum Obstacle Clearance',
392
	                    'MOD' => 'Moderate',
393
	                    'MON' => 'Monday',
394
	                    'MOPS' => 'Minimum Operational Performance Standards',
395
	                    'MOV' => 'Movement',
396
	                    'MRA' => 'Minimum Reception Altitude',
397
	                    'MRG' => 'Medium Range',
398
	                    'MRP' => 'ATS/MET Reporting Point',
399
	                    'MS' => 'Minus',
400
	                    'MSA' => 'Minimum Sector Altitude',
401
	                    'MSAW' => 'Minimum Safe Altitude Warning',
402
	                    'MSG' => 'Message',
403
	                    'MSSR' => 'Monopulse Secondary Surveillance Radar',
404
	                    'MT' => 'Mountain',
405
	                    'MTU' => 'Metric Units',
406
	                    'MTW' => 'Mountain Waves',
407
	                    'NASC' => 'National AIS System Centre',
408
	                    'NAT' => 'North Atlantic',
409
	                    'NAV' => 'Navigation',
410
	                    'NB' => 'Northbound',
411
	                    'NBFR' => 'Not Before',
412
	                    'NE' => 'North-east',
413
	                    'NEB' => 'North-eastbound',
414
	                    'NEG' => 'Negative',
415
	                    'NGT' => 'Night',
416
	                    'NIL' => 'None',
417
	                    'NML' => 'Normal',
418
	                    'NNE' => 'North-north-east',
419
	                    'NNW' => 'North-north-west',
420
	                    'NOF' => 'International NOTAM Office',
421
	                    'NOV' => 'November',
422
	                    'NOZ' => 'Normal Operating Zone',
423
	                    'NR' => 'Number',
424
	                    'NRH' => 'No Reply Heard',
425
	                    'NTL' => 'National',
426
	                    'NTZ' => 'No Transgression Zone',
427
	                    'NW' => 'North-west',
428
	                    'NWB' => 'North-westbound',
429
	                    'NXT' => 'Next',
430
	                    'O/R' => 'On Request',
431
	                    'OAC' => 'Oceanic Area Control Centre',
432
	                    'OAS' => 'Obstacle Assessment Surface',
433
	                    'OBS' => 'Observe',
434
	                    'OBST' => 'Obstacle',
435
	                    'OBSTS' => 'Obstacles',
436
	                    'OCA' => 'Oceanic Control Area',
437
	                    'OCH' => 'Obstacle Clearance Height',
438
	                    'OCL' => 'Obstacle Clearance Limit',
439
	                    'OCS' => 'Obstacle Clearance Surface',
440
	                    'OCT' => 'October',
441
	                    'OFZ' => 'Obstacle Free Zone',
442
	                    'OGN' => 'Originate',
443
	                    'OHD' => 'Overhead',
444
	                    'OM' => 'Outer Marker',
445
	                    'OPC' => 'Control Indicated Is Operational Control',
446
	                    'OPMET' => 'Operational Meteorological',
447
	                    'OPN' => 'Open',
448
	                    'OPR' => 'Operate',
449
	                    'OPS' => 'Operations',
450
	                    'ORD' => 'Order',
451
	                    'OSV' => 'Ocean Station Vessel',
452
	                    'OTLK' => 'Outlook',
453
	                    'OTP' => 'On Top',
454
	                    'OTS' => 'Organized Track System',
455
	                    'OUBD' => 'Outbound',
456
	                    'PA' => 'Precision Approach',
457
	                    'PALS' => 'Precision Approach Lighting System',
458
	                    'PANS' => 'Procedures for Air Navigation Services',
459
	                    'PAR' => 'Precision Approach Radar',
460
	                    'PARL' => 'Parallel',
461
	                    'PATC' => 'Precision Approach Terrain Chart',
462
	                    'PAX' => 'Passenger(s)',
463
	                    'PCD' => 'Proceed',
464
	                    'PCL' => 'Pilot-controlled Lighting',
465
	                    'PCN' => 'Pavement Classification Number',
466
	                    'PDC' => 'Pre-departure Clearance',
467
	                    'PDG' => 'Procedure Design Gradient',
468
	                    'PER' => 'Performance',
469
	                    'PERM' => 'Permanent',
470
	                    'PIB' => 'Pre-flight Information Bulletin',
471
	                    'PJE' => 'Parachute Jumping Exercise',
472
	                    'PLA' => 'Practice Low Approach',
473
	                    'PLN' => 'Flight Plan',
474
	                    'PLVL' => 'Present Level',
475
	                    'PN' => 'Prior Notice Required',
476
	                    'PNR' => 'Point Of No Return',
477
	                    'POB' => 'Persons On Board',
478
	                    'POSS' => 'Possible',
479
	                    'PPI' => 'Plan Position Indicator',
480
	                    'PPR' => 'Prior Permission Required',
481
	                    'PPSN' => 'Present Position',
482
	                    'PRI' => 'Primary',
483
	                    'PRKG' => 'Parking',
484
	                    'PROB' => 'Probability',
485
	                    'PROC' => 'Procedure',
486
	                    'PROV' => 'Provisional',
487
	                    'PS' => 'Plus',
488
	                    'PSG' => 'Passing',
489
	                    'PSN' => 'Position',
490
	                    'PSNS' => 'Positions',
491
	                    'PSR' => 'Primary Surveillance Radar',
492
	                    'PSYS' => 'Pressure System(s)',
493
	                    'PTN' => 'Procedure Turn',
494
	                    'PTS' => 'Polar Track Structure',
495
	                    'PWR' => 'Power',
496
	                    'QUAD' => 'Quadrant',
497
	                    'RAC' => 'Rules of The Air and Air Traffic Services',
498
	                    'RAG' => 'Runway Arresting Gear',
499
	                    'RAI' => 'Runway Alignment Indicator',
500
	                    'RASC' => 'Regional AIS System Centre',
501
	                    'RASS' => 'Remote Altimeter Setting Source',
502
	                    'RB' => 'Rescue Boat',
503
	                    'RCA' => 'Reach Cruising Altitude',
504
	                    'RCC' => 'Rescue Coordination Centre',
505
	                    'RCF' => 'Radiocommunication Failure',
506
	                    'RCH' => 'Reaching',
507
	                    'RCL' => 'Runway Centre Line',
508
	                    'RCLL' => 'Runway Centre Line Light(s)',
509
	                    'RCLR' => 'Recleared',
510
	                    'RDH' => 'Reference Datum Height',
511
	                    'RDL' => 'Radial',
512
	                    'RDO' => 'Radio',
513
	                    'RE' => 'Recent',
514
	                    'REC' => 'Receiver',
515
	                    'REDL' => 'Runway Edge Light(s)',
516
	                    'REF' => 'Refer To',
517
	                    'REG' => 'Registration',
518
	                    'RENL' => 'Runway End Light(s)',
519
	                    'REP' => 'Report',
520
	                    'REQ' => 'Requested',
521
	                    'RERTE' => 'Re-route',
522
	                    'RESA' => 'Runway End Safety Area',
523
	                    'RG' => 'Range (lights)',
524
	                    'RHC' => 'Right-hand Circuit',
525
	                    'RIF' => 'Reclearance In Flight',
526
	                    'RITE' => 'Right',
527
	                    'RL' => 'Report Leaving',
528
	                    'RLA' => 'Relay To',
529
	                    'RLCE' => 'Request Level Change En Route',
530
	                    'RLLS' => 'Runway Lead-in Lighting System',
531
	                    'RLNA' => 'Request Level Not Available',
532
	                    'RMAC' => 'Radar Minimum Altitude Chart',
533
	                    'RMK' => 'Remark',
534
	                    'RNG' => 'Radio Range',
535
	                    'RNP' => 'Required Navigation Performance',
536
	                    'ROC' => 'Rate Of Climb',
537
	                    'ROD' => 'Rate Of Descent',
538
	                    'ROFOR' => 'Route Forecast',
539
	                    'RON' => 'Receiving Only',
540
	                    'RPI' => 'Radar Position Indicator',
541
	                    'RPL' => 'Repetitive Flight Plan',
542
	                    'RPLC' => 'Replaced',
543
	                    'RPS' => 'Radar Position Symbol',
544
	                    'RQMNTS' => 'Requirements',
545
	                    'RQP' => 'Request Flight Plan',
546
	                    'RQS' => 'Request Supplementary Flight Plan',
547
	                    'RR' => 'Report Reaching',
548
	                    'RSC' => 'Rescue Sub-centre',
549
	                    'RSCD' => 'Runway Surface Condition',
550
	                    'RSP' => 'Responder Beacon',
551
	                    'RSR' => 'En-route Surveillance Radar',
552
	                    'RTE' => 'Route',
553
	                    'RTES' => 'Routes',
554
	                    'RTF' => 'Radiotelephone',
555
	                    'RTG' => 'Radiotelegraph',
556
	                    'RTHL' => 'Runway Threshold Light(s)',
557
	                    'RTN' => 'Return',
558
	                    'RTODAH' => 'Rejected Take-off Distance Available, Helicopter',
559
	                    'RTS' => 'Return To Service',
560
	                    'RTT' => 'Radioteletypewriter',
561
	                    'RTZL' => 'Runway Touchdown Zone Light(s)',
562
	                    'RUT' => 'Standard Regional Route Transmitting Frequencies',
563
	                    'RV' => 'Rescue Vessel',
564
	                    'RVSM' => 'Reduced Vertical Separation Minimum',
565
	                    'RWY' => 'Runway',
566
	                    'RWYS' => 'Runways',
567
	                    'SALS' => 'Simple Approach Lighting System',
568
	                    'SAN' => 'Sanitary',
569
	                    'SAP' => 'As Soon As Possible',
570
	                    'SAR' => 'Search and Rescue',
571
	                    'SARPS' => 'Standards and Recommended Practices',
572
	                    'SAT' => 'Saturday',
573
	                    'SATCOM' => 'Satellite Communication',
574
	                    'SB' => 'Southbound',
575
	                    'SBAS' => 'Satellite-based Augmentation System',
576
	                    'SDBY' => 'Stand by',
577
	                    'SE' => 'South-east',
578
	                    'SEA' => 'Sea',
579
	                    'SEB' => 'South-eastbound',
580
	                    'SEC' => 'Seconds',
581
	                    'SECN' => 'Section',
582
	                    'SECT' => 'Sector',
583
	                    'SELCAL' => 'Selective calling system',
584
	                    'SEP' => 'September',
585
	                    'SER' => 'Service',
586
	                    'SEV' => 'Severe',
587
	                    'SFC' => 'Surface',
588
	                    'SGL' => 'Signal',
589
	                    'SID' => 'Standard Instrument Departure',
590
	                    'SIF' => 'Selective Identification Feature',
591
	                    'SIG' => 'Significant',
592
	                    'SIMUL' => 'Simultaneous',
593
	                    'SKED' => 'Schedule',
594
	                    'SLP' => 'Speed Limiting Point',
595
	                    'SLW' => 'Slow',
596
	                    'SMC' => 'Surface Movement Control',
597
	                    'SMR' => 'Surface Movement Radar',
598
	                    'SPL' => 'Supplementary Flight Plan',
599
	                    'SPOC' => 'SAR Point Of Contact',
600
	                    'SPOT' => 'Spot Wind',
601
	                    'SR' => 'Sunrise',
602
	                    'SRA' => 'Surveillance Radar Approach',
603
	                    'SRE' => 'Surveillance Radar Element Of Precision Approach Radar System',
604
	                    'SRG' => 'Short Range',
605
	                    'SRR' => 'Search and Rescue Region',
606
	                    'SRY' => 'Secondary',
607
	                    'SS' => 'Sunset',
608
	                    'SSE' => 'South-south-east',
609
	                    'SSR' => 'Secondary Surveillance Radar',
610
	                    'SST' => 'Supersonic Transport',
611
	                    'SSW' => 'South-south-west',
612
	                    'STA' => 'Straight-in Approach',
613
	                    'STAR' => 'Standard Instrument Arrival',
614
	                    'STD' => 'Standard',
615
	                    'STN' => 'Station',
616
	                    'STNR' => 'Stationary',
617
	                    'STOL' => 'Short Take-off and Landing',
618
	                    'STS' => 'Status',
619
	                    'STWL' => 'Stopway Light(s)',
620
	                    'SUBJ' => 'Subject To',
621
	                    'SUN' => 'Sunday',
622
	                    'SUP' => 'Supplement',
623
	                    'SUPPS' => 'Regional Supplementary Procedures Service Message',
624
	                    'SVCBL' => 'Serviceable',
625
	                    'SW' => 'South-west',
626
	                    'SWB' => 'South-westbound',
627
	                    'SWY' => 'Stopway',
628
	                    'TA' => 'Transition Altitude',
629
	                    'TAA' => 'Terminal Arrival Altitude',
630
	                    'TAF' => 'Aerodrome Forecast',
631
	                    'TAIL' => 'Tail Wind',
632
	                    'TAR' => 'Terminal Area Surveillance Radar',
633
	                    'TAX' => 'Taxi',
634
	                    'TCAC' => 'Tropical Cyclone Advisory Centre',
635
	                    'TDO' => 'Tornado',
636
	                    'TDZ' => 'Touchdown Zone',
637
	                    'TECR' => 'Technical Reason',
638
	                    'TEMPO' => 'Temporarily',
639
	                    'TFC' => 'Traffic',
640
	                    'TGL' => 'Touch-and-go',
641
	                    'TGS' => 'Taxiing Guidance System',
642
	                    'THR' => 'Threshold',
643
	                    'THRU' => 'Through',
644
	                    'THU' => 'Thursday',
645
	                    'TIBA' => 'Traffic Information Broadcast By Aircraft',
646
	                    'TIL' => 'Until',
647
	                    'TIP' => 'Until Past',
648
	                    'TKOF' => 'Take-off',
649
	                    'TL' => 'Till',
650
	                    'TLOF' => 'Touchdown And Lift-off Area',
651
	                    'TMA' => 'Terminal Control Area',
652
	                    'TNA' => 'Turn Altitude',
653
	                    'TNH' => 'Turn Height',
654
	                    'TOC' => 'Top of Climb',
655
	                    'TODA' => 'Take-off Distance Available',
656
	                    'TODAH' => 'Take-off Distance Available, Helicopter',
657
	                    'TORA' => 'Take-off Run Available',
658
	                    'TP' => 'Turning Point',
659
	                    'TR' => 'Track',
660
	                    'TRA' => 'Temporary Reserved Airspace',
661
	                    'TRANS' => 'Transmitter',
662
	                    'TRL' => 'Transition Level',
663
	                    'TUE' => 'Tuesday',
664
	                    'TURB' => 'Turbulence',
665
	                    'TVOR' => 'Terminal VOR',
666
	                    'TWR' => 'Tower',
667
	                    'TWY' => 'Taxiway',
668
	                    'TWYL' => 'Taxiway-link',
669
	                    'TXT' => 'Text',
670
	                    'TYP' => 'Type of Aircraft',
671
	                    'U/S' => 'Unserviceable',
672
	                    'UAB' => 'Until Advised By',
673
	                    'UAC' => 'Upper Area Control Centre',
674
	                    'UAR' => 'Upper Air Route',
675
	                    'UDA' => 'Upper advisory area',
676
	                    'UFN' => 'Until Further Notice',
677
	                    'UHDT' => 'Unable Higher Due Traffic',
678
	                    'UIC' => 'Upper Information Centre',
679
	                    'UIR' => 'Upper Flight Information Region',
680
	                    'ULR' => 'Ultra Long Range',
681
	                    'UNA' => 'Unable',
682
	                    'UNAP' => 'Unable To Approve',
683
	                    'UNL' => 'Unlimited',
684
	                    'UNREL' => 'Unreliable',
685
	                    'UTA' => 'Upper Control Area',
686
	                    'VAAC' => 'Volcanic Ash Advisory Centre',
687
	                    'VAC' => 'Visual Approach Chart',
688
	                    'VAL' => 'In Valleys',
689
	                    'VAN' => 'Runway Control Van',
690
	                    'VAR' => 'Visual-aural Radio Range',
691
	                    'VC' => 'Vicinity',
692
	                    'VCY' => 'Vicinity',
693
	                    'VER' => 'Vertical',
694
	                    'VIS' => 'Visibility',
695
	                    'VLR' => 'Very Long Range',
696
	                    'VPA' => 'Vertical Path Angle',
697
	                    'VRB' => 'Variable',
698
	                    'VSA' => 'By Visual Reference To The Ground',
699
	                    'VSP' => 'Vertical Speed',
700
	                    'VTOL' => 'Vertical Take-off And Landing',
701
	                    'WAC' => 'World Aeronautical Chart',
702
	                    'WAFC' => 'World Area Forecast Centre',
703
	                    'WB' => 'Westbound',
704
	                    'WBAR' => 'Wing Bar Lights',
705
	                    'WDI' => 'Wind Direction Indicator',
706
	                    'WDSPR' => 'Widespread',
707
	                    'WED' => 'Wednesday',
708
	                    'WEF' => 'Effective From',
709
	                    'WI' => 'Within',
710
	                    'WID' => 'Width',
711
	                    'WIE' => 'Effective Immediately',
712
	                    'WILCO' => 'Will Comply',
713
	                    'WIND' => 'Wind',
714
	                    'WINTEM' => 'Forecast Upper Wind And Temperature For Aviation',
715
	                    'WIP' => 'Work In Progress',
716
	                    'WKN' => 'Weaken',
717
	                    'WNW' => 'West-north-west',
718
	                    'WO' => 'Without',
719
	                    'WPT' => 'Way-point',
720
	                    'WRNG' => 'Warning',
721
	                    'WSW' => 'West-south-west',
722
	                    'WT' => 'Weight',
723
	                    'WWW' => 'Worldwide Web',
724
	                    'WX' => 'Weather',
725
	                    'XBAR' => 'Crossbar',
726
	                    'XNG' => 'Crossing',
727
	                    'XS' => 'Atmospherics',
728
	                    'YCZ' => 'Yellow Caution Zone',
729
	                    'YR' => 'Your');
730
	public $code_airspace = array(
731
			    'AA' => 'Minimum altitude',
732
			    'AC' => 'Class B, C, D, or E Surface Area',
733
			    'AD' => 'Air defense identification zone',
734
			    'AE' => 'Control area',
735
			    'AF' => 'Flight information region',
736
			    'AH' => 'Upper control area',
737
			    'AL' => 'Minimum usable flight level',
738
			    'AN' => 'Area navigation route',
739
			    'AO' => 'Oceanic control area',
740
			    'AP' => 'Reporting point',
741
			    'AR' => 'ATS route',
742
			    'AT' => 'Class B Airspace',
743
			    'AU' => 'Upper flight information region',
744
			    'AV' => 'Upper advisory area',
745
			    'AX' => 'Intersection',
746
			    'AZ' => 'Aerodrome traffic zone');
747
	public $code_comradar = array(
748
			    'CA' => 'Air/ground',
749
			    'CE' => 'En route surveillance radar',
750
			    'CG' => 'Ground controlled approach system',
751
			    'CL' => 'Selective calling system',
752
			    'CM' => 'Surface movement radar',
753
			    'CP' => 'Precision approach radar',
754
			    'CR' => 'Surveillance radar element of precision approach radar system',
755
			    'CS' => 'Secondary surveillance radar',
756
			    'CT' => 'Terminal area surveillance radar');
757
	public $code_facilities = array(
758
			    'FA' => 'airport',
759
			    'FB' => 'Braking action measurement equipment',
760
			    'FC' => 'Ceiling measurement equipment',
761
			    'FD' => 'Docking system',
762
			    'FF' => 'Fire fighting and rescue',
763
			    'FG' => 'Ground movement control',
764
			    'FH' => 'Helicopter alighting area/platform',
765
			    'FL' => 'Landing direction indicator',
766
			    'FM' => 'Meteorological service',
767
			    'FO' => 'Fog dispersal system',
768
			    'FP' => 'Heliport',
769
			    'FS' => 'Snow removal equipment',
770
			    'FT' => 'Transmissometer',
771
			    'FU' => 'Fuel availability',
772
			    'FW' => 'Wind direction indicator',
773
			    'FZ' => 'Customs');
774
	public $code_instrumentlanding = array(
775
			    'ID' => 'DME associated with ILS',
776
			    'IG' => 'Glide path',
777
			    'II' => 'Inner marker',
778
			    'IL' => 'Localizer',
779
			    'IM' => 'Middle marker',
780
			    'IO' => 'Outer marker',
781
			    'IS' => 'ILS Category I',
782
			    'IT' => 'ILS Category II',
783
			    'IU' => 'ILS Category III',
784
			    'IW' => 'Microwave landing system',
785
			    'IX' => 'Locator, outer',
786
			    'IY' => 'Locator, middle');
787
	public $code_lightingfacilities = array(
788
			    'LA' => 'Approach lighting system',
789
			    'LB' => 'Airport beacon',
790
			    'LC' => 'Runway center line lights',
791
			    'LD' => 'Landing direction indicator lights',
792
			    'LE' => 'Runway edge lights',
793
			    'LF' => 'Sequenced flashing lights',
794
			    'LH' => 'High intensity runway lights',
795
			    'LI' => 'Runway end identifier lights',
796
			    'LK' => 'Category II components of approach lighting system',
797
			    'LL' => 'Low intensity runway lights',
798
			    'LM' => 'Medium intensity runway lights',
799
			    'LP' => 'Precision approach path indicator',
800
			    'LR' => 'All landing area lighting facilities',
801
			    'LS' => 'Stopway lights',
802
			    'LT' => 'Threshold lights',
803
			    'LV' => 'Visual approach slope indicator system',
804
			    'LW' => 'Heliport lighting',
805
			    'LX' => 'Taxiway center line lights',
806
			    'LY' => 'Taxiway edge lights',
807
			    'LZ' => 'Runway touchdown zone lights');
808
	public $code_movementareas = array(
809
			    'MA' => 'Movement area',
810
			    'MB' => 'Bearing strength',
811
			    'MC' => 'Clearway',
812
			    'MD' => 'Declared distances',
813
			    'MG' => 'Taxiing guidance system',
814
			    'MH' => 'Runway arresting gear',
815
			    'MK' => 'Parking area',
816
			    'MM' => 'Daylight markings',
817
			    'MN' => 'Apron',
818
			    'MP' => 'Aircraft stands',
819
			    'MR' => 'Runway',
820
			    'MS' => 'Stopway',
821
			    'MT' => 'Threshold',
822
			    'MU' => 'Runway turning bay',
823
			    'MW' => 'Strip',
824
			    'MX' => 'Taxiway');
825
	public $code_terminalfacilities = array(
826
			    'NA' => 'All radio navigation facilities',
827
			    'NB' => 'Non directional beacon',
828
			    'NC' => 'DECCA',
829
			    'ND' => 'Distance measuring equipment',
830
			    'NF' => 'Fan marker',
831
			    'NL' => 'Locator',
832
			    'NM' => 'VOR/DME',
833
			    'NN' => 'TACAN',
834
			    'NO' => 'OMEGA',
835
			    'NT' => 'VORTAC',
836
			    'NV' => 'VOR',
837
			    'NX' => 'Direction finding station');
838
	public $code_information = array(
839
			    'OA' => 'Aeronautical information service',
840
			    'OB' => 'Obstacle',
841
			    'OE' => 'Aircraft entry requirements',
842
			    'OL' => 'Obstacle lights on',
843
			    'OR' => 'Rescue coordination centre');
844
	public $code_airtraffic = array(
845
			    'PA' => 'Standard instrument arrival',
846
			    'PD' => 'Standard instrument departure',
847
			    'PF' => 'Flow control procedure',
848
			    'PH' => 'Holding procedure',
849
			    'PI' => 'Instrument approach procedure',
850
			    'PL' => 'Obstacle clearance limit',
851
			    'PM' => 'Aerodrome operating minima',
852
			    'PO' => 'Obstacle clearance altitude',
853
			    'PP' => 'Obstacle clearance height',
854
			    'PR' => 'Radio failure procedure',
855
			    'PT' => 'Transition altitude',
856
			    'PU' => 'Missed approach procedure',
857
			    'PX' => 'Minimum holding altitude',
858
			    'PZ' => 'ADIZ procedure');
859
	public $code_navigationw = array(
860
			    'RA' => 'Airspace reservation',
861
			    'RD' => 'Danger area',
862
			    'RO' => 'Overflying of',
863
			    'RP' => 'Prohibited area',
864
			    'RR' => 'Restricted area',
865
			    'RT' => 'Temporary restricted area');
866
	public $code_volmet = array(
867
			    'SA' => 'Automatic terminal information service',
868
			    'SB' => 'ATS reporting office',
869
			    'SC' => 'Area control center',
870
			    'SE' => 'Flight information service',
871
			    'SF' => 'Airport flight information service',
872
			    'SL' => 'Flow control centre',
873
			    'SO' => 'Oceanic area control centre',
874
			    'SP' => 'Approach control service',
875
			    'SS' => 'Flight service station',
876
			    'ST' => 'Airport control tower',
877
			    'SU' => 'Upper area control centre',
878
			    'SV' => 'VOLMET broadcast',
879
			    'SY' => 'Upper advisory service');
880
	public $code_warnings = array(
881
			    'WA' => 'Air display',
882
			    'WB' => 'Aerobatics',
883
			    'WC' => 'Captive balloon or kite',
884
			    'WD' => 'Demolition of explosives',
885
			    'WE' => 'Exercises',
886
			    'WF' => 'Air refueling',
887
			    'WG' => 'Glider flying',
888
			    'WJ' => 'Banner/target towing',
889
			    'WL' => 'Ascent of free balloon',
890
			    'WM' => 'Missile, gun or rocket firing',
891
			    'WP' => 'Parachute jumping exercise',
892
			    'WS' => 'Burning or blowing gas',
893
			    'WT' => 'Mass movement of aircraft',
894
			    'WV' => 'Formation flight',
895
			    'WZ' => 'model flying');
896
	public $code_sp_availabity = array(
897
			    'AC' => 'Withdrawn for maintenance',
898
			    'AD' => 'Available for daylight operation',
899
			    'AF' => 'Flight checked and found reliable',
900
			    'AG' => 'Operating but ground checked only, awaiting flight check',
901
			    'AH' => 'Hours of service are now',
902
			    'AK' => 'Resumed normal operations',
903
			    'AM' => 'Military operations only',
904
			    'AN' => 'Available for night operation',
905
			    'AO' => 'Operational',
906
			    'AP' => 'Available, prior permission required',
907
			    'AR' => 'Available on request',
908
			    'AS' => 'Unserviceable',
909
			    'AU' => 'Not available',
910
			    'AW' => 'Completely withdrawn',
911
			    'AX' => 'Previously promulgated shutdown has been cancelled');
912
	public $code_sp_changes = array(
913
			    'CA' => 'Activated',
914
			    'CC' => 'Completed',
915
			    'CD' => 'Deactivated',
916
			    'CE' => 'Erected',
917
			    'CF' => 'Operating frequency(ies) changed to',
918
			    'CG' => 'Downgraded to',
919
			    'CH' => 'Changed',
920
			    'CI' => 'dentification or radio call sign changed to',
921
			    'CL' => 'Realigned',
922
			    'CM' => 'Displaced',
923
			    'CO' => 'Operating',
924
			    'CP' => 'Operating on reduced power',
925
			    'CR' => 'Temporarily replaced by',
926
			    'CS' => 'Installed',
927
			    'CT' => 'On test, do not use');
928
	public $code_sp_hazardous = array(
929
			    'HA' => 'Braking action is',
930
			    'HB' => 'Braking coefficient is',
931
			    'HC' => 'Covered by compacted snow to depth of x Ft',
932
			    'HD' => 'Covered by dry snow to a depth of x Ft',
933
			    'HE' => 'Covered by water to a depth of x Ft',
934
			    'HF' => 'Totally free of snow and ice',
935
			    'HG' => 'Grass cutting in progress',
936
			    'HH' => 'Hazard due to',
937
			    'HI' => 'Covered by ice',
938
			    'HJ' => 'Launch planned',
939
			    'HK' => 'Migration in progress',
940
			    'HL' => 'Snow clearance completed',
941
			    'HM' => 'Marked by',
942
			    'HN' => 'Covered by wet snow or slush to a depth of x Ft',
943
			    'HO' => 'Obscured by snow',
944
			    'HP' => 'Snow clearance in progress',
945
			    'HQ' => 'Operation cancelled',
946
			    'HR' => 'Standing water',
947
			    'HS' => 'Sanding in progress',
948
			    'HT' => 'Approach according to signal area only',
949
			    'HU' => 'Launch in progress',
950
			    'HV' => 'Work completed',
951
			    'HW' => 'Work in progress',
952
			    'HX' => 'Concentration of birds',
953
			    'HY' => 'Snow banks exist',
954
			    'HZ' => 'Covered by frozen ruts and ridges');
955
	public $code_sp_limitations = array(
956
			    'LA' => 'Operating on Auxiliary Power Supply',
957
			    'LB' => 'Reserved for aircraft based therein',
958
			    'LC' => 'Closed',
959
			    'LD' => 'Unsafe',
960
			    'LE' => 'Operated without auxiliary power supply',
961
			    'LF' => 'Interference from',
962
			    'LG' => 'Operating without identification',
963
			    'LH' => 'Unserviceable for aircraft heavier than',
964
			    'LI' => 'Close to IFR operations',
965
			    'LK' => 'Operating as a fixed light',
966
			    'LL' => 'Usable for lenght of... and width of...',
967
			    'LN' => 'Close to all night operations',
968
			    'LP' => 'Prohibited to',
969
			    'LR' => 'Aircraft restricted to runways and taxiways',
970
			    'LS' => 'Subject to interruption',
971
			    'LT' => 'Limited to',
972
			    'LV' => 'Close to VFR operations',
973
			    'LW' => 'Will take place',
974
			    'LX' => 'Operating but caution advised to'); 
975
976
	public function __construct($dbc = null) {
977
		$Connection = new Connection($dbc);
978
		$this->db = $Connection->db;
979
	}
980
	public function getAllNOTAM() {
981
		global $globalDBdriver;
982
		if ($globalDBdriver == 'mysql') {
983
			$query  = 'SELECT * FROM notam WHERE radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()';
984
		} else {
985
			$query  = "SELECT * FROM notam WHERE radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
986
		}
987
		$query_values = array();
988
		try {
989
			$sth = $this->db->prepare($query);
990
			$sth->execute($query_values);
991
		} catch(PDOException $e) {
992
			echo "error : ".$e->getMessage();
993
			return array();
994
		}
995
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
996
		return $all;
997
	}
998
	public function getAllNOTAMbyFir($fir) {
999
		global $globalDBdriver;
1000
		if ($globalDBdriver == 'mysql') {
1001
			$query  = 'SELECT * FROM notam WHERE date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND fir = :fir ORDER BY date_begin DESC';
1002
		} else {
1003
			$query  = "SELECT * FROM notam WHERE fir = :fir AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' ORDER BY date_begin DESC";
1004
		}
1005
		$query_values = array(':fir' => $fir);
1006
		try {
1007
			$sth = $this->db->prepare($query);
1008
			$sth->execute($query_values);
1009
		} catch(PDOException $e) {
1010
			echo "error : ".$e->getMessage();
1011
			return array();
1012
		}
1013
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1014
		return $all;
1015
	}
1016
	public function getAllNOTAMtext() {
1017
		$query  = 'SELECT full_notam FROM notam';
1018
		$query_values = array();
1019
		try {
1020
			$sth = $this->db->prepare($query);
1021
			$sth->execute($query_values);
1022
		} catch(PDOException $e) {
1023
			echo "error : ".$e->getMessage();
1024
			return array();
1025
		}
1026
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1027
		return $all;
1028
	}
1029
	public function createNOTAMtextFile($filename) {
1030
		$allnotam_result = $this->getAllNOTAMtext();
1031
		$notamtext = '';
1032
		foreach($allnotam_result as $notam) {
1033
			$notamtext .= '%%'."\n";
1034
			$notamtext .= $notam['full_notam'];
1035
			$notamtext .= "\n".'%%'."\n";
1036
		}
1037
		file_put_contents($filename,$notamtext);
1038
	}
1039
	public function parseNOTAMtextFile($filename) {
1040
		$data = file_get_contents($filename);
1041
		preg_match_all("/%%(.+?)%%/is", $data, $matches);
1042
		if (isset($matches[1])) return $matches[1];
1043
		else return array();
1044
	}
1045
	public function getAllNOTAMbyScope($scope) {
1046
		global $globalDBdriver;
1047
		if ($globalDBdriver == 'mysql') {
1048
			$query  = 'SELECT * FROM notam WHERE radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
1049
		} else {
1050
			$query  = "SELECT * FROM notam WHERE radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND scope = :scope";
1051
		}
1052
		$query_values = array(':scope' => $scope);
1053
		try {
1054
			$sth = $this->db->prepare($query);
1055
			$sth->execute($query_values);
1056
		} catch(PDOException $e) {
1057
			echo "error : ".$e->getMessage();
1058
			return array();
1059
		}
1060
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1061
		return $all;
1062
	}
1063
	public function getAllNOTAMbyCoord($coord) {
1064
		global $globalDBdriver;
1065
		if (is_array($coord)) {
1066
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1067
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1068
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1069
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1070
			if ($minlat > $maxlat) {
1071
				$tmplat = $minlat;
1072
				$minlat = $maxlat;
1073
				$maxlat = $tmplat;
1074
			}
1075
			if ($minlong > $maxlong) {
1076
				$tmplong = $minlong;
1077
				$minlong = $maxlong;
1078
				$maxlong = $tmplong;
1079
			}
1080
		} else return array();
1081
		if ($globalDBdriver == 'mysql') {
1082
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()';
1083
		} else {
1084
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong." AND radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1085
		}
1086
		$query_values = array();
1087
		try {
1088
			$sth = $this->db->prepare($query);
1089
			$sth->execute($query_values);
1090
		} catch(PDOException $e) {
1091
			echo "error : ".$e->getMessage();
1092
			return array();
1093
		}
1094
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1095
		return $all;
1096
	}
1097
	public function getAllNOTAMbyCoordScope($coord,$scope) {
1098
		global $globalDBdriver;
1099
		if (is_array($coord)) {
1100
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1103
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1104
		} else return array();
1105
		if ($globalDBdriver == 'mysql') {
1106
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
1107
		} else {
1108
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong." AND radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND scope = :scope";
1109
		}
1110
		$query_values = array(':scope' => $scope);
1111
		try {
1112
			$sth = $this->db->prepare($query);
1113
			$sth->execute($query_values);
1114
		} catch(PDOException $e) {
1115
			echo "error : ".$e->getMessage();
1116
			return array();
1117
		}
1118
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1119
		return $all;
1120
	}
1121
	public function getNOTAMbyRef($ref) {
1122
		$query = "SELECT * FROM notam WHERE ref = :ref LIMIT 1";
1123
		$query_values = array('ref' => $ref);
1124
		try {
1125
			$sth = $this->db->prepare($query);
1126
			$sth->execute($query_values);
1127
		} catch(PDOException $e) {
1128
			return "error : ".$e->getMessage();
1129
		}
1130
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1131
		if (isset($all[0])) return $all[0];
1132
		else return array();
1133
	}
1134
1135
	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1136
		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1137
		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1138
		try {
1139
			$sth = $this->db->prepare($query);
1140
			$sth->execute($query_values);
1141
		} catch(PDOException $e) {
1142
			return "error : ".$e->getMessage();
1143
		}
1144
		return '';
1145
	}
1146
1147
	public function deleteNOTAM($id) {
1148
		$query = "DELETE FROM notam WHERE id = :id";
1149
		$query_values = array(':id' => $id);
1150
		try {
1151
			$sth = $this->db->prepare($query);
1152
			$sth->execute($query_values);
1153
		} catch(PDOException $e) {
1154
			return "error : ".$e->getMessage();
1155
		}
1156
		return '';
1157
	}
1158
	public function deleteOldNOTAM() {
1159
		global $globalDBdriver;
1160
		if ($globalDBdriver == 'mysql') {
1161
			$query = "DELETE FROM notam WHERE date_end < UTC_TIMESTAMP()";
1162
		} else {
1163
			$query = "DELETE FROM notam WHERE date_end < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1164
		}
1165
		$query_values = array();
1166
		try {
1167
			$sth = $this->db->prepare($query);
1168
			$sth->execute($query_values);
1169
		} catch(PDOException $e) {
1170
			return "error : ".$e->getMessage();
1171
		}
1172
		return '';
1173
	}
1174
	public function deleteNOTAMbyRef($ref) {
1175
		$query = "DELETE FROM notam WHERE ref = :ref";
1176
		$query_values = array(':ref' => $ref);
1177
		try {
1178
			$sth = $this->db->prepare($query);
1179
			$sth->execute($query_values);
1180
		} catch(PDOException $e) {
1181
			return "error : ".$e->getMessage();
1182
		}
1183
		return '';
1184
	}
1185
	public function deleteAllNOTAM() {
1186
		$query = "DELETE FROM notam";
1187
		try {
1188
			$sth = $this->db->prepare($query);
1189
			$sth->execute();
1190
		} catch(PDOException $e) {
1191
			return "error : ".$e->getMessage();
1192
		}
1193
		return '';
1194
	}
1195
	public function deleteAllNOTAMLocation() {
1196
		$query = "DELETE FROM notam";
1197
		try {
1198
			$sth = $this->db->prepare($query);
1199
			$sth->execute();
1200
		} catch(PDOException $e) {
1201
			return "error : ".$e->getMessage();
1202
		}
1203
		return '';
1204
	}
1205
1206
	public function updateNOTAM() {
1207
		global $globalNOTAMAirports;
1208
		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1209
			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1210
				$airport_icao = implode(',',$airport);
1211
				$alldata = $this->downloadNOTAM($airport_icao);
1212
				if (count($alldata) > 0) {
1213
					foreach ($alldata as $initial_data) {
1214
						$data = $this->parse($initial_data);
1215
						$notamref = $this->getNOTAMbyRef($data['ref']);
1216
						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1217
					}
1218
				}
1219
			}
1220
		}
1221
	}
1222
	public function updateNOTAMfromTextFile($filename) {
1223
		global $globalTransaction, $globalDebug;
1224
		$alldata = $this->parseNOTAMtextFile($filename);
1225
		if (count($alldata) > 0) {
1226
			$this->deleteOldNOTAM();
1227
			if ($globalTransaction) $this->db->beginTransaction();
1228
			$j = 0;
1229
			foreach ($alldata as $initial_data) {
1230
				$j++;
1231
				$data = $this->parse($initial_data);
1232
				$notamref = $this->getNOTAMbyRef($data['ref']);
1233
				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1234
				if ($globalTransaction && $j % 1000 == 0) {
1235
					$this->db->commit();
1236
					if ($globalDebug) echo '.';
1237
					$this->db->beginTransaction();
1238
				}
1239
			}
1240
			if ($globalTransaction) $this->db->commit();
1241
		}
1242
	}
1243
1244
	public function updateNOTAMallAirports() {
1245
		global $globalTransaction;
1246
		$Spotter = new Spotter($this->db);
1247
		$allairports = $Spotter->getAllAirportInfo();
1248
		foreach (array_chunk($allairports,20) as $airport) {
1249
			$airports_icao = array();
1250
			foreach($airport as $icao) {
1251
				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1252
			}
1253
			$airport_icao = implode(',',$airports_icao);
1254
			$alldata = $this->downloadNOTAM($airport_icao);
1255
			if ($globalTransaction) $this->db->beginTransaction();
1256
			if (count($alldata) > 0) {
1257
				foreach ($alldata as $initial_data) {
1258
					//print_r($initial_data);
1259
					$data = $this->parse($initial_data);
1260
					//print_r($data);
1261
					if (isset($data['ref'])) {
1262
						$notamref = $this->getNOTAMbyRef($data['ref']);
1263
						if (count($notamref) == 0) {
1264
							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1265
							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1266
							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1267
						}
1268
					}
1269
				}
1270
			} else echo 'Error on download. Nothing matches for '.$airport_icao."\n";
1271
			if ($globalTransaction) $this->db->commit();
1272
			sleep(5);
1273
		}
1274
	}
1275
1276
	public function downloadNOTAM($icao) {
1277
		date_default_timezone_set("UTC");
1278
		$Common = new Common();
1279
		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1280
		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1281
		$data = $Common->getData($url);
1282
		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1283
		//print_r($matches);
1284
		if (isset($matches[1])) return $matches[1];
1285
		else return array();
1286
	}
1287
1288
	public function parse($data) {
1289
		global $globalDebug;
1290
		$Common = new Common();
1291
		$result = array();
1292
		$result['full_notam'] = $data;
1293
		$result['text'] = '';
1294
		$result['permanent'] = '';
1295
		$result['date_begin'] = NULL;
1296
		$result['date_end'] = NULL;
1297
		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1298
		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1299
		$q = false;
1300
		$a = false;
1301
		$b = false;
1302
		$c = false;
1303
		$e = false;
1304
		foreach ($data as $line) {
1305
			$line = trim($line);
1306
			if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) {
1307
				$line = str_replace(' ','',$line);
1308
				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1309
				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1310
					$result['fir'] = $matches[1];
1311
					$result['code'] = $matches[2];
1312
					$result['title'] = $this->parse_code($result['code']);
1313
					$rules = str_split($matches[3]);
1314
					foreach ($rules as $rule) {
1315
						if ($rule == 'I') {
1316
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
1317
							else $result['rules'] = 'IFR';
1318
						} elseif ($rule == 'V') {
1319
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
1320
							else $result['rules'] = 'VFR';
1321
						} elseif ($rule == 'K') {
1322
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
1323
							else $result['rules'] = 'Checklist';
1324
						}
1325
					}
1326
					$attentions = str_split($matches[4]);
1327
					foreach ($attentions as $attention) {
1328
						if ($attention == 'N') {
1329
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
1330
							else $result['rules'] = 'Immediate attention';
1331
						} elseif ($attention == 'B') {
1332
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
1333
							else $result['rules'] = 'Operational significance';
1334
						} elseif ($attention == 'O') {
1335
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
1336
							else $result['rules'] = 'Flight operations';
1337
						} elseif ($attention == 'M') {
1338
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
1339
							else $result['rules'] = 'Misc';
1340
						} elseif ($attention == 'K') {
1341
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
1342
							else $result['rules'] = 'Checklist';
1343
						}
1344
					}
1345
					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
1346
					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
1347
					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
1348
					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
1349
					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
1350
					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1351
					$result['lower_limit'] = $matches[6];
1352
					$result['upper_limit'] = $matches[7];
1353
					$latitude = $Common->convertDec($matches[8],'latitude');
1354
					if ($matches[9] == 'S') $latitude = -$latitude;
1355
					$longitude = $Common->convertDec($matches[10],'longitude');
1356
					if ($matches[11] == 'W') $longitude = -$longitude;
1357
					$result['latitude'] = $latitude;
1358
					$result['longitude'] = $longitude;
1359
					if ($matches[12] != '') $result['radius'] = intval($matches[12]);
1360
					else $result['radius'] = 0;
1361
					$q = true;
1362
				} elseif ($globalDebug) {
1363
					echo 'NOTAM error : '.$result['full_notam']."\n";
1364
					echo "Can't parse : ".$line."\n";
1365
				}
1366
			}
1367
			elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) {
1368
				$result['icao'] = $matches[2];
1369
				$a = true;
1370
			}
1371
			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) {
1372
				if ($matches[1] > 50) $year = '19'.$matches[2];
1373
				else $year = '20'.$matches[2];
1374
				$result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1375
				$b = true;
1376
			}
1377
			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) {
1378
				if ($matches[2] > 50) $year = '19'.$matches[2];
1379
				else $year = '20'.$matches[2];
1380
				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1381
				$result['permanent'] = 0;
1382
				$c = true;
1383
			}
1384
			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) {
1385
				if ($matches[2] > 50) $year = '19'.$matches[2];
1386
				else $year = '20'.$matches[2];
1387
				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1388
				if ($matches[7] == 'EST') $result['estimated'] = 1;
1389
				else $result['estimated'] = 0;
1390
				if ($matches[7] == 'PERM') $result['permanent'] = 1;
1391
				else $result['permanent'] = 0;
1392
				$c = true;
1393
			}
1394
			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) {
1395
				$result['date_end'] = '2030/12/20 12:00';
1396
				if ($matches[2] == 'EST') $result['estimated'] = 1;
1397
				else $result['estimated'] = 0;
1398
				if ($matches[2] == 'PERM') $result['permanent'] = 1;
1399
				else $result['permanent'] = 0;
1400
				$c = true;
1401
			}
1402
			elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) {
1403
				$rtext = array();
1404
				$text = explode(' ',$matches[2]);
1405
				foreach ($text as $word) {
1406
					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1407
					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1408
					else $rtext[] = $word;
1409
				}
1410
				$result['text'] = implode(' ',$rtext);
1411
				$e = true;
1412
			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1413
			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1414
			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1415
				$text = explode(' ',$line);
1416
				$result['ref'] = $text[0];
1417
				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1418
				if ($matches[1] == 'NOTAMC') {
1419
					$result['type'] = 'cancel';
1420
					$result['ref_cancelled'] = $text[2];
1421
				}
1422
				if ($matches[1] == 'NOTAMR') {
1423
					$result['type'] = 'replace';
1424
					$result['ref_replaced'] = $text[2];
1425
				}
1426
			}
1427
		}
1428
		return $result;
1429
	}
1430
	
1431
	public function parse_code($code) {
1432
		$code = str_split($code);
1433
		$code_fp = $code[1].$code[2];
1434
		$code_sp = $code[3].$code[4];
1435
		$result = '';
1436
		switch ($code[1]) {
1437
			case 'A':
1438
				$result = 'Airspace organization ';
1439
				if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp];
1440
				break;
1441
			case 'C':
1442
				$result = 'Communications and radar facilities ';
1443
				if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp];
1444
				break;
1445
			case 'F':
1446
				$result = 'Facilities and services ';
1447
				if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp];
1448
				break;
1449
			case 'I':
1450
				$result = 'Instrument and Microwave Landing System ';
1451
				if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp];
1452
				break;
1453
			case 'L':
1454
				$result = 'Lighting facilities ';
1455
				if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp];
1456
				break;
1457
			case 'M':
1458
				$result = 'Movement and landing areas ';
1459
				if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp];
1460
				break;
1461
			case 'N':
1462
				$result = 'Terminal and En Route Navigation Facilities ';
1463
				if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp];
1464
				break;
1465
			case 'O':
1466
				$result = 'Other information ';
1467
				if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp];
1468
				break;
1469
			case 'P':
1470
				$result = 'Air Traffic procedures ';
1471
				if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp];
1472
				break;
1473
			case 'R':
1474
				$result = 'Navigation Warnings: Airspace Restrictions ';
1475
				if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp];
1476
				break;
1477
			case 'S':
1478
				$result = 'Air Traffic and VOLMET Services ';
1479
				if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp];
1480
				break;
1481
			case 'W':
1482
				$result = 'Navigation Warnings: Warnings ';
1483
				if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp];
1484
				break;
1485
		}
1486
		switch ($code[3]) {
1487
			case 'A':
1488
				// Availability
1489
				if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp];
1490
				break;
1491
			case 'C':
1492
				// Changes
1493
				if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp];
1494
				break;
1495
			case 'H':
1496
				// Hazardous conditions
1497
				if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp];
1498
				break;
1499
			case 'L':
1500
				// Limitations
1501
				if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp];
1502
				break;
1503
			case 'X':
1504
				// Other Information
1505
				break;
1506
		}
1507
		return trim($result);
1508
	}
1509
}
1510
/*
1511
$NOTAM = new NOTAM();
1512
//print_r($NOTAM->downloadNOTAM('lfll'));
1513
//print_r($NOTAM->parse(''));
1514
//$NOTAM->deleteAllNOTAM();
1515
//$NOTAM->updateNOTAMallAirports();
1516
//echo $NOTAM->parse_code('QFATT');
1517
//$NOTAM->createNOTAMtextFile('../install/tmp/notam.txt');
1518
$NOTAM->updateNOTAMfromTextFile('../install/tmp/notam.txt');
1519
*/
1520
1521
?>