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

View File

@@ -64,6 +64,23 @@ describe('ol.style.Fill', function() {
expect(literal.fillOpacity).to.be(0.8);
});
it('casts opacity to number', function() {
var symbolizer = new ol.style.Fill({
opacity: ol.expr.parse('opacity'),
color: '#ff00ff'
});
var feature = new ol.Feature({
opacity: '0.55',
geometry: new ol.geom.Polygon(
[[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]])
});
var literal = symbolizer.createLiteral(feature);
expect(literal).to.be.a(ol.style.PolygonLiteral);
expect(literal.fillOpacity).to.be(0.55);
});
});
describe('#getColor()', function() {