From 401acc77f364df4436a81d6784f75a5087e3cdc5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 23 Jan 2014 15:37:54 +0100 Subject: [PATCH 1/5] Remove unneeded 'ms' param from Date.UTC function --- src/ol/format/igcformat.js | 2 +- src/ol/format/kmlformat.js | 2 +- src/ol/format/xsdformat.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/format/igcformat.js b/src/ol/format/igcformat.js index ea4005822e..06f165affd 100644 --- a/src/ol/format/igcformat.js +++ b/src/ol/format/igcformat.js @@ -127,7 +127,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text) { } flatCoordinates.push(z); } - var dateTime = Date.UTC(year, month, day, hour, minute, second, 0); + var dateTime = Date.UTC(year, month, day, hour, minute, second); flatCoordinates.push(dateTime / 1000); } } else if (line.charAt(0) == 'H') { diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 02c75e0a08..c861fa763e 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -1129,7 +1129,7 @@ ol.format.KML.whenParser_ = function(node, objectStack) { var hour = parseInt(m[4], 10); var minute = parseInt(m[5], 10); var second = parseInt(m[6], 10); - var when = Date.UTC(year, month, day, hour, minute, second, 0); + var when = Date.UTC(year, month, day, hour, minute, second); if (m[7] != 'Z') { var sign = m[8] == '-' ? -1 : 1; when += sign * 60 * parseInt(m[9], 10); diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index a0b2685ff9..85cf9c54d8 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -42,7 +42,7 @@ ol.format.XSD.readDateTime = function(node) { var hour = parseInt(m[4], 10); var minute = parseInt(m[5], 10); var second = parseInt(m[6], 10); - var dateTime = Date.UTC(year, month, day, hour, minute, second, 0) / 1000; + var dateTime = Date.UTC(year, month, day, hour, minute, second) / 1000; if (m[7] != 'Z') { var sign = m[8] == '-' ? -1 : 1; dateTime += sign * 60 * parseInt(m[9], 10); From 7b09e04001e3fa857f469aad09dbe393c9673199 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 23 Jan 2014 15:38:51 +0100 Subject: [PATCH 2/5] Rename ol.format.KML.readscale_ to ol.format.KML.readScale_ --- src/ol/format/kmlformat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index c861fa763e..544c1cff2e 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -433,7 +433,7 @@ ol.format.KML.readVec2_ = function(node) { * @private * @return {number|undefined} Scale. */ -ol.format.KML.readscale_ = function(node) { +ol.format.KML.readScale_ = function(node) { var number = ol.format.KML.readNumber_(node); if (goog.isDef(number)) { return Math.sqrt(number); @@ -1236,7 +1236,7 @@ ol.format.KML.ICON_STYLE_PARSERS_ = ol.xml.makeParsersNS( 'Icon': ol.xml.makeObjectPropertySetter(ol.format.KML.readIcon_), 'heading': ol.xml.makeObjectPropertySetter(ol.format.KML.readNumber_), 'hotSpot': ol.xml.makeObjectPropertySetter(ol.format.KML.readVec2_), - 'scale': ol.xml.makeObjectPropertySetter(ol.format.KML.readscale_) + 'scale': ol.xml.makeObjectPropertySetter(ol.format.KML.readScale_) }); From 64ccfdc8052078016db09fd6fcd5e529e8758c50 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 23 Jan 2014 15:55:50 +0100 Subject: [PATCH 3/5] Add exponent support in ol.format.XSD.readDecimal --- src/ol/format/xsdformat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index 85cf9c54d8..df4ed9f763 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -64,7 +64,7 @@ ol.format.XSD.readDateTime = function(node) { ol.format.XSD.readDecimal = function(node) { // FIXME check spec var s = ol.xml.getAllTextContent(node, false); - var m = /^\s*([+\-]?\d+(?:\.\d*)?)\s*$/.exec(s); + var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s); if (m) { return parseFloat(m[1]); } else { From 271caef342e3f7a7b57eec563cba43de84c006fd Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 23 Jan 2014 16:09:05 +0100 Subject: [PATCH 4/5] Better ol.format.XSD.* documentation --- src/ol/format/xsdformat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/format/xsdformat.js b/src/ol/format/xsdformat.js index df4ed9f763..9d52f36d38 100644 --- a/src/ol/format/xsdformat.js +++ b/src/ol/format/xsdformat.js @@ -28,7 +28,7 @@ ol.format.XSD.readBoolean = function(node) { /** * @param {Node} node Node. - * @return {number|undefined} DateTime. + * @return {number|undefined} DateTime in seconds. */ ol.format.XSD.readDateTime = function(node) { var s = ol.xml.getAllTextContent(node, false); @@ -75,7 +75,7 @@ ol.format.XSD.readDecimal = function(node) { /** * @param {Node} node Node. - * @return {number|undefined} Decimal. + * @return {number|undefined} Non negative integer. */ ol.format.XSD.readNonNegativeInteger = function(node) { var s = ol.xml.getAllTextContent(node, false); From 295d4fbaa3e51896e5853455358444a7197a4cd1 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 23 Jan 2014 16:13:53 +0100 Subject: [PATCH 5/5] Use ol.format.XSD.readDecimal in ol.format.KML --- src/ol/format/kmlformat.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 544c1cff2e..f2cdbca34f 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -364,22 +364,6 @@ ol.format.KML.readFlatCoordinates_ = function(node) { }; -/** - * @param {Node} node Node. - * @private - * @return {number|undefined} - */ -ol.format.KML.readNumber_ = function(node) { - var s = ol.xml.getAllTextContent(node, false); - var m = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s); - if (m) { - return parseFloat(m[1]); - } else { - return undefined; - } -}; - - /** * @param {Node} node Node. * @private @@ -434,7 +418,7 @@ ol.format.KML.readVec2_ = function(node) { * @return {number|undefined} Scale. */ ol.format.KML.readScale_ = function(node) { - var number = ol.format.KML.readNumber_(node); + var number = ol.format.XSD.readDecimal(node); if (goog.isDef(number)) { return Math.sqrt(number); } else { @@ -1234,7 +1218,7 @@ ol.format.KML.ICON_PARSERS_ = ol.xml.makeParsersNS( ol.format.KML.ICON_STYLE_PARSERS_ = ol.xml.makeParsersNS( ol.format.KML.NAMESPACE_URIS_, { 'Icon': ol.xml.makeObjectPropertySetter(ol.format.KML.readIcon_), - 'heading': ol.xml.makeObjectPropertySetter(ol.format.KML.readNumber_), + 'heading': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal), 'hotSpot': ol.xml.makeObjectPropertySetter(ol.format.KML.readVec2_), 'scale': ol.xml.makeObjectPropertySetter(ol.format.KML.readScale_) }); @@ -1259,7 +1243,7 @@ ol.format.KML.INNER_BOUNDARY_IS_PARSERS_ = ol.xml.makeParsersNS( ol.format.KML.LINE_STYLE_PARSERS_ = ol.xml.makeParsersNS( ol.format.KML.NAMESPACE_URIS_, { 'color': ol.xml.makeObjectPropertySetter(ol.format.KML.readColor_), - 'width': ol.xml.makeObjectPropertySetter(ol.format.KML.readNumber_) + 'width': ol.xml.makeObjectPropertySetter(ol.format.XSD.readDecimal) });