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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user