Jump to content

[Module Request] AirCharts.org charts in Briefing page. (API Available)


ShrikarG

Recommended Posts

Hello ,

As all of us must be knowing , the default briefing doesn't retrieve charts out of USA ARTCCs.

I have found a website called "AirCharts.org" with an open free API that lists all charts according to ICAO worldwide.

Unfortunately , I don't have much PHP knowledge. If someone could code this , it would be a great help to all virtual airlines all over the world.

API
AirCharts' new, open API is now available for public use. Use of the API is in accordance with the API Agreement.
Usage:
Airport Information and Charts: http://api.aircharts.org/Airport/(ICAO).(format)
List of Airports and Charts: http://api.aircharts.org/Airport/(ICAO),(ICAO),(ICAO).(format) [up to 15]
Available formats: JSON (default), XML.
Examples:
http://api.aircharts.org/Airport/KNPA.json
http://api.aircharts.org/Airport/KPNS,KNPA,KNDZ,KNSE,KJKA.json
http://api.aircharts.org/Airport/KNPA,KPNS,KNDZ,KNSE,KJKA.xml

Link to comment
Share on other sites

EDIT: Original text

For now, you can just put this in a module called

core/modules/Aircharts/Aircharts.php

<?php
class Aircharts extends CodonModule {
public $title = 'Aircharts';
public function index() {

}

public function getCharts($icao = '') {
$icao = DB::escape($icao);
$responsetype = '.json'; // Change this to .XML if you really want
$apiurl = 'http://api.aircharts.org/Airport/'.$icao.$responsetype;
$obj = json_decode(file_get_contents($apiurl), true);
foreach($obj as $o) {
echo '<strong>Charts for '.$icao.'</strong>';
echo '<br />';
foreach($o['charts'] as $c) {
echo $c['name'].' - <a href="'.$c['url'].'" target="_blank">Link Here</a>';
echo '<br />';
}
}
}
}

And then in your url go to http://yourvaurl.com.../getCharts/KJFK and it should output the charts (change KJFK to any ICAO).

EDIT:: I saw you wanted to show this in your schedule briefing, for starters (without a template made), you can just replace this

<tr style="background-color: #333; color: #FFF;">
<td>Charts for <?php echo $schedule->depicao?></td>
<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
<td width="50%" valign="top">
<a href="http://www.airnav.com/airport/<?php echo $schedule->depicao?>#ifr" target="_blank">
<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->depicao?>/APD/AIRPORT+DIAGRAM/png"
width="387px" height="594px" alt="No chart available" /></a>
</td>
<td width="50%" valign="top">
<a href="http://www.airnav.com/airport/<?php echo $schedule->arricao?>#ifr" target="_blank">
<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->arricao?>/APD/AIRPORT+DIAGRAM/png"
width="387px" height="594px" alt="No chart available" /></a>
</td>

</tr>

With this

<tr style="background-color: #333; color: #FFF;">
<td>Charts for <?php echo $schedule->depicao?></td>
<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
<td width="50%" valign="top">
<?php MainController::Run('Aircharts', 'getCharts', $schedule->depicao); ?>
</td>
<td width="50%" valign="top">
<?php MainController::Run('Aircharts', 'getCharts', $schedule->arricao); ?>
</td>

</tr>

And it will show all charts found in a list

EDIT: I have uploaded the complete module now onto github https://github.com/w...AirchartsModule

Make sure you are familiar with the aircharts license agreement then follow the instructions to install

Edited by web541
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • Administrators

This module was working perfectly a week or two ago. Today I am getting the following errors when attempting to access an airport that AirCharts supplies charts for.

Warning: file_get_contents(): Peer certificate CN=`nameitcreateit.com' did not match expected CN=`api.aircharts.org' in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Warning: file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Warning: file_get_contents(http://api.aircharts.org/Airport/KLAS.json): failed to open stream: operation failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Line 40 reads:

		$obj = json_decode(file_get_contents($apiurl), true);

It looks like the AirCharts site has the ability to use 'https' instead of 'http'. I tried changing the 'http' entries to 'https' in .../modules/Aircharts/Aircharts.php and received the same error.

