Dedicated module for IGC altitude enum
This commit is contained in:
@@ -1932,7 +1932,7 @@ olx.format.TopoJSONOptions.prototype.defaultDataProjection;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{altitudeMode: (ol.format.IGC.Z|undefined)}}
|
* @typedef {{altitudeMode: (ol.format.IGCZ|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.format.IGCOptions;
|
olx.format.IGCOptions;
|
||||||
|
|
||||||
@@ -1940,7 +1940,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.IGC.Z|undefined}
|
* @type {ol.format.IGCZ|undefined}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.format.IGCOptions.prototype.altitudeMode;
|
olx.format.IGCOptions.prototype.altitudeMode;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.format.IGC');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.format.Feature');
|
goog.require('ol.format.Feature');
|
||||||
|
goog.require('ol.format.IGCZ');
|
||||||
goog.require('ol.format.TextFeature');
|
goog.require('ol.format.TextFeature');
|
||||||
goog.require('ol.geom.GeometryLayout');
|
goog.require('ol.geom.GeometryLayout');
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
@@ -31,10 +32,10 @@ ol.format.IGC = function(opt_options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.format.IGC.Z}
|
* @type {ol.format.IGCZ}
|
||||||
*/
|
*/
|
||||||
this.altitudeMode_ = options.altitudeMode ?
|
this.altitudeMode_ = options.altitudeMode ?
|
||||||
options.altitudeMode : ol.format.IGC.Z.NONE;
|
options.altitudeMode : ol.format.IGCZ.NONE;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.format.IGC, ol.format.TextFeature);
|
ol.inherits(ol.format.IGC, ol.format.TextFeature);
|
||||||
@@ -135,11 +136,11 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
x = -x;
|
x = -x;
|
||||||
}
|
}
|
||||||
flatCoordinates.push(x, y);
|
flatCoordinates.push(x, y);
|
||||||
if (altitudeMode != ol.format.IGC.Z.NONE) {
|
if (altitudeMode != ol.format.IGCZ.NONE) {
|
||||||
var z;
|
var z;
|
||||||
if (altitudeMode == ol.format.IGC.Z.GPS) {
|
if (altitudeMode == ol.format.IGCZ.GPS) {
|
||||||
z = parseInt(m[11], 10);
|
z = parseInt(m[11], 10);
|
||||||
} else if (altitudeMode == ol.format.IGC.Z.BAROMETRIC) {
|
} else if (altitudeMode == ol.format.IGCZ.BAROMETRIC) {
|
||||||
z = parseInt(m[12], 10);
|
z = parseInt(m[12], 10);
|
||||||
} else {
|
} else {
|
||||||
ol.DEBUG && console.assert(false, 'Unknown altitude mode.');
|
ol.DEBUG && console.assert(false, 'Unknown altitude mode.');
|
||||||
@@ -173,7 +174,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var lineString = new ol.geom.LineString(null);
|
var lineString = new ol.geom.LineString(null);
|
||||||
var layout = altitudeMode == ol.format.IGC.Z.NONE ?
|
var layout = altitudeMode == ol.format.IGCZ.NONE ?
|
||||||
ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM;
|
ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM;
|
||||||
lineString.setFlatCoordinates(layout, flatCoordinates);
|
lineString.setFlatCoordinates(layout, flatCoordinates);
|
||||||
var feature = new ol.Feature(ol.format.Feature.transformWithOptions(
|
var feature = new ol.Feature(ol.format.Feature.transformWithOptions(
|
||||||
@@ -218,14 +219,3 @@ ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.format.IGC.prototype.readProjection;
|
ol.format.IGC.prototype.readProjection;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.format.IGC.Z = {
|
|
||||||
BAROMETRIC: 'barometric',
|
|
||||||
GPS: 'gps',
|
|
||||||
NONE: 'none'
|
|
||||||
};
|
|
||||||
|
|||||||
11
src/ol/format/igcz.js
Normal file
11
src/ol/format/igcz.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
goog.provide('ol.format.IGCZ');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IGC altitude/z. One of 'barometric', 'gps', 'none'.
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.format.IGCZ = {
|
||||||
|
BAROMETRIC: 'barometric',
|
||||||
|
GPS: 'gps',
|
||||||
|
NONE: 'none'
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user