all-airports
Version:
Serves as an independent data scraping module, complete with ontology and full scraping ability for the airports of the world
97 lines (96 loc) • 5.72 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var funktologies_1 = require("funktologies");
var getUuid = require("uuid-by-string");
var constants_1 = require("../constants/constants");
var globalStore_1 = require("../constants/globalStore");
function getHelicopterLandingZones() {
Object.values(globalStore_1.store.airports).forEach(function (airport) {
var location = funktologies_1.getRelation(airport.objectProperties, constants_1.consts.ONTOLOGY.HAS_LOCATION);
location = globalStore_1.store.locations[location && location['@id']];
var runway = funktologies_1.getRelation(airport.objectProperties, constants_1.consts.ONTOLOGY.HAS_RUNWAY);
runway = globalStore_1.store.runways[runway && runway['@id']];
// No location, no way to land on the spot.
// No runway, no place to get length, width, and surface materials from.
if (!location || !runway) {
return;
}
var surfaceMats = airport.objectProperties
.filter(function (x) { return x[constants_1.consts.ONTOLOGY.HAS_SURFACE_MATERIAL]; })
.map(function (y) { return y[constants_1.consts.ONTOLOGY.HAS_SURFACE_MATERIAL]; })
.map(function (z) { return globalStore_1.store.surfaceMaterials[z && z['@id']]; });
var latLng = location.datatypeProperties[constants_1.consts.WGS84_POS.LAT_LONG];
var length = runway.datatypeProperties[constants_1.consts.ONTOLOGY.DT_LENGTH];
var width = runway.datatypeProperties[constants_1.consts.ONTOLOGY.DT_WIDTH];
var unit = runway.datatypeProperties[constants_1.consts.ONTOLOGY.DT_UNIT];
// Without a location, a width, a length, and a minimum size (80 ft width),
// There is nothing to make a Helicopter Landing Zone out of.
if (!latLng || !length || !width || !Math.floor(width / 80)) {
return;
}
var hlzId = constants_1.consts.ONTOLOGY.INST_HELO_LAND_ZONE + getUuid(latLng);
var objectProp = {};
if (!globalStore_1.store.helicopterLandingZones[hlzId]) {
objectProp = funktologies_1.entityMaker(constants_1.consts.ONTOLOGY.HAS_HELO_LAND_ZONE, constants_1.consts.ONTOLOGY.ONT_HELO_LAND_ZONE, hlzId, "Helicopter Landing Zone on runway of airport: " + (airport.datatypeProperties[constants_1.consts.ONTOLOGY.DT_NAME] ||
airport.datatypeProperties[constants_1.consts.ONTOLOGY.DT_ICAO_CODE] ||
'N/A'));
globalStore_1.store.helicopterLandingZones[hlzId] = objectProp[constants_1.consts.ONTOLOGY.HAS_HELO_LAND_ZONE];
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_LENGTH] = length;
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_WIDTH] = width;
globalStore_1.store.helicopterLandingZones[hlzId].objectProperties.push(funktologies_1.entityRefMaker(constants_1.consts.ONTOLOGY.HAS_LOCATION, globalStore_1.store.locations, location['@id']));
surfaceMats.forEach(function (sm) {
globalStore_1.store.helicopterLandingZones[hlzId].objectProperties.push(funktologies_1.entityRefMaker(constants_1.consts.ONTOLOGY.HAS_SURFACE_MATERIAL, globalStore_1.store.surfaceMaterials, sm['@id']));
});
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_1] = getNumOfLPS(length, width, 1);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_2] = getNumOfLPS(length, width, 2);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_3] = getNumOfLPS(length, width, 3);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_4] = getNumOfLPS(length, width, 4);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_5] = getNumOfLPS(length, width, 5);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_6] = getNumOfLPS(length, width, 6);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_NUM_OF_LAND_SITE_7] = getNumOfLPS(length, width, 7);
globalStore_1.store.helicopterLandingZones[hlzId].datatypeProperties[constants_1.consts.ONTOLOGY.DT_UNIT] = unit || 'ft (Guessed Unit)';
}
});
}
exports.getHelicopterLandingZones = getHelicopterLandingZones;
;
function getNumOfLPS(length, width, size) {
var lengthInMeters = 0.3048 * length;
var widthInMeters = 0.3048 * width;
var minBase;
var numInWidth = 0;
var numInLength = 0;
switch (size) {
case 1: {
minBase = 25;
break;
}
case 2: {
minBase = 35;
break;
}
case 3: {
minBase = 50;
break;
}
case 4: {
minBase = 80;
break;
}
case 5: {
minBase = 100;
break;
}
case 6: {
minBase = 125;
break;
}
case 7: {
minBase = 150;
break;
}
}
numInLength = Math.floor(lengthInMeters / minBase);
numInWidth = Math.floor(widthInMeters / minBase);
return numInWidth * numInLength;
}
;