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
+2 -3
View File
@@ -64,9 +64,8 @@ ol.style.Fill.prototype.createLiteral = function(featureOrType) {
goog.asserts.assertString(
color, 'color must be a string');
var opacity = ol.expr.evaluateFeature(this.opacity_, feature);
goog.asserts.assertNumber(
opacity, 'color must be a number');
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
literal = new ol.style.PolygonLiteral({
fillColor: color,