Rename ol.xml.pushAndParse to ol.xml.pushParseAndPop

This commit is contained in:
Tom Payne
2014-01-20 16:47:56 +01:00
parent 646dd18149
commit 432d10a457
3 changed files with 28 additions and 26 deletions
+8 -7
View File
@@ -92,7 +92,7 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
ol.format.GPX.parseRtePt_ = function(node, objectStack) { ol.format.GPX.parseRtePt_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'rtept'); goog.asserts.assert(node.localName == 'rtept');
var values = ol.xml.pushAndParse( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack); {}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack);
if (goog.isDef(values)) { if (goog.isDef(values)) {
var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
@@ -111,7 +111,7 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) {
ol.format.GPX.parseTrkPt_ = function(node, objectStack) { ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'trkpt'); goog.asserts.assert(node.localName == 'trkpt');
var values = ol.xml.pushAndParse( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack); {}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack);
if (goog.isDef(values)) { if (goog.isDef(values)) {
var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
@@ -148,7 +148,7 @@ ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
ol.format.GPX.readRte_ = function(node, objectStack) { ol.format.GPX.readRte_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'rte'); goog.asserts.assert(node.localName == 'rte');
var values = ol.xml.pushAndParse({ var values = ol.xml.pushParseAndPop({
'flatCoordinates': [] 'flatCoordinates': []
}, ol.format.GPX.RTE_PARSERS_, node, objectStack); }, ol.format.GPX.RTE_PARSERS_, node, objectStack);
if (!goog.isDef(values)) { if (!goog.isDef(values)) {
@@ -174,7 +174,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
ol.format.GPX.readTrk_ = function(node, objectStack) { ol.format.GPX.readTrk_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'trk'); goog.asserts.assert(node.localName == 'trk');
var values = ol.xml.pushAndParse({ var values = ol.xml.pushParseAndPop({
'flatCoordinates': [], 'flatCoordinates': [],
'ends': [] 'ends': []
}, ol.format.GPX.TRK_PARSERS_, node, objectStack); }, ol.format.GPX.TRK_PARSERS_, node, objectStack);
@@ -204,7 +204,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
ol.format.GPX.readWpt_ = function(node, objectStack) { ol.format.GPX.readWpt_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'wpt'); goog.asserts.assert(node.localName == 'wpt');
var values = ol.xml.pushAndParse( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack); {}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
if (!goog.isDef(values)) { if (!goog.isDef(values)) {
return undefined; return undefined;
@@ -392,8 +392,9 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node) {
return []; return [];
} }
if (node.localName == 'gpx') { if (node.localName == 'gpx') {
var features = ol.xml.pushAndParse(/** @type {Array.<ol.Feature>} */ ([]), var features = ol.xml.pushParseAndPop(
ol.format.GPX.GPX_PARSERS_, node, []); /** @type {Array.<ol.Feature>} */ ([]), ol.format.GPX.GPX_PARSERS_,
node, []);
if (goog.isDef(features)) { if (goog.isDef(features)) {
return features; return features;
} else { } else {
+18 -18
View File
@@ -487,7 +487,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
// FIXME viewBoundScale // FIXME viewBoundScale
// FIXME viewFormat // FIXME viewFormat
// FIXME httpQuery // FIXME httpQuery
var object = ol.xml.pushAndParse( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!goog.isDef(object)) {
return; return;
@@ -564,7 +564,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
// FIXME gx:outerWidth // FIXME gx:outerWidth
// FIXME gx:physicalWidth // FIXME gx:physicalWidth
// FIXME gx:labelVisibility // FIXME gx:labelVisibility
var object = ol.xml.pushAndParse( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!goog.isDef(object)) {
return; return;
@@ -589,7 +589,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'PolyStyle'); goog.asserts.assert(node.localName == 'PolyStyle');
// FIXME colorMode // FIXME colorMode
var object = ol.xml.pushAndParse( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!goog.isDef(object)) {
return; return;
@@ -622,7 +622,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
ol.format.KML.readFlatLinearRing_ = function(node, objectStack) { ol.format.KML.readFlatLinearRing_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'LinearRing'); goog.asserts.assert(node.localName == 'LinearRing');
return /** @type {Array.<number>} */ (ol.xml.pushAndParse( return /** @type {Array.<number>} */ (ol.xml.pushParseAndPop(
null, ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack)); null, ol.format.KML.FLAT_LINEAR_RING_PARSERS_, node, objectStack));
}; };
@@ -667,7 +667,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
goog.asserts.assert(goog.array.indexOf( goog.asserts.assert(goog.array.indexOf(
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI) != -1); ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI) != -1);
goog.asserts.assert(node.localName == 'MultiTrack'); goog.asserts.assert(node.localName == 'MultiTrack');
var lineStrings = ol.xml.pushAndParse( var lineStrings = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.LineString>} */ ([]), /** @type {Array.<ol.geom.LineString>} */ ([]),
ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack);
if (!goog.isDef(lineStrings)) { if (!goog.isDef(lineStrings)) {
@@ -690,7 +690,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
goog.asserts.assert(goog.array.indexOf( goog.asserts.assert(goog.array.indexOf(
ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI) != -1); ol.format.KML.GX_NAMESPACE_URIS_, node.namespaceURI) != -1);
goog.asserts.assert(node.localName == 'Track'); goog.asserts.assert(node.localName == 'Track');
var gxTrackObject = ol.xml.pushAndParse( var gxTrackObject = ol.xml.pushParseAndPop(
/** @type {ol.format.KMLGxTrackObject_} */ ({ /** @type {ol.format.KMLGxTrackObject_} */ ({
flatCoordinates: [], flatCoordinates: [],
whens: [] whens: []
@@ -721,7 +721,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
ol.format.KML.readIcon_ = function(node, objectStack) { ol.format.KML.readIcon_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Icon'); goog.asserts.assert(node.localName == 'Icon');
var iconObject = ol.xml.pushAndParse( var iconObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.ICON_PARSERS_, node, objectStack); {}, ol.format.KML.ICON_PARSERS_, node, objectStack);
if (goog.isDef(iconObject)) { if (goog.isDef(iconObject)) {
return iconObject; return iconObject;
@@ -739,7 +739,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) {
*/ */
ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) { ol.format.KML.readFlatCoordinatesFromNode_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
return /** @type {Array.<number>} */ (ol.xml.pushAndParse(null, return /** @type {Array.<number>} */ (ol.xml.pushParseAndPop(null,
ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack)); ol.format.KML.GEOMETRY_FLAT_COORDINATES_PARSERS_, node, objectStack));
}; };
@@ -796,7 +796,7 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) {
ol.format.KML.readMultiGeometry_ = function(node, objectStack) { ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'MultiGeometry'); goog.asserts.assert(node.localName == 'MultiGeometry');
var geometries = ol.xml.pushAndParse( var geometries = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.Geometry>} */ ([]), /** @type {Array.<ol.geom.Geometry>} */ ([]),
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack); ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
if (!goog.isDef(geometries)) { if (!goog.isDef(geometries)) {
@@ -919,7 +919,7 @@ ol.format.KML.readPoint_ = function(node, objectStack) {
ol.format.KML.readPolygon_ = function(node, objectStack) { ol.format.KML.readPolygon_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Polygon'); goog.asserts.assert(node.localName == 'Polygon');
var flatLinearRings = ol.xml.pushAndParse( var flatLinearRings = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([null]), /** @type {Array.<Array.<number>>} */ ([null]),
ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack); ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack);
if (goog.isDefAndNotNull(flatLinearRings) && if (goog.isDefAndNotNull(flatLinearRings) &&
@@ -950,7 +950,7 @@ ol.format.KML.readPolygon_ = function(node, objectStack) {
ol.format.KML.readStyle_ = function(node, objectStack) { ol.format.KML.readStyle_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Style'); goog.asserts.assert(node.localName == 'Style');
var styleObject = ol.xml.pushAndParse( var styleObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(styleObject)) { if (!goog.isDef(styleObject)) {
return null; return null;
@@ -992,7 +992,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'Data'); goog.asserts.assert(node.localName == 'Data');
var name = node.getAttribute('name'); var name = node.getAttribute('name');
if (!goog.isNull(name)) { if (!goog.isNull(name)) {
var data = ol.xml.pushAndParse( var data = ol.xml.pushParseAndPop(
undefined, ol.format.KML.DATA_PARSERS_, node, objectStack); undefined, ol.format.KML.DATA_PARSERS_, node, objectStack);
if (goog.isDef(data)) { if (goog.isDef(data)) {
var featureObject = var featureObject =
@@ -1024,7 +1024,7 @@ ol.format.KML.ExtendedDataParser_ = function(node, objectStack) {
ol.format.KML.PairDataParser_ = function(node, objectStack) { ol.format.KML.PairDataParser_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Pair'); goog.asserts.assert(node.localName == 'Pair');
var pairObject = ol.xml.pushAndParse( var pairObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack); {}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
if (!goog.isDef(pairObject)) { if (!goog.isDef(pairObject)) {
return; return;
@@ -1098,7 +1098,7 @@ ol.format.KML.StyleMapParser_ = function(node, objectStack) {
ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) { ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'innerBoundaryIs'); goog.asserts.assert(node.localName == 'innerBoundaryIs');
var flatLinearRing = ol.xml.pushAndParse( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack);
if (goog.isDef(flatLinearRing)) { if (goog.isDef(flatLinearRing)) {
@@ -1119,7 +1119,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) { ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'outerBoundaryIs'); goog.asserts.assert(node.localName == 'outerBoundaryIs');
var flatLinearRing = ol.xml.pushAndParse( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack);
if (goog.isDef(flatLinearRing)) { if (goog.isDef(flatLinearRing)) {
@@ -1448,7 +1448,7 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
'Style': goog.bind(this.readSharedStyle_, this), 'Style': goog.bind(this.readSharedStyle_, this),
'StyleMap': goog.bind(this.readSharedStyleMap_, this) 'StyleMap': goog.bind(this.readSharedStyleMap_, this)
}); });
var features = ol.xml.pushAndParse(/** @type {Array.<ol.Feature>} */ ([]), var features = ol.xml.pushParseAndPop(/** @type {Array.<ol.Feature>} */ ([]),
parsersNS, node, objectStack, this); parsersNS, node, objectStack, this);
if (goog.isDef(features)) { if (goog.isDef(features)) {
return features; return features;
@@ -1467,7 +1467,7 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'Placemark'); goog.asserts.assert(node.localName == 'Placemark');
var object = ol.xml.pushAndParse({'geometry': null}, var object = ol.xml.pushParseAndPop({'geometry': null},
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack); ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!goog.isDef(object)) {
return undefined; return undefined;
@@ -1525,7 +1525,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'StyleMap'); goog.asserts.assert(node.localName == 'StyleMap');
var id = node.getAttribute('id'); var id = node.getAttribute('id');
if (!goog.isNull(id)) { if (!goog.isNull(id)) {
var styleObject = ol.xml.pushAndParse(/** @type {Object} */ ({}), var styleObject = ol.xml.pushParseAndPop(/** @type {Object} */ ({}),
ol.format.KML.STYLE_MAP_PARSERS_, node, objectStack); ol.format.KML.STYLE_MAP_PARSERS_, node, objectStack);
if (!goog.isDef(styleObject)) { if (!goog.isDef(styleObject)) {
return; return;
+2 -1
View File
@@ -196,7 +196,8 @@ ol.xml.parse = function(parsersNS, node, objectStack, opt_this) {
* @return {T|undefined} Object. * @return {T|undefined} Object.
* @template T * @template T
*/ */
ol.xml.pushAndParse = function(object, parsersNS, node, objectStack, opt_this) { ol.xml.pushParseAndPop = function(
object, parsersNS, node, objectStack, opt_this) {
objectStack.push(object); objectStack.push(object);
ol.xml.parse(parsersNS, node, objectStack, opt_this); ol.xml.parse(parsersNS, node, objectStack, opt_this);
return objectStack.pop(); return objectStack.pop();