UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

38 lines 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CellIdentificationNode = void 0; const data_1 = require("../../data"); const RelativePositionProcessing_1 = require("./RelativePositionProcessing"); /** * Cell identification processing node * @rdf {@link http://purl.org/poso/CellIdentification} * @category Processing node */ class CellIdentificationNode extends RelativePositionProcessing_1.RelativePositionProcessing { constructor(options) { super(data_1.RelativeDistance, options); this.options.maxDistance = this.options.maxDistance || 2; } processRelativePositions(dataObject, relativePositions, dataFrame) { return new Promise((resolve) => { let spheres = []; relativePositions.forEach((object, relativePosition) => { if (object.getPosition()) { spheres.push([object.getPosition(), relativePosition.distance]); } }); // Order points and distances by distances spheres = spheres.sort((a, b) => a[1] - b[1]); if (spheres.length > 0 && spheres[0][1] <= this.options.maxDistance) { const position = spheres[0][0].clone(); position.timestamp = dataFrame.createdTimestamp; position.accuracy.value = spheres[0][1]; dataObject.setPosition(position); return resolve(dataObject); } resolve(dataObject); }); } } exports.CellIdentificationNode = CellIdentificationNode; //# sourceMappingURL=CellIdentificationNode.js.map