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
+6 -6
View File
@@ -71,13 +71,13 @@ ol.style.Stroke.prototype.createLiteral = function(featureOrType) {
this.color_, feature);
goog.asserts.assertString(color, 'color 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');
var width = ol.expr.evaluateFeature(
this.width_, feature);
goog.asserts.assertNumber(width, 'width must be a number');
var width = Number(ol.expr.evaluateFeature(
this.width_, feature));
goog.asserts.assert(!isNaN(width), 'width must be a number');
var literal = null;
if (type === ol.geom.GeometryType.LINESTRING ||