From 4d2156ff3ada3444612fdeaf69f5f97e10b0dc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sat, 16 Jul 2022 23:20:28 +0200 Subject: [PATCH] Replace IGCZ enum with typedef --- src/ol/format/IGC.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/ol/format/IGC.js b/src/ol/format/IGC.js index 2c00be8359..01df64567c 100644 --- a/src/ol/format/IGC.js +++ b/src/ol/format/IGC.js @@ -9,14 +9,9 @@ import {get as getProjection} from '../proj.js'; import {transformGeometryWithOptions} from './Feature.js'; /** + * @typedef {'barometric' | 'gps' | 'none'} IGCZ * IGC altitude/z. One of 'barometric', 'gps', 'none'. - * @enum {string} */ -const IGCZ = { - BAROMETRIC: 'barometric', - GPS: 'gps', - NONE: 'none', -}; /** * @const @@ -47,7 +42,7 @@ const NEWLINE_RE = /\r\n|\r|\n/; /** * @typedef {Object} Options - * @property {IGCZ|string} [altitudeMode='none'] Altitude mode. Possible + * @property {IGCZ} [altitudeMode='none'] Altitude mode. Possible * values are `'barometric'`, `'gps'`, and `'none'`. */ @@ -79,9 +74,7 @@ class IGC extends TextFeature { * @private * @type {IGCZ} */ - this.altitudeMode_ = options.altitudeMode - ? options.altitudeMode - : IGCZ.NONE; + this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : 'none'; } /** @@ -119,11 +112,11 @@ class IGC extends TextFeature { x = -x; } flatCoordinates.push(x, y); - if (altitudeMode != IGCZ.NONE) { + if (altitudeMode != 'none') { let z; - if (altitudeMode == IGCZ.GPS) { + if (altitudeMode == 'gps') { z = parseInt(m[11], 10); - } else if (altitudeMode == IGCZ.BAROMETRIC) { + } else if (altitudeMode == 'barometric') { z = parseInt(m[12], 10); } else { z = 0; @@ -156,7 +149,7 @@ class IGC extends TextFeature { return null; } const layout = - altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM; + altitudeMode == 'none' ? GeometryLayout.XYM : GeometryLayout.XYZM; const lineString = new LineString(flatCoordinates, layout); const feature = new Feature( transformGeometryWithOptions(lineString, false, opt_options)