Also, looks like version 2 of the API was released (https://api.aircharts.org/). I tried changing the 3 $apiurl lines (17, 28, 39) in Aircharts.php to reflect this change and continued to receive the same error.

The only item on my site that changed is we added SSL (https). But after getting that all set up, everything (including AirCharts) worked fine - until today.

Any help is much appreciated.

Link to comment
Share on other sites

  • Administrators

Also just noticed in Error_log a bunch of similar errors starting on 12/17/2017.

[22-Dec-2017 10:17:37 America/Los_Angeles] PHP Warning:  file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18
[22-Dec-2017 10:17:37 America/Los_Angeles] PHP Warning:  file_get_contents(http://api.aircharts.org/Airport/KASE.json): failed to open stream: operation failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18
[22-Dec-2017 10:17:38 America/Los_Angeles] PHP Warning:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18
[22-Dec-2017 10:17:38 America/Los_Angeles] PHP Warning:  file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18

[22-Dec-2017 10:17:38 America/Los_Angeles] PHP Warning:  file_get_contents(http://api.aircharts.org/Airport/KDEN.json): failed to open stream: operation failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18
[22-Dec-2017 10:27:42 America/Los_Angeles] PHP Warning:  file_get_contents(): Peer certificate CN=`nameitcreateit.com' did not match expected CN=`api.aircharts.org' in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18
[22-Dec-2017 10:27:42 America/Los_Angeles] PHP Warning:  file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18

The first 4 occur from 12/17 to the date/time shown. The later 3 show from that date/time to present.

Link to comment
Share on other sites

6 hours ago, ProAvia said:

This module was working perfectly a week or two ago. Today I am getting the following errors when attempting to access an airport that AirCharts supplies charts for.


Warning: file_get_contents(): Peer certificate CN=`nameitcreateit.com' did not match expected CN=`api.aircharts.org' in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Warning: file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Warning: file_get_contents(http://api.aircharts.org/Airport/KLAS.json): failed to open stream: operation failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Line 40 reads:


		$obj = json_decode(file_get_contents($apiurl), true);

It looks like the AirCharts site has the ability to use 'https' instead of 'http'. I tried changing the 'http' entries to 'https' in .../modules/Aircharts/Aircharts.php and received the same error.

Also, looks like version 2 of the API was released (https://api.aircharts.org/). I tried changing the 3 $apiurl lines (17, 28, 39) in Aircharts.php to reflect this change and continued to receive the same error.

The only item on my site that changed is we added SSL (https). But after getting that all set up, everything (including AirCharts) worked fine - until today.

Any help is much appreciated.

Go to the github link above and re-download the module, I have updated it to the API Version 2 and also have a workaround for the SSL Issue (temporary). It should work now.

Edited by web541
  • Like 1
Link to comment
Share on other sites

  • Administrators
19 hours ago, web541 said:

Go to the github link above and re-download the module, I have updated it to the API Version 2 and also have a workaround for the SSL Issue (temporary). It should work now.

Thank you - works great!

My basic understanding of the temporary SSL workaround is that it bypasses the SSL check - is that correct?

Link to comment
Share on other sites

17 hours ago, thefiercepilot said:

I'm getting this on requesting for non-US charts:


Warning: Invalid argument supplied for foreach() in /storage/ssd3/285/3946285/public_html/core/templates/aircharts/aircharts_chartslist.php on line 49

US charts work fine

Can you give me an ICAO that does this, their supported airports are listed here https://www.aircharts.org/

 

4 minutes ago, ProAvia said:

Thank you - works great!

My basic understanding of the temporary SSL workaround is that it bypasses the SSL check - is that correct?

Yes it bypasses SSL verification only for the charts, haven't figured out a way to use file_get_contents with SSL correctly (cURL could work). This is something I've never seen before. It's possible that their API doesn't support secure connections as of yet (hence why it says "Your connection is not private" when visiting their API)

  • Like 1
Link to comment
Share on other sites

17 hours ago, thefiercepilot said:

I'm getting this on requesting for non-US charts:


Warning: Invalid argument supplied for foreach() in /storage/ssd3/285/3946285/public_html/core/templates/aircharts/aircharts_chartslist.php on line 49

US charts work fine

Actually, redownload the module, I've fixed this now.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...