The airport database contains airport and runway information. It is built into the app but can be updated via the Internet. The arpt page controls the airport database and is responsible for loading and updating the database.
Individual airport information is accessed using an instance of the Airport class. An Airport instance contains information about the airport itself, such as ID codes, location, elevation, and information about each usable runway, such as ID, width, TORA, LDA, slope, and surface type. Runways not usable for this aircraft type are deleted from the database. For example, runways that are too short or of an unsupported surface type (e.g., water). Airports that don't have any usable runways are deleted from the database.
Airports can have several identification codes. For example, they can have normal 4-letter codes where the first letter identifies a region (e.g., KSFO), 3-letter IATA codes (e.g., SFO), regional codes (e.g., O22), or informal codes (e.g., GB-0002). Some codes in different regions can conflict. In that case, the code for the smaller airport is removed from the database. If all of an airport's codes are eliminated, the airport is deleted from the database.
Runway surfaces are quite varied. Since performance is the only issue, not weight-bearing, the surfaces are classified into the following categories:
'hard''turf''dirt''gravel''water'Different models and options combinations can have different surface requirements. For example, an aircraft with floats installed will want to use water runways, but models without will not. The type-wide data can set the validRunwaySurfaces property with an array of valid surface codes, and individual models or options can override this list. Runways not on the validRunwaySurfaces are not considered when setting up the usable runway options.
The airport database relies on two sources:
source/airportData/NFDC. You may choose the current data or the preview that will be made current at the next database cycle.The airport database source/app/${app}/airportData.json is a JSON-encoded object with the following properties:
versiontimestampminRunwayLengthairportFieldscodeslatitudelongitudeelevationrunwaysrunwayFields property.runwayFieldsairportsairportFields array.The airport database itself is built by the buildAirportDB.js nodeJS script. The script outputs the airport database as a JSON-encoded object. The script takes the following flags:
source/airportData/dbFlags/${app}.txt.To build the database first manually download the APT.txt file for the current or next version of the NFDC airport database to source/airportData/NFDC. After that run make -B db, which does the following:
buildAirportDB.js with the flags in source/airportData/dbFlags/${app}.txt and outputs the result to source/app/${app}/airportData.json.source/app/${app}/airportDataTimestamp.json which contains a JSON-encoded object with two properties:versiontimestampsource/app/${app}/airportData.json prepended with:export const airportData =
to source/app/${app}/buildStamp/data/airportData.js. This file is loaded by commonaero/airport.js to access the built-in database by importing airportData.
The app may have a dynamically updated database in addition to the built-in database. When the app starts up or is resumed after a prolonged period of inactivity (>1 day), the app fetches the airportDataTimestamp.json file from the origin server. It compares the timestamp in the JSON-encoded object to the timestamp field in the current database. If it's different, then the app fetches airportData.json. The update is stored in the device's local Object storage under the key 'airportDb'. The updated database is then used in place of the built-in database.
Airport instanceThe Airport constructor takes an airport code, airportId, as an argument. The instance contains properties and methods for accessing and using the airport data. The airport can be changed subsequently by calling the setAirport() method.
The Airport instance contains the following properties:
airportIdcodeselevationhasDataairportId found data in the database.latitudelongitudemagVarmagVarRrunwayIdsrunwaysidldamagDirslopesurfacetoratrueDirIf the database does not contain data associated with airportId, then the instance provides default airport information with no runways and hasData will be false.
Some Airport instance methods work with other pages containing airport information and compute takeoff and landing performance (e.g., the Departure or Destination pages). The methods have a pageId argument for pages containing these common airport state variables:
${pageId}_airportCode${pageId}_airportId${pageId}_airportMsg${pageId}_bestRunwayId${pageId}_crosswind${pageId}_crosswindDir${pageId}_crosswindMsg${pageId}_elevation_ft${pageId}_hasAirportData${pageId}_headwind${pageId}_magVar${pageId}_obstacle_ft${pageId}_roll_ft${pageId}_rollAdjustment${pageId}_runwayConditiondry, wet, or icy.${pageId}_runwayId${pageId}_runwayLeft_ft${pageId}_runwayLeftMsg${pageId}_runwayLength_ft${pageId}_runwayMagDir${pageId}_runwayObstacleDist_ft${pageId}_runwaySlope${pageId}_runwaySurface${pageId}_runwaysText${pageId}_runwayWidth_ft${pageId}_safeObstacle_ft${pageId}_safeRunwayLength_ft${pageId}_selRunway${pageId}_userRollAdjustment${pageId}_windDir${pageId}_windDirIn addition, Airport instances also require the following state variables:
set_tkoSafetyFactorset_ldgSafetyFactorset_obsSafetyFactorset_noHeadwindThe setPageAirportInfo() method sets the specified pageId state variables based on the information in the Airport instance. It sets the airport elevation, magnetic variance, runway options, and the selected runway's length, width, slope, and surface.
The setPageRunwayPerformance() method computes the performance of all usable runways, picks the best, and then sets the results for the selected runway (the best or a specific runway from ${pageId}_selRunway) in the pageId state variables. The setPageRunwayPerformance() is passed a distanceFn argument containing an aircraft-specific function to compute the ground roll and obstacle clearance distance for each runway.
The POH typically does not specify performance under all conditions. For example, it often fails to provide adjustments for wet runways or runway slope. The app can allow the user to specify a set of standard ground roll adjustments based on runway surface and condition. The standard adjustments are for hard, wet runways, icy or snow-covered runways, unpaved runways, or runway slope. In some cases, the standard adjustments need adjusting. For example, for longer grass or soft conditions on a turf runway.
The distanceFn also computes a rollSurfaceFactor that contains the non-POH adjustment factor to the POH-derived roll. The setPageRunwayPerformance() method sets the ${pageId}_rollAdjustment output state variable to let the user know the non-POH adjustment used in the calculations. The user can add an additional factor for actual conditions (e.g. long grass or a soft field) by setting the ${pageId}_userRollAdjustment input state variable. The different is roll due to this factor is computed and added to the published ground roll, obstacle clearance, and safe distances.
The computation includes the "safe" runway distances. The ground roll and obstacle clearance distances are based on a safety factor in the set_tkoSafetyFactor or set_ldgSafetyFactor state variables. However, the minimum safe runway can be no less than the no-headwind obstacle clearance distance. This is to provide the required height above the DER or AER for IFR procedures. In addition, the runway is not safe the crosswind exceeds the maximum crosswind published in the POH.
The best runway is selected after the performance of all usable runways is computed. The selection is based on the following criteria in order of priority:
The best runway calculation is unaffected by the value in the ${pageId}_userRollAdjustment state variable. It only applies to the published values for the selected or best runway.
new Airport(airportId)
The constructor uses the setAirport() method to retrieve the information for airportId from the database and set the instance properties.
airportIdsetAirport()setAirport(airportId)
This method sets the airport ID for the Airport instance to airportId and retrieves the airport information from the database. If acData.validRunwaySurfaces is present, then runway surfaces not included in the acData.validRunwaySurfaces array will not appear in the instance's runway list.
airportIdrunwayOptions()runwayOptions()
Returns an array of options given an array of runway ID strings. If the airport has no data or the ID is null, it returns an array containing all IDs from 01 to 36.
This method is used to set the runway ID options in the ${pageId}_selRunway state variable.
An array of runway ID strings.
setPageAirportInfo()setPageAirportInfo(pageId)
This method sets the airport-related state variables according to the instance properties. The affected state variables are:
${pageId}_airportCode${pageId}_airportMsg${pageId}_elevation_ft${pageId}_hasAirportData${pageId}_magVar${pageId}_runwaySlope${pageId}_runwaysText${pageId}_selRunway${pageId}_windDirmagVar property so that the wind direction can be converted between magnetic north and true north as required.pageIdsetPageRunwayPerformance()setPageRunwayPerformance(pageId, conditions, distanceFn)
This method computes the performance of all usable runways for the conditions, picks the best, and then sets the results for the selected runway (the best or a specific runway from ${pageId}_selRunway) in the pageId state variables.
conditions is an OutsideConditions instance representing the current OAT and other weather conditions. distanceFn is function that takes an OutsideConditions instance as an argument. The instance also contains the following properties:
runwayConditiondry, wet, icy.runwaySloperunwaySurfacehard, turf, dirt, gravel, water.headwindcrosswinddistanceFn() returns an object containing the following properties:rollobstacleThe method clones the conditions instance and then iterates over all the usable runways, doing the following:
headwind and crosswind properties in the cloned conditions instance to the headwind and crosswind for that runway.runwaySlope, runwaySurface, and runwayCondition properties in the cloned conditions instance to the runway slope, surface category, and surface condition (dry, wet, or icy).distanceFn function with the cloned conditions instance with the added information as an argument. The function returns an object containing the computed performance results for that runway and conditions.distanceFn function again with the cloned conditions instance with any headwind set to zero as an argument. Tailwinds are not set to 0.distanceFn(), it computes the "safe" runway length and includes the ground roll safety factors.The ${pageId}_selRunway state variable can have a value of "Best", in which case the performance from the best runway is set in the page's state variables. If the value of ${pageId}_selRunway is a specific runway, then the computed data from the selected runway is set. In either case, the value of ${pageId}_bestRunwayId is set to the selected best runway. The selected runway's performance is then adjusted by the difference in ground roll due to the setting of the ${pageId}_userRollAdjustment state variable.
The selected runway's performance is set into the following state variables:
${pageId}_crosswind${pageId}_crosswindDir${pageId}_crosswindMsg${pageId}_headwind${pageId}_obstacle_ft${pageId}_roll_ft${pageId}_rollAdjustment${pageId}_runwayId${pageId}_runwayLeft_ft${pageId}_runwayLeftMsg${pageId}_runwayLength_ft${pageId}_runwayMagDir${pageId}_runwayObstacleDist_ft${pageId}_runwaySlope${pageId}_runwaySurface${pageId}_runwaysText${pageId}_runwayWidth_ft${pageId}_safeObstacle_ft${pageId}_safeRunwayLength_ftpageIdAirport.checkDbUpdate()Airport.checkDbUpdate(airportId)
Initiates a check for an airport DB update. If there's an update, it will fetch it and update the internal airport database.
Airport.drawRunway()Airport.drawRunway(canvas, pageId)
Draws a runway diagram with relative headwind and crosswind shown. It also shows the ground roll and safe runway distances as colored zones on the runway surface.
The pageId is that page ID to get the standard runway performance state variables to use to create the diagram.
canvas<canvas> element to draw the diagram on.pageIdAirport.fetchDbUpdate()Airport.fetchDbUpdate()
Returns a Promise that resolves when the updated database has been fetched and the results have been successfully stored in local object storage. See Airport database updates and Object storage.
A Promise.
Airport.findAll()Airport.findAll(airportId, radius)
Find all airports within radius (in nm) of airportId. Returns an array of airport ID strings sorted in order of distance.
airportIdradiusairportId to search for airports.An array of airport ID strings sorted in order of distance. If no airports are found or if airportId is not in the database, and empty array is returned.
Airport.hasData()Airport.hasData(airportId)
Returns true if there's data associated with airportId in the database.
airportIdA boolean.
Airport.hasDbUpdate()Airport.hasDbUpdate()
Return a Promise that resolves with a boolean that's true if the server has an updated database. The method fetched only the small timestamp file, not the large database file. See Airport database updates.
A Promise.
Airport.lookup()Airport.lookup(airportId)
Lookup an airport ID in the airport database. Returns an object with properties set according to the field names and values in the database. See Airport database structure.
airportIdA object.
Airport.renderAirportRows()Airport.renderAirportRows(pageId, metar)
Returns a template with an array of card rows Cr Components containing the user input and outputs for airport and runway information on all airport-related pages (Departure, Departure return, Destination, Alternate). Uses the standard airport state variables, see Pages and runway performance.
This method is used by airport-related pages to keep the airport information in a standard format.
pageIdmetarpageId. This is only used to implement the refresh button.A Template containing airport information <Cr> components.
Airport.minRunwayLengthThe minimum runway length accepted in the current airport database. Shorter runways are deleted as are airports without any acceptable runways.
Airport.surfacesAn array of surface category strings. The possible strings are:
'hard''turf''dirt''gravel''water'