Test custom encodeLiteral function
This commit is contained in:
@@ -271,6 +271,35 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_custom_date_writing(t) {
|
||||||
|
t.plan(1);
|
||||||
|
|
||||||
|
// ISO 8601: 2010-11-27T18:19:15.123Z
|
||||||
|
var start = new Date(Date.UTC(2010, 10, 27, 18, 19, 15, 123));
|
||||||
|
|
||||||
|
// ISO 8601: 2011-12-27T18:19:15.123Z
|
||||||
|
var end = new Date(Date.UTC(2011, 11, 27, 18, 19, 15, 123));
|
||||||
|
|
||||||
|
var filter = new OpenLayers.Filter.Comparison({
|
||||||
|
type: OpenLayers.Filter.Comparison.BETWEEN,
|
||||||
|
property: "when",
|
||||||
|
lowerBoundary: start,
|
||||||
|
upperBoundary: end
|
||||||
|
});
|
||||||
|
|
||||||
|
var format = new OpenLayers.Format.Filter({
|
||||||
|
encodeLiteral: function(value) {
|
||||||
|
// return just the date and not the time portion
|
||||||
|
return OpenLayers.Date.toISOString(value).split("T").shift();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var got = format.write(filter);
|
||||||
|
var exp = readXML("CustomBetweenDates");
|
||||||
|
t.xml_eq(got, exp, "comparison filter with dates");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function readXML(id) {
|
function readXML(id) {
|
||||||
var xml = document.getElementById(id).firstChild.nodeValue;
|
var xml = document.getElementById(id).firstChild.nodeValue;
|
||||||
return new OpenLayers.Format.XML().read(xml).documentElement;
|
return new OpenLayers.Format.XML().read(xml).documentElement;
|
||||||
@@ -325,6 +354,19 @@
|
|||||||
</ogc:PropertyIsBetween>
|
</ogc:PropertyIsBetween>
|
||||||
</ogc:Filter>
|
</ogc:Filter>
|
||||||
--></div>
|
--></div>
|
||||||
|
<div id="CustomBetweenDates"><!--
|
||||||
|
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
|
||||||
|
<ogc:PropertyIsBetween>
|
||||||
|
<ogc:PropertyName>when</ogc:PropertyName>
|
||||||
|
<ogc:LowerBoundary>
|
||||||
|
<ogc:Literal>2010-11-27</ogc:Literal>
|
||||||
|
</ogc:LowerBoundary>
|
||||||
|
<ogc:UpperBoundary>
|
||||||
|
<ogc:Literal>2011-12-27</ogc:Literal>
|
||||||
|
</ogc:UpperBoundary>
|
||||||
|
</ogc:PropertyIsBetween>
|
||||||
|
</ogc:Filter>
|
||||||
|
--></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user