Add ol.source.GPX
This commit is contained in:
@@ -556,6 +556,20 @@
|
|||||||
* @property {Array.<string>|undefined} urls URLs.
|
* @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
|
* @typedef {Object} olx.source.TopoJSONOptions
|
||||||
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
* @property {Array.<ol.Attribution>|undefined} attributions Attributions.
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ ol.format.GPX.WPT_PARSERS_ = ol.xml.makeParsersNS(
|
|||||||
ol.format.GPX.NAMESPACE_URIS_, {
|
ol.format.GPX.NAMESPACE_URIS_, {
|
||||||
'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
|
'ele': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
|
||||||
'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime),
|
'time': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDateTime),
|
||||||
|
'magvar': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
|
||||||
'geoidheight': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
|
'geoidheight': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal),
|
||||||
'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
'name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||||
'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
'cmt': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||||
|
|||||||
1
src/ol/source/gpxsource.exports
Normal file
1
src/ol/source/gpxsource.exports
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@exportSymbol ol.source.GPX
|
||||||
32
src/ol/source/gpxsource.js
Normal file
32
src/ol/source/gpxsource.js
Normal 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);
|
||||||
@@ -285,6 +285,7 @@ describe('ol.format.GPX', function() {
|
|||||||
var text =
|
var text =
|
||||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||||
' <wpt lat="1" lon="2">' +
|
' <wpt lat="1" lon="2">' +
|
||||||
|
' <magvar>11</magvar>' +
|
||||||
' <geoidheight>4</geoidheight>' +
|
' <geoidheight>4</geoidheight>' +
|
||||||
' <name>Name</name>' +
|
' <name>Name</name>' +
|
||||||
' <cmt>Comment</cmt>' +
|
' <cmt>Comment</cmt>' +
|
||||||
@@ -309,6 +310,8 @@ describe('ol.format.GPX', function() {
|
|||||||
expect(fs).to.have.length(1);
|
expect(fs).to.have.length(1);
|
||||||
var f = fs[0];
|
var f = fs[0];
|
||||||
expect(f).to.be.an(ol.Feature);
|
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('name')).to.be('Name');
|
||||||
expect(f.get('cmt')).to.be('Comment');
|
expect(f.get('cmt')).to.be('Comment');
|
||||||
expect(f.get('desc')).to.be('Description');
|
expect(f.get('desc')).to.be('Description');
|
||||||
|
|||||||
Reference in New Issue
Block a user