-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate sensor position schema detection and parsing (#59)
- Loading branch information
Showing
17 changed files
with
962 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Nullable, UnknownRecord } from '../types/core'; | ||
import { SensorPosition } from '../types/internal'; | ||
export interface IDataPackageParser { | ||
/** | ||
* Parse a data package sensor position record into an | ||
* internal shape based on detected schema version. | ||
* @param position The position to parse | ||
* @returns The parsed position to an internal, normalized shape. | ||
*/ | ||
parseSensorPosition: (position: Nullable<UnknownRecord>) => Nullable<SensorPosition>; | ||
} | ||
declare const DataPackageParser: IDataPackageParser; | ||
export default DataPackageParser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _typeUtil = require("../util/typeUtil"); | ||
var _neonDataPackage = require("../types/neonDataPackage"); | ||
var DataPackageParser = { | ||
parseSensorPosition: function parseSensorPosition(position) { | ||
if (!(0, _typeUtil.exists)(position)) { | ||
return null; | ||
} | ||
var result = null; | ||
var resultV2 = _neonDataPackage.sensorPositionV2Schema.safeParse(position); | ||
if (!resultV2.success) { | ||
// Check for v1 schema | ||
var resultV1 = _neonDataPackage.sensorPositionV1Schema.safeParse(position); | ||
if (!resultV1.success) { | ||
var v2ErrorFormat = resultV2.error.format(); | ||
var v1ErrorFormat = resultV1.error.format(); | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to detect sensor position schema', v2ErrorFormat, v1ErrorFormat); | ||
} else { | ||
var parsedV1 = resultV1.data; | ||
result = { | ||
horVer: parsedV1['HOR.VER'], | ||
sensorName: (0, _typeUtil.isStringNonEmpty)(parsedV1.name) ? parsedV1.name : 'N/A', | ||
sensorDescription: parsedV1.description, | ||
sensorStartDateTime: parsedV1.start, | ||
sensorEndDateTime: parsedV1.end, | ||
referenceLocationName: parsedV1.referenceName, | ||
referenceLocationDescription: parsedV1.referenceDescription, | ||
referenceLocationStartDateTime: parsedV1.referenceStart, | ||
referenceLocationEndDateTime: parsedV1.referenceEnd, | ||
xOffset: parsedV1.xOffset, | ||
yOffset: parsedV1.yOffset, | ||
zOffset: parsedV1.zOffset, | ||
pitch: parsedV1.pitch, | ||
roll: parsedV1.roll, | ||
azimuth: parsedV1.azimuth, | ||
referenceLocationLatitude: parsedV1.referenceLatitude, | ||
referenceLocationLongitude: parsedV1.referenceLongitude, | ||
referenceLocationElevation: parsedV1.referenceElevation, | ||
eastOffset: parsedV1.eastOffset, | ||
northOffset: parsedV1.northOffset, | ||
xAzimuth: parsedV1.xAzimuth, | ||
yAzimuth: parsedV1.yAzimuth | ||
}; | ||
} | ||
} else { | ||
var parsedV2 = resultV2.data; | ||
result = { | ||
horVer: parsedV2['HOR.VER'], | ||
sensorName: parsedV2.sensorLocationID, | ||
sensorDescription: parsedV2.sensorLocationDescription, | ||
sensorStartDateTime: parsedV2.positionStartDateTime, | ||
sensorEndDateTime: parsedV2.positionEndDateTime, | ||
referenceLocationName: parsedV2.referenceLocationID, | ||
referenceLocationDescription: parsedV2.referenceLocationIDDescription, | ||
referenceLocationStartDateTime: parsedV2.referenceLocationIDStartDateTime, | ||
referenceLocationEndDateTime: parsedV2.referenceLocationIDEndDateTime, | ||
xOffset: parsedV2.xOffset, | ||
yOffset: parsedV2.yOffset, | ||
zOffset: parsedV2.zOffset, | ||
pitch: parsedV2.pitch, | ||
roll: parsedV2.roll, | ||
azimuth: parsedV2.azimuth, | ||
referenceLocationLatitude: parsedV2.locationReferenceLatitude, | ||
referenceLocationLongitude: parsedV2.locationReferenceLongitude, | ||
referenceLocationElevation: parsedV2.locationReferenceElevation, | ||
eastOffset: parsedV2.eastOffset, | ||
northOffset: parsedV2.northOffset, | ||
xAzimuth: parsedV2.xAzimuth, | ||
yAzimuth: parsedV2.yAzimuth | ||
}; | ||
} | ||
return result; | ||
} | ||
}; | ||
Object.freeze(DataPackageParser); | ||
var _default = DataPackageParser; | ||
exports.default = _default; |
Oops, something went wrong.