Merge pull request #7683 from fredj/IGC_cleanup
Move IGCZ enum to src/ol/format/IGC.js
This commit is contained in:
@@ -1538,7 +1538,7 @@ olx.format.TopoJSONOptions.prototype.layers;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
|
* @typedef {{altitudeMode: (IGCZ|string|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.format.IGCOptions;
|
olx.format.IGCOptions;
|
||||||
|
|
||||||
@@ -1546,7 +1546,7 @@ olx.format.IGCOptions;
|
|||||||
/**
|
/**
|
||||||
* Altitude mode. Possible values are `barometric`, `gps`, and `none`. Default
|
* Altitude mode. Possible values are `barometric`, `gps`, and `none`. Default
|
||||||
* is `none`.
|
* is `none`.
|
||||||
* @type {ol.format.IGCZ|undefined}
|
* @type {IGCZ|string|undefined}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.format.IGCOptions.prototype.altitudeMode;
|
olx.format.IGCOptions.prototype.altitudeMode;
|
||||||
|
|||||||
@@ -4,12 +4,21 @@
|
|||||||
import {inherits} from '../index.js';
|
import {inherits} from '../index.js';
|
||||||
import _ol_Feature_ from '../Feature.js';
|
import _ol_Feature_ from '../Feature.js';
|
||||||
import {transformWithOptions} from '../format/Feature.js';
|
import {transformWithOptions} from '../format/Feature.js';
|
||||||
import _ol_format_IGCZ_ from '../format/IGCZ.js';
|
|
||||||
import TextFeature from '../format/TextFeature.js';
|
import TextFeature from '../format/TextFeature.js';
|
||||||
import GeometryLayout from '../geom/GeometryLayout.js';
|
import GeometryLayout from '../geom/GeometryLayout.js';
|
||||||
import LineString from '../geom/LineString.js';
|
import LineString from '../geom/LineString.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
var IGCZ = {
|
||||||
|
BAROMETRIC: 'barometric',
|
||||||
|
GPS: 'gps',
|
||||||
|
NONE: 'none'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* Feature format for `*.igc` flight recording files.
|
* Feature format for `*.igc` flight recording files.
|
||||||
@@ -32,11 +41,9 @@ var IGC = function(opt_options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.format.IGCZ}
|
* @type {IGCZ}
|
||||||
*/
|
*/
|
||||||
this.altitudeMode_ = options.altitudeMode ?
|
this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : IGCZ.NONE;
|
||||||
options.altitudeMode : _ol_format_IGCZ_.NONE;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(IGC, TextFeature);
|
inherits(IGC, TextFeature);
|
||||||
@@ -45,26 +52,23 @@ inherits(IGC, TextFeature);
|
|||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {RegExp}
|
* @type {RegExp}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
IGC.B_RECORD_RE_ =
|
var B_RECORD_RE =
|
||||||
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
|
/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {RegExp}
|
* @type {RegExp}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
IGC.H_RECORD_RE_ = /^H.([A-Z]{3}).*?:(.*)/;
|
var H_RECORD_RE = /^H.([A-Z]{3}).*?:(.*)/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {RegExp}
|
* @type {RegExp}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
IGC.HFDTE_RECORD_RE_ = /^HFDTE(\d{2})(\d{2})(\d{2})/;
|
var HFDTE_RECORD_RE = /^HFDTE(\d{2})(\d{2})(\d{2})/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,9 +76,8 @@ IGC.HFDTE_RECORD_RE_ = /^HFDTE(\d{2})(\d{2})(\d{2})/;
|
|||||||
*
|
*
|
||||||
* @const
|
* @const
|
||||||
* @type {RegExp}
|
* @type {RegExp}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
IGC.NEWLINE_RE_ = /\r\n|\r|\n/;
|
var NEWLINE_RE = /\r\n|\r|\n/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +97,7 @@ IGC.prototype.readFeature;
|
|||||||
*/
|
*/
|
||||||
IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
||||||
var altitudeMode = this.altitudeMode_;
|
var altitudeMode = this.altitudeMode_;
|
||||||
var lines = text.split(IGC.NEWLINE_RE_);
|
var lines = text.split(NEWLINE_RE);
|
||||||
/** @type {Object.<string, string>} */
|
/** @type {Object.<string, string>} */
|
||||||
var properties = {};
|
var properties = {};
|
||||||
var flatCoordinates = [];
|
var flatCoordinates = [];
|
||||||
@@ -107,7 +110,7 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
var line = lines[i];
|
var line = lines[i];
|
||||||
var m;
|
var m;
|
||||||
if (line.charAt(0) == 'B') {
|
if (line.charAt(0) == 'B') {
|
||||||
m = IGC.B_RECORD_RE_.exec(line);
|
m = B_RECORD_RE.exec(line);
|
||||||
if (m) {
|
if (m) {
|
||||||
var hour = parseInt(m[1], 10);
|
var hour = parseInt(m[1], 10);
|
||||||
var minute = parseInt(m[2], 10);
|
var minute = parseInt(m[2], 10);
|
||||||
@@ -121,11 +124,11 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
flatCoordinates.push(x, y);
|
flatCoordinates.push(x, y);
|
||||||
if (altitudeMode != _ol_format_IGCZ_.NONE) {
|
if (altitudeMode != IGCZ.NONE) {
|
||||||
var z;
|
var z;
|
||||||
if (altitudeMode == _ol_format_IGCZ_.GPS) {
|
if (altitudeMode == IGCZ.GPS) {
|
||||||
z = parseInt(m[11], 10);
|
z = parseInt(m[11], 10);
|
||||||
} else if (altitudeMode == _ol_format_IGCZ_.BAROMETRIC) {
|
} else if (altitudeMode == IGCZ.BAROMETRIC) {
|
||||||
z = parseInt(m[12], 10);
|
z = parseInt(m[12], 10);
|
||||||
} else {
|
} else {
|
||||||
z = 0;
|
z = 0;
|
||||||
@@ -141,13 +144,13 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
lastDateTime = dateTime;
|
lastDateTime = dateTime;
|
||||||
}
|
}
|
||||||
} else if (line.charAt(0) == 'H') {
|
} else if (line.charAt(0) == 'H') {
|
||||||
m = IGC.HFDTE_RECORD_RE_.exec(line);
|
m = HFDTE_RECORD_RE.exec(line);
|
||||||
if (m) {
|
if (m) {
|
||||||
day = parseInt(m[1], 10);
|
day = parseInt(m[1], 10);
|
||||||
month = parseInt(m[2], 10) - 1;
|
month = parseInt(m[2], 10) - 1;
|
||||||
year = 2000 + parseInt(m[3], 10);
|
year = 2000 + parseInt(m[3], 10);
|
||||||
} else {
|
} else {
|
||||||
m = IGC.H_RECORD_RE_.exec(line);
|
m = H_RECORD_RE.exec(line);
|
||||||
if (m) {
|
if (m) {
|
||||||
properties[m[1]] = m[2].trim();
|
properties[m[1]] = m[2].trim();
|
||||||
}
|
}
|
||||||
@@ -158,8 +161,7 @@ IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var lineString = new LineString(null);
|
var lineString = new LineString(null);
|
||||||
var layout = altitudeMode == _ol_format_IGCZ_.NONE ?
|
var layout = altitudeMode == IGCZ.NONE ? GeometryLayout.XYM : GeometryLayout.XYZM;
|
||||||
GeometryLayout.XYM : GeometryLayout.XYZM;
|
|
||||||
lineString.setFlatCoordinates(layout, flatCoordinates);
|
lineString.setFlatCoordinates(layout, flatCoordinates);
|
||||||
var feature = new _ol_Feature_(transformWithOptions(lineString, false, opt_options));
|
var feature = new _ol_Feature_(transformWithOptions(lineString, false, opt_options));
|
||||||
feature.setProperties(properties);
|
feature.setProperties(properties);
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/format/IGCZ
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
BAROMETRIC: 'barometric',
|
|
||||||
GPS: 'gps',
|
|
||||||
NONE: 'none'
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user