Search code examples
openlayerscqlgeoserver

OpenLayers.Format.CQL fails when parsing after/before


I am trying to add a filter to my OpenLayers WMS layer

var format = new OpenLayers.Format.CQL();

var date = this.controls.UploadAfter.getValue();
    filterArray.push("upload_time after " + date.format("Y-m-d") + "T00:00:00"); 

Then i try to parse it

var filter;

try {
  filter = format.read(filterArray.join(" and ")); 
} catch (err) {
   alert("Filter cannot be parsed");
}

Error message:

"ERROR: In parsing: [after 2015-05-21T00:00:00], expected one of: ↵ COMPARISON: /^(=|<>|<=|<|>=|>|LIKE)/i↵ BETWEEN: /^BETWEEN/i↵ COMMA: /^,/↵ IS_NULL: /^IS NULL/i"

I guess this text suggest that I cant use the word after? I have tested this on my Geoserver and it works when I apply the parameter to the url, like this

..&cql_filter=origin_date after 2015-05-13T00:00:00

Solution

  • Found the answer here

    https://gis.stackexchange.com/questions/118182/how-to-run-a-temporal-query-on-a-csw-using-geonetwork

    use < and > instead. And remember to put ' around the date.