Ticket #2522 (closed feature: fixed)

Opened 3 years ago

Last modified 2 years ago

Format.CQL for seralizing and deserializing filters

Reported by: tschaub Owned by: tschaub
Priority: minor Milestone: 2.11 Release
Component: Format.CQL Version: 2.8
Keywords: Cc:
State:

Description

To facilitate the creation of OpenLayers.Filter instances, a parser could be created that reads CQL (OGC Common Query Language). The same parser should write CQL given a filter.

CQL is defined as part of the OGC Catalog specification. Some references below:

Attachments

cql.patch Download (432 bytes) - added by dwinslow 2 years ago.
patch for CQL parsing
cql.2.patch Download (24.1 KB) - added by dwinslow 2 years ago.
patch including missing files from original
2522.patch Download (32.8 KB) - added by tschaub 2 years ago.
read and write cql

Change History

Changed 2 years ago by dwinslow

patch for CQL parsing

follow-up: ↓ 2   Changed 2 years ago by dwinslow

I've attached a patch which provides parsing/encoding for a subset of CQL syntax.

in reply to: ↑ 1 ; follow-up: ↓ 3   Changed 2 years ago by erilem

Replying to dwinslow:

I've attached a patch which provides parsing/encoding for a subset of CQL syntax.

Missing files in the patch (I hope).

in reply to: ↑ 2   Changed 2 years ago by dwinslow

Replying to erilem:

Replying to dwinslow:

I've attached a patch which provides parsing/encoding for a subset of CQL syntax.

Missing files in the patch (I hope).

Oops, sorry about that. Attaching a better patch shortly.

Changed 2 years ago by dwinslow

patch including missing files from original

  Changed 2 years ago by tschaub

  • status changed from new to assigned
  • state set to Review

Reviewing now.

  Changed 2 years ago by tschaub

This will make a really great addition. In reviewing, I've caught a few things and added tests. There is still one failing test. Here's what I've done so far:

  • removed trailing commas to get it to load in IE
  • added semicolons where appropriate (improves things with our limited compressor)
  • updated example to allow users to change CQL and see results
  • added CQL.js format to OpenLayers.js loader
  • added docs
  • made it so comparison filters are written with quoted strings only (numbers were quoted as well)
  • added write support for WITHIN, INTERSECTS, CONTAINS
  • replaced use of bracket notation with charAt for strings (the former doesn't work in IE and was causing infinite recursion)
  • made infinite recursion less likely in the balanced parentheses matcher for geometries
  • made it possible to use spatial filters in a logical filter - this required adding SPATIAL before PROPERTY to the list of follows for LOGICAL (tests pass, but this needs confirmation as the right thing to do)
  • made it so spatial filters store geometries instead of features

  Changed 2 years ago by tschaub

In adding write tests, I've gotten it so everything passes except for the writing the filter that results from "A = '1' AND (B = '2' OR C = '3')". Seems to me like we could go for the easy solution and wrap all subfilters or keep track of precedence within logical operators.

Changed 2 years ago by tschaub

read and write cql

  Changed 2 years ago by tschaub

Ok, latest patch avoids the logical operator precedence issue by wrapping all subfilters of a logical filter in parens when writing. Tests cover this.

  Changed 2 years ago by tschaub

  • state changed from Review to Commit

Ok, with tests passing and examples working in IE 6, FF 3, and Chrome 9, I think this is good to go. This dramatically simplifies filter creation and I hope it gets heavy use. It will also make a nice alternative filterToParams method for the HTTP protocol (see #3032).

Thanks dwins for the great contribution.

  Changed 2 years ago by tschaub

  • status changed from assigned to closed
  • resolution set to fixed
  • state Commit deleted
  • component changed from Format to Format.CQL

In w/ r11065.

Note: See TracTickets for help on using tickets.