aviation-model
Version:
Public methods for querying the information from aviation-pg
271 lines (195 loc) • 9.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Documentation Index</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
<script src="https://use.fontawesome.com/e18d549689.js"></script>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Documentation</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="global.html#airportsBounds">airportsBounds</a></li><li><a href="global.html#getAirlineCities">getAirlineCities</a></li><li><a href="global.html#getAirlineData">getAirlineData</a></li><li><a href="global.html#getAirportData">getAirportData</a></li><li><a href="global.html#getAirportJson">getAirportJson</a></li><li><a href="global.html#getCity">getCity</a></li><li><a href="global.html#getDestinations">getDestinations</a></li><li><a href="global.html#queryData">queryData</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
<div id="code-links">
<a href="https://github.com/cristobal-io/aviation-model" class="code-logo-link"><i class="fa fa-github fa-2x" aria-hidden="true"></i></a><a href="https://www.npmjs.com/package/aviation-model" class="code-logo-link"><a href="https://www.npmjs.com/package/aviation-model" class="code-logo-link"><svg class="code-svg" viewBox="0 0 18 7"><path fill="red" d="M0,0v6h5v1h4v-1h9v-6"/><path fill="#FFF" d="M1,1v4h2v-3h1v3h1v-4h1v5h2v-4h1v2h-1v1h2v-4h1v4h2v-3h1v3h1v-3h1v3h1v-4"/></svg></a>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<section class="readme-section">
<article><h1>Models</h1><p>This package exposes public methods to retrieve information from the PostgreSQL database created at the aviation-pg module.</p>
<h2>Configuration.</h2><p>The following environment variables are required to configure the connection to the database.</p>
<pre class="prettyprint source"><code>PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=aviation
PG_USER=aviator
PG_PASSWORD=null</code></pre><p>while developing you can also create a <code>./database.json</code> with the following details:</p>
<pre class="prettyprint source lang-json"><code>{
"host": "localhost",
"port": 5432,
"database": "aviation",
"user": "aviator",
"password": null
}</code></pre><h2>Usage</h2><p>Install via npm with <code>npm install aviation-model</code> </p>
<blockquote>
<p>If you haven't created the database with the <a href="https://github.com/cristobal-io/aviation-pg">aviation-pg</a>, the following won't work.</p>
</blockquote>
<h3>Methods available.</h3><ul>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getAirlineCities__anchor">getAirlineCities</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getAirlineData__anchor">getAirlineData</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getAirportData__anchor">getAirportData</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getAirportJson__anchor">getAirportJson</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getCity__anchor">getCity</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#getDestinations__anchor">getDestinations</a></li>
<li><a href="http://cristobal-io.github.io/aviation-model/global.html#queryData__anchor">queryData</a> (airportData, airlineDestinations, airportRunways, citiesByAirline, radiusAirports, airlines)</li>
</ul>
<p>Next you have a quick example.</p>
<p>Include the module at your code:</p>
<pre class="prettyprint source lang-javascript"><code>var aviationModel = require("aviation-model");</code></pre><p>Then use as explained in detail at the docs the different methods, a quick example:</p>
<pre class="prettyprint source lang-javascript"><code>aviationModel.getAirportJson({
airport_id: "San_Francisco_International_Airport"
}, function (err, airport) {
if (err) {
throw err;
}
console.log("Airport: ",airport);
});
// This will print out:
Airport: { location: '37°37′08″N 122°22′30″W',
airport_id: 'San_Francisco_International_Airport',
latitude: '37°37′08″N',
longitude: '122°22′30″W',
name: 'San Francisco International Airport',
nickname: 'SFO',
iata: 'SFO',
icao: 'KSFO' }</code></pre><h2>Testing</h2><p>Run the command <code>make test</code>, this will check with ESLint the code and run the tests, if the <code>database.json</code> file is not located, it will return an error.</p>
<p>The default <code>make</code> command will do the npm install, update the database formulas with the one needed and will run the tests.</p>
<h2>Contributions:</h2><p>If you want to contribute, create your branch and place a PR or open an issue.</p></article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
on 2016-11-03T09:51:48+01:00
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : false,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
var id = $( heading ).attr( "id" );
return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>