diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index ff886b03c1..6669c8994b 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -556,6 +556,20 @@ * @property {Array.|undefined} urls URLs. */ +/** + * @typedef {Object} olx.source.GPXOptions + * @property {Array.|undefined} attributions Attributions. + * @property {Document|undefined} doc Document. + * @property {ol.Extent|undefined} extent Extent. + * @property {string|undefined} logo Logo. + * @property {Node|undefined| node Node. + * @property {ol.proj.ProjectionLike} projection Projection. + * @property {ol.proj.ProjectionLike} reprojectTo Re-project to. + * @property {string|undefined} text Text. + * @property {string|undefined} url URL. + * @property {Array.|undefined} urls URLs. + */ + /** * @typedef {Object} olx.source.TopoJSONOptions * @property {Array.|undefined} attributions Attributions. diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index 31ca041ffc..5b1b1e0ddb 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -339,6 +339,7 @@ ol.format.GPX.WPT_PARSERS_ = ol.xml.makeParsersNS( ol.format.GPX.NAMESPACE_URIS_, { 'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), 'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime), + 'magvar': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), 'geoidheight': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), 'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), 'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString), diff --git a/src/ol/source/gpxsource.exports b/src/ol/source/gpxsource.exports new file mode 100644 index 0000000000..0dfabb47be --- /dev/null +++ b/src/ol/source/gpxsource.exports @@ -0,0 +1 @@ +@exportSymbol ol.source.GPX diff --git a/src/ol/source/gpxsource.js b/src/ol/source/gpxsource.js new file mode 100644 index 0000000000..4cf8da99ce --- /dev/null +++ b/src/ol/source/gpxsource.js @@ -0,0 +1,32 @@ +goog.provide('ol.source.GPX'); + +goog.require('ol.format.GPX'); +goog.require('ol.source.VectorFile'); + + + +/** + * @constructor + * @extends {ol.source.VectorFile} + * @param {olx.source.GPXOptions=} opt_options Options. + */ +ol.source.GPX = function(opt_options) { + + var options = goog.isDef(opt_options) ? opt_options : {}; + + goog.base(this, { + attributions: options.attributions, + doc: options.doc, + extent: options.extent, + format: new ol.format.GPX(), + logo: options.logo, + node: options.node, + projection: options.projection, + reprojectTo: options.reprojectTo, + text: options.text, + url: options.url, + urls: options.urls + }); + +}; +goog.inherits(ol.source.GPX, ol.source.VectorFile); diff --git a/test/spec/ol/format/gpxformat.test.js b/test/spec/ol/format/gpxformat.test.js index 53b8a78a17..b146289a61 100644 --- a/test/spec/ol/format/gpxformat.test.js +++ b/test/spec/ol/format/gpxformat.test.js @@ -285,6 +285,7 @@ describe('ol.format.GPX', function() { var text = '' + ' ' + + ' 11' + ' 4' + ' Name' + ' Comment' + @@ -309,6 +310,8 @@ describe('ol.format.GPX', function() { expect(fs).to.have.length(1); var f = fs[0]; expect(f).to.be.an(ol.Feature); + expect(f.get('magvar')).to.be(11); + expect(f.get('geoidheight')).to.be(4); expect(f.get('name')).to.be('Name'); expect(f.get('cmt')).to.be('Comment'); expect(f.get('desc')).to.be('Description');