From 434a90506d662920249e724fe8526fd9f0ec6361 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Feb 2018 09:12:57 -0700 Subject: [PATCH] Remove private static members from OSMXML format --- src/ol/format/OSMXML.js | 110 ++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 60 deletions(-) diff --git a/src/ol/format/OSMXML.js b/src/ol/format/OSMXML.js index 7f6d6a5f3e..ee35408b86 100644 --- a/src/ol/format/OSMXML.js +++ b/src/ol/format/OSMXML.js @@ -36,12 +36,50 @@ const OSMXML = function() { inherits(OSMXML, XMLFeature); +/** + * @const + * @type {Array.} + */ +const NAMESPACE_URIS = [null]; + + +/** + * @const + * @type {Object.>} + */ +const WAY_PARSERS = makeStructureNS( + NAMESPACE_URIS, { + 'nd': readNd, + 'tag': readTag + }); + + +/** + * @const + * @type {Object.>} + */ +const PARSERS = makeStructureNS( + NAMESPACE_URIS, { + 'node': readNode, + 'way': readWay + }); + + +/** + * @const + * @type {Object.>} + */ +const NODE_PARSERS = makeStructureNS( + NAMESPACE_URIS, { + 'tag': readTag + }); + + /** * @param {Node} node Node. * @param {Array.<*>} objectStack Object stack. - * @private */ -OSMXML.readNode_ = function(node, objectStack) { +function readNode(node, objectStack) { const options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); const state = /** @type {Object} */ (objectStack[objectStack.length - 1]); const id = node.getAttribute('id'); @@ -54,7 +92,7 @@ OSMXML.readNode_ = function(node, objectStack) { const values = pushParseAndPop({ tags: {} - }, OSMXML.NODE_PARSERS_, node, objectStack); + }, NODE_PARSERS, node, objectStack); if (!isEmpty(values.tags)) { const geometry = new Point(coordinates); transformWithOptions(geometry, false, options); @@ -63,91 +101,43 @@ OSMXML.readNode_ = function(node, objectStack) { feature.setProperties(values.tags); state.features.push(feature); } -}; +} /** * @param {Node} node Node. * @param {Array.<*>} objectStack Object stack. - * @private */ -OSMXML.readWay_ = function(node, objectStack) { +function readWay(node, objectStack) { const id = node.getAttribute('id'); const values = pushParseAndPop({ id: id, ndrefs: [], tags: {} - }, OSMXML.WAY_PARSERS_, node, objectStack); + }, WAY_PARSERS, node, objectStack); const state = /** @type {Object} */ (objectStack[objectStack.length - 1]); state.ways.push(values); -}; +} /** * @param {Node} node Node. * @param {Array.<*>} objectStack Object stack. - * @private */ -OSMXML.readNd_ = function(node, objectStack) { +function readNd(node, objectStack) { const values = /** @type {Object} */ (objectStack[objectStack.length - 1]); values.ndrefs.push(node.getAttribute('ref')); -}; +} /** * @param {Node} node Node. * @param {Array.<*>} objectStack Object stack. - * @private */ -OSMXML.readTag_ = function(node, objectStack) { +function readTag(node, objectStack) { const values = /** @type {Object} */ (objectStack[objectStack.length - 1]); values.tags[node.getAttribute('k')] = node.getAttribute('v'); -}; - - -/** - * @const - * @private - * @type {Array.} - */ -OSMXML.NAMESPACE_URIS_ = [ - null -]; - - -/** - * @const - * @type {Object.>} - * @private - */ -OSMXML.WAY_PARSERS_ = makeStructureNS( - OSMXML.NAMESPACE_URIS_, { - 'nd': OSMXML.readNd_, - 'tag': OSMXML.readTag_ - }); - - -/** - * @const - * @type {Object.>} - * @private - */ -OSMXML.PARSERS_ = makeStructureNS( - OSMXML.NAMESPACE_URIS_, { - 'node': OSMXML.readNode_, - 'way': OSMXML.readWay_ - }); - - -/** - * @const - * @type {Object.>} - * @private - */ -OSMXML.NODE_PARSERS_ = makeStructureNS( - OSMXML.NAMESPACE_URIS_, { - 'tag': OSMXML.readTag_ - }); +} /** @@ -172,7 +162,7 @@ OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { nodes: {}, ways: [], features: [] - }, OSMXML.PARSERS_, node, [options]); + }, PARSERS, node, [options]); // parse nodes in ways for (let j = 0; j < state.ways.length; j++) { const values = /** @type {Object} */ (state.ways[j]);