Merge pull request #1542 from twpayne/vector-api-kml-clean-ups

[vector-api] ol.source.KML clean-ups
This commit is contained in:
Tom Payne
2014-01-16 11:50:36 -08:00
3 changed files with 7 additions and 12 deletions

View File

@@ -41,7 +41,7 @@ var displayFeatureInfo = function(pixel) {
for (i = 0, ii = features.length; i < ii; ++i) {
info.push(features[i].get('name'));
}
document.getElementById('info').innerHTML = info.join(', ') || '(unkown)';
document.getElementById('info').innerHTML = info.join(', ') || '(unknown)';
map.getTarget().style.cursor = 'pointer';
} else {
document.getElementById('info').innerHTML = '&nbsp;';

View File

@@ -270,8 +270,6 @@
* @typedef {Object} olx.format.KMLOptions
* @property {Array.<ol.style.Style>|undefined} defaultStyle Default style. The default
* default style is the same as Google Earth.
* @property {boolean|undefined} extractAttributes Extract attributes.
* @property {boolean|undefined} extractStyles Extract styles.
*/
/**

View File

@@ -1,8 +1,6 @@
// FIXME add Styles with ids to sharedStyles_
// FIXME refactor StyleMap handling
// FIXME handle highlighted keys in StyleMaps - use styleFunctions
// FIXME extractAttributes
// FIXME extractStyles
// FIXME http://earth.google.com/kml/1.0 namespace?
// FIXME why does node.getAttribute return an unknown type?
// FIXME text
@@ -365,7 +363,7 @@ ol.format.KML.readFlatCoordinates_ = function(node) {
// The KML specification states that coordinate tuples should not include
// spaces, but we tolerate them.
var re =
/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*,\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)(?:\s*,\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?))?\s*/i;
/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*,\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s*,\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?))?\s*/i;
var m;
while ((m = re.exec(s))) {
var x = parseFloat(m[1]);
@@ -388,7 +386,7 @@ ol.format.KML.readFlatCoordinates_ = function(node) {
*/
ol.format.KML.readNumber_ = function(node) {
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 {
@@ -1157,16 +1155,15 @@ 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 date = new Date(year, month, day, hour, minute, second, 0);
var t = date.getTime() / 1000;
var when = Date.UTC(year, month, day, hour, minute, second, 0);
if (m[7] != 'Z') {
var sign = m[8] == '-' ? -1 : 1;
t += sign * 60 * parseInt(m[9], 10);
when += sign * 60 * parseInt(m[9], 10);
if (goog.isDef(m[10])) {
t += sign * 60 * 60 * parseInt(m[10], 10);
when += sign * 60 * 60 * parseInt(m[10], 10);
}
}
whens.push(t);
whens.push(when);
} else {
whens.push(0);
}