-
airportsBounds(options, callback)
-
with this function we retrieve all the airports located inside a bound box.
Parameters:
| Name |
Type |
Description |
options |
Object
|
pass all the values to use on the query.
Properties
| Name |
Type |
Description |
latitude1 |
String
|
latitude of the first point |
longitude1 |
String
|
longitude of the first point |
latitude2 |
String
|
latitude of the first point |
longitude2 |
String
|
longitude of the first point |
|
callback |
function
|
|
Returns:
returns an array with the data requested.
-
Type
-
Array
Example
aviationModel.airportsBounds({
latitude1: 38,
longitude1: -123,
latitude2: 37,
longitude2: -122
}, function (err, boxAirports) {
if (err) {throw err;}
console.log(boxAirports);
});
// returns the following array
[ { airport_id: 'Buchanan_Field_Airport',
latitude: '37°59′23″N',
longitude: '122°03′25″W',
name: 'Buchanan International\nConcord Army Air Base',
nickname: 'CCR',
iata: 'CCR',
icao: 'KCCR',
dd_latitude: 37.98972222222222,
dd_longitude: -122.05694444444444 },
{ airport_id: 'Half_Moon_Bay_Airport',
latitude: '37°30′48″N',
longitude: '122°30′04″W',
name: 'Eddie Andreini Sr. Airfield\nHalf Moon Bay Airport',
nickname: 'HAF',
iata: 'HAF',
icao: 'KHAF',
dd_latitude: 37.513333333333335,
dd_longitude: -122.50111111111111 },
{ airport_id: 'Hayward_Executive_Airport',
latitude: '37°39′32″N',
longitude: '122°07′18″W',
name: 'Hayward Executive Airport',
nickname: '(former Hayward Army Air Field)',
iata: 'HWD',
icao: 'KHWD',
dd_latitude: 37.65888888888889,
dd_longitude: -122.12166666666666 },
{ airport_id: 'Moffett_Federal_Airfield',
latitude: '37°24′54″N',
longitude: '122°02′54″W',
name: 'Moffett Federal Airfield',
nickname: 'NUQ',
iata: 'NUQ',
icao: 'KNUQ',
dd_latitude: 37.415,
dd_longitude: -122.04833333333333 },
{ airport_id: 'Oakland_International_Airport',
latitude: '37°43′17″N',
longitude: '122°13′15″W',
name: 'Oakland International Airport',
nickname: 'OAK',
iata: 'OAK',
icao: 'KOAK',
dd_latitude: 37.72138888888889,
dd_longitude: -122.22083333333333 },
{ airport_id: 'Palo_Alto_Airport',
latitude: '37°27′40″N',
longitude: '122°06′54″W',
name: 'Palo Alto Airport',
nickname: 'PAO',
iata: 'PAO',
icao: 'KPAO',
dd_latitude: 37.461111111111116,
dd_longitude: -122.115 },
{ 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',
dd_latitude: 37.61888888888889,
dd_longitude: -122.375 },
{ airport_id: 'San_Carlos_Airport_(California)',
latitude: '37°30′43″N',
longitude: '122°14′58″W',
name: 'San Carlos Airport',
nickname: 'SQL',
iata: 'SQL',
icao: 'KSQL',
dd_latitude: 37.511944444444445,
dd_longitude: -122.24944444444445 } ]
-
getAirlineCities(airline, callback)
-
This method returns the cities of all the airports that an airline is flying to.
Parameters:
| Name |
Type |
Description |
airline |
String
|
airline_id value we want to search, we can use wildcard % |
callback |
function
|
|
Returns:
All the cities.
-
Type
-
Array
Example
aviationModel.getAirlineCities("American_Airlines", function(err, cities) {
if (err) {throw err; }
console.log(cities);
});
// this returns the following array:
[
'St._John%27s,_Antigua_and_Barbuda',
'Buenos_Aires',
'Oranjestad,_Aruba',
'Sydney',
'Nassau,_Bahamas',
'Bridgetown,_Barbados',
'Belize_City',
'Brussels',
'Hamilton,_Bermuda',
'La_Paz',
// this continues to complete all the cities.
]
-
getAirlineData(options, callback)
-
Gets data for a single airline
Parameters:
| Name |
Type |
Description |
options |
Object
|
Contains all the options.
Properties
| Name |
Type |
Description |
type |
String
|
name | logo_url | iata | icao | callsign | website |
value |
String
|
the value according to the type specified. |
method |
String
|
name | logo_url | iata | icao | callsign | website
Optional we can leave the method empty to get all the information from the airline. |
verbose |
boolean
|
specify if you want to have logging. |
|
callback |
function
|
|
Returns:
returns the information requested.
-
Type
-
string
Example
aviationModel.getAirlineData({
value: "American_Airlines",
type: "airline_id",
method: "website"
}, function (err, data) {
if (err) {throw err;}
console.log("Web: ", data);
});
// This will print out:
// Web: http://www.aa.com
-
getAirportData(options, callback)
-
Gets data for a single airport.
Parameters:
| Name |
Type |
Description |
options |
Object
|
Properties
| Name |
Type |
Argument |
Description |
type |
String
|
|
airport_id | name | latitude | longitude | nickname | iata | icao |
value |
String
|
|
the value according to the type specified. |
method |
String
|
<optional>
|
airport_id | name | location | latitude | longitude | nickname | iata | icao
(if we don't specify the method, the whole airport data will be served). |
verbose |
boolean
|
|
specify if you want to have logging. |
|
callback |
function
|
|
Returns:
requested information.
-
Type
-
string
Example
aviationModel.getAirportData({
value: "SFO",
type: "iata",
method: "latitude"
}, function (err, data) {
if (err) {throw err;}
console.log(data);
});
// returns:
// "37°37′08″N
-
getAirportJson(searchOptions, callback)
-
This function retrieves all the information of an airport in a JSON format.
Parameters:
| Name |
Type |
Description |
searchOptions |
Object
|
key and value (string) to find. |
callback |
function
|
|
Returns:
JSON data of the airport requested.
-
Type
-
object
Example
aviationModel.getAirportJson({
airport_id: "San_Francisco_International_Airport"
}, function (err, airport) {
if (err) {
throw err;
}
console.log("Airport:", airport);
});
// this logs the following JSON object.
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' }
-
getCity(airport, callback)
-
Finds the city for the specific airport
Parameters:
| Name |
Type |
Description |
airport |
String
|
Exact airport_id |
callback |
function
|
|
Returns:
The name of the city where the airport is located.
-
Type
-
String
Example
aviationModel.getCity("San_Francisco_International_Airport", function(err, city) {
if (err) {throw err;}
console.log("city: ", city);
});
// This will return the following:
// city: San_Francisco
-
getDestinations(airline, callback)
-
It performs a search at the db and returns all the destinations of the
airline or airlines that match the string.
Parameters:
| Name |
Type |
Description |
airline |
String
|
the airline_id we want to look for, use wildcard % |
callback |
function
|
|
Returns:
array composed with objects that include airline_id and airport_id
-
Type
-
Array
Example
aviationModel.getDestinations("American_Airlines", function (err, destinations) {
if (err) {throw err;}
console.log(JSON.stringify(destinations, null, 2));
});
// this will return the following array:
[
{
"airline_id": "American_Airlines",
"airport_id": "V._C._Bird_International_Airport"
},
{
"airline_id": "American_Airlines",
"airport_id": "Ministro_Pistarini_International_Airport"
},
{
"airline_id": "American_Airlines",
"airport_id": "Queen_Beatrix_International_Airport"
},
{
"airline_id": "American_Airlines",
"airport_id": "Sydney_Airport"
},
{
"airline_id": "American_Airlines",
"airport_id": "Lynden_Pindling_International_Airport"
},
// continue until complete the total destinations...
]
-
queryData(options, query, callback)
-
formula to use all the queries stored at ./sql/queries/
Parameters:
| Name |
Type |
Description |
options |
Object
|
pass all the values to use on the query.
Properties
| Name |
Type |
Description |
searchString |
String
|
text to use on the query. |
distance |
String
|
distance in meters to look for formulas using radius. |
|
query |
String
|
specified the name of the query you are going to use.
Properties
| Name |
Type |
Description |
airlines |
String
|
airline_id of the airline (wildcard %) |
airlineDestinations |
String
|
id of the airline (1 airline) (wildcard %)
will return the airports with complete data. |
citiesByAirline |
String
|
Name of the airline (wildcard %) |
airportData |
String
|
This query accepts the name (wildcard %) |
airportRunways |
String
|
Name of the airport (wildcard %) |
radiusAirports |
String
|
airport_id (wildcard %) and the distance of the radius in meters. |
airlinesByAirport |
String
|
airport_id (wildcard %) |
|
callback |
function
|
|
Returns:
returns an array with the data requested.
-
Type
-
Array
Examples
aviationModel.queryData({
searchString: "San_Francisco%",
distance: 100 * 1000
}, "radiusAirports", function (err, radiusAirports) {
if (err) {throw err;}
console.log(radiusAirports);
});
// This will return the following array:
[
{ airport_id: 'San_Francisco_International_Airport',
name: 'San Francisco International Airport',
latitude: '37°37′08″N',
longitude: '122°22′30″W',
distance: 0 },
{ airport_id: 'Half_Moon_Bay_Airport',
name: 'Eddie Andreini Sr. Airfield\nHalf Moon Bay Airport',
latitude: '37°30′48″N',
longitude: '122°30′04″W',
distance: 16183.33 },
{ airport_id: 'San_Carlos_Airport_(California)',
name: 'San Carlos Airport',
latitude: '37°30′43″N',
longitude: '122°14′58″W',
distance: 16262.58 },
{ airport_id: 'Oakland_International_Airport',
name: 'Oakland International Airport',
latitude: '37°43′17″N',
longitude: '122°13′15″W',
distance: 17740.59 },
{ airport_id: 'Hayward_Executive_Airport',
name: 'Hayward Executive Airport',
latitude: '37°39′32″N',
longitude: '122°07′18″W',
distance: 22771.33 },
// this continues to complete all the airports in the radius.
]
aviationModel.queryData({
searchString: "Vueling%"
}, "airlineDestinations" , function (err, destinations) {
if (err) {throw err;}
console.log(destinations);
});
// This will return the following array:
[
{
"airline_id": "Vueling",
"airport_id": "Pulkovo_Airport",
"latitude": "59°48′01″N",
"longitude": "30°15′45″E",
"name": "Pulkovo Airport",
"nickname": "Аэропорт Пулково",
"iata": "LED",
"icao": "ULLI",
"dd_latitude": 59.80027777777777,
"dd_longitude": 30.2625
},
{
"airline_id": "Vueling",
"airport_id": "Belgrade_Nikola_Tesla_Airport",
"latitude": "44°49′10″N",
"longitude": "20°18′25″E",
"name": "Belgrade Nikola Tesla AirportAerodrom Nikola Tesla a.d.",
"nickname": "Аеродром Никола Тесла Београд",
"iata": "BEG",
"icao": "LYBE",
"dd_latitude": 44.81944444444445,
"dd_longitude": 20.306944444444444
},
{
"airline_id": "Vueling",
"airport_id": "Houari_Boumediene_Airport",
"latitude": "36°41′27.65″N",
"longitude": "003°12′55.47″E",
"name": "Houari Boumediene AirportHouari Boumediene AirportHouari Boumediene Airport",
"nickname": "مطار هواري بومدين الدولي",
"iata": "ALG",
"icao": "DAAG",
"dd_latitude": 36.69101388888888,
"dd_longitude": 3.2154083333333334
},
// this continues to complete all the destinations.
]