Parse distance as a number
This commit is contained in:
@@ -234,7 +234,8 @@ ol.parser.ogc.Filter_v1 = function() {
|
|||||||
ol.expr.functions.DWITHIN);
|
ol.expr.functions.DWITHIN);
|
||||||
},
|
},
|
||||||
'Distance': function(node, obj) {
|
'Distance': function(node, obj) {
|
||||||
obj.distance = new ol.expr.Literal(this.getChildValue(node));
|
var value = goog.string.toNumber(this.getChildValue(node));
|
||||||
|
obj.distance = new ol.expr.Literal(value);
|
||||||
obj.distanceUnits = new ol.expr.Literal(node.getAttribute('units'));
|
obj.distanceUnits = new ol.expr.Literal(node.getAttribute('units'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,27 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reads DWithin', function(done) {
|
||||||
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/dwithin.xml';
|
||||||
|
afterLoadXml(url, function(xml) {
|
||||||
|
var filter = parser.read(xml);
|
||||||
|
expect(filter).to.be.a(ol.expr.Call);
|
||||||
|
var callee = filter.getCallee();
|
||||||
|
expect(callee).to.be.a(ol.expr.Identifier);
|
||||||
|
var name = callee.getName();
|
||||||
|
expect(name).to.equal(ol.expr.functions.DWITHIN);
|
||||||
|
var args = filter.getArgs();
|
||||||
|
expect(args.length).to.equal(5);
|
||||||
|
var distance = args[1];
|
||||||
|
expect(distance).to.be.a(ol.expr.Literal);
|
||||||
|
expect(distance.getValue()).to.equal(1000);
|
||||||
|
var units = args[2];
|
||||||
|
expect(units).to.be.a(ol.expr.Literal);
|
||||||
|
expect(units.getValue()).to.equal('m');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('DWithin written correctly', function(done) {
|
it('DWithin written correctly', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/dwithin.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/dwithin.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
|
|||||||
Reference in New Issue
Block a user