Parse coordinates in GML in a single pass

This commit is contained in:
Tom Payne
2014-03-18 16:06:41 +01:00
parent 84cb3c88ef
commit b3ac959d6a

View File

@@ -680,8 +680,18 @@ ol.format.GML.readFlatCoordinatesFromNode_ = function(node, objectStack) {
* @return {Array.<number>|undefined} Flat coordinates.
*/
ol.format.GML.readFlatPos_ = function(node, objectStack) {
var s = ol.xml.getAllTextContent(node, false).replace(/^\s*|\s*$/g, '');
var flatCoordinates = goog.array.map(s.split(/\s+/), parseFloat);
var s = ol.xml.getAllTextContent(node, false);
var re = /^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*/;
/** @type {Array.<number>} */
var flatCoordinates = [];
var m;
while ((m = re.exec(s))) {
flatCoordinates.push(parseFloat(m[1]));
s = s.substr(m[0].length);
}
if (s !== '') {
return undefined;
}
var context = objectStack[0];
goog.asserts.assert(goog.isObject(context));
var containerSrs = goog.object.get(context, 'srsName');