Add ol.source.GPX

This commit is contained in:
Tom Payne
2014-01-16 19:00:58 +01:00
parent fa89c1c3a3
commit 917b6cda8f
5 changed files with 51 additions and 0 deletions

View File

@@ -556,6 +556,20 @@
* @property {Array.<string>|undefined} urls URLs.
*/
/**
* @typedef {Object} olx.source.GPXOptions
* @property {Array.<ol.Attribution>|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.<string>|undefined} urls URLs.
*/
/**
* @typedef {Object} olx.source.TopoJSONOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.

View File

@@ -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),

View File

@@ -0,0 +1 @@
@exportSymbol ol.source.GPX

View File

@@ -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);

View File

@@ -285,6 +285,7 @@ describe('ol.format.GPX', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <wpt lat="1" lon="2">' +
' <magvar>11</magvar>' +
' <geoidheight>4</geoidheight>' +
' <name>Name</name>' +
' <cmt>Comment</cmt>' +
@@ -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');