Replace IGCZ enum with typedef
This commit is contained in:
@@ -9,14 +9,9 @@ import {get as getProjection} from '../proj.js';
|
|||||||
import {transformGeometryWithOptions} from './Feature.js';
|
import {transformGeometryWithOptions} from './Feature.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @typedef {'barometric' | 'gps' | 'none'} IGCZ
|
||||||
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
||||||
* @enum {string}
|
|
||||||
*/
|
*/
|
||||||
const IGCZ = {
|
|
||||||
BAROMETRIC: 'barometric',
|
|
||||||
GPS: 'gps',
|
|
||||||
NONE: 'none',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -47,7 +42,7 @@ const NEWLINE_RE = /\r\n|\r|\n/;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {IGCZ|string} [altitudeMode='none'] Altitude mode. Possible
|
* @property {IGCZ} [altitudeMode='none'] Altitude mode. Possible
|
||||||
* values are `'barometric'`, `'gps'`, and `'none'`.
|
* values are `'barometric'`, `'gps'`, and `'none'`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -79,9 +74,7 @@ class IGC extends TextFeature {
|
|||||||
* @private
|
* @private
|
||||||
* @type {IGCZ}
|
* @type {IGCZ}
|
||||||
*/
|
*/
|
||||||
this.altitudeMode_ = options.altitudeMode
|
this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : 'none';
|
||||||
? options.altitudeMode
|
|
||||||
: IGCZ.NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,11 +112,11 @@ class IGC extends TextFeature {
|
|||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
flatCoordinates.push(x, y);
|
flatCoordinates.push(x, y);
|
||||||
if (altitudeMode != IGCZ.NONE) {
|
if (altitudeMode != 'none') {
|
||||||
let z;
|
let z;
|
||||||
if (altitudeMode == IGCZ.GPS) {
|
if (altitudeMode == 'gps') {
|
||||||
z = parseInt(m[11], 10);
|
z = parseInt(m[11], 10);
|
||||||
} else if (altitudeMode == IGCZ.BAROMETRIC) {
|
} else if (altitudeMode == 'barometric') {
|
||||||
z = parseInt(m[12], 10);
|
z = parseInt(m[12], 10);
|
||||||
} else {
|
} else {
|
||||||
z = 0;
|
z = 0;
|
||||||
@@ -156,7 +149,7 @@ class IGC extends TextFeature {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const layout =
|
const layout =
|
||||||
altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM;
|
altitudeMode == 'none' ? GeometryLayout.XYM : GeometryLayout.XYZM;
|
||||||
const lineString = new LineString(flatCoordinates, layout);
|
const lineString = new LineString(flatCoordinates, layout);
|
||||||
const feature = new Feature(
|
const feature = new Feature(
|
||||||
transformGeometryWithOptions(lineString, false, opt_options)
|
transformGeometryWithOptions(lineString, false, opt_options)
|
||||||
|
|||||||
Reference in New Issue
Block a user