Cast to numbers for literals

There are times when we parse from XML without a schema (e.g. KML).  In these cases, features attributes will always be strings.  We can cast to number when creating literals from symbolizers and then assert `!isNaN` instead of asserting that they are numbers before.
This commit is contained in:
Tim Schaub
2013-08-23 17:30:24 -04:00
parent 43953c8efa
commit 3c993168c4
9 changed files with 233 additions and 37 deletions
+4 -4
View File
@@ -84,14 +84,14 @@ ol.style.Text.prototype.createLiteral = function(featureOrType) {
var fontFamily = ol.expr.evaluateFeature(this.fontFamily_, feature);
goog.asserts.assertString(fontFamily, 'fontFamily must be a string');
var fontSize = ol.expr.evaluateFeature(this.fontSize_, feature);
goog.asserts.assertNumber(fontSize, 'fontSize must be a number');
var fontSize = Number(ol.expr.evaluateFeature(this.fontSize_, feature));
goog.asserts.assert(!isNaN(fontSize), 'fontSize must be a number');
var text = ol.expr.evaluateFeature(this.text_, feature);
goog.asserts.assertString(text, 'text must be a string');
var opacity = ol.expr.evaluateFeature(this.opacity_, feature);
goog.asserts.assertNumber(opacity, 'opacity must be a number');
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
return new ol.style.TextLiteral({
color: color,