Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the CQL implementation #432

Closed
cportele opened this issue Apr 27, 2021 · 3 comments · Fixed by #579
Closed

update the CQL implementation #432

cportele opened this issue Apr 27, 2021 · 3 comments · Fixed by #579
Assignees
Milestone

Comments

@cportele
Copy link
Member

cportele commented Apr 27, 2021

The CQL implementations need to be updated to the latest draft (CQL2), which should soon become a release candidate.

https://docs.ogc.org/DRAFTS/19-079r1.html

There is also the following PR for case/accent insensistive string comparisons (CASEI and ACCENTI functions, opengeospatial/ogcapi-features#641) that needs to be taken into account.

The first step will be a comparison of the current implementation and the updated specification to identify which changes are needed. This issue has to be updated with the analysis.

The second step will be the implementation.

@cportele cportele added this to the 3.x.0 milestone May 5, 2021
@cportele cportele changed the title Limitations of the CQL implementation Updating the CQL implementation Dec 13, 2021
@bekakh bekakh self-assigned this Dec 13, 2021
@bekakh
Copy link
Contributor

bekakh commented Dec 15, 2021

List of changes compared to the current implementation:

Temporal geometry literals (instants, CQL-Text)

Current:

1969-07-20
1969-07-20T20:17:40Z

CQL2:

DATE('1969-07-20')
TIMESTAMP('1969-07-20T20:17:40Z')

Temporal geometry literals (instants, CQL-JSON)

Current:

"1969-07-20"
"1969-07-20T20:17:40Z"

CQL2:

{ "date": "1969-07-20" }
{ "timestamp": "1969-07-20T20:17:40Z" }

Temporal geometry literals (intervals, CQL-Text)

Current:

1969-07-16/1969-07-24
1969-07-16T05:32:00Z/1969-07-24T16:50:35Z
2019-09-09/..

CQL2:

INTERVAL('1969-07-16', '1969-07-24')
INTERVAL('1969-07-16T05:32:00Z', '1969-07-24T16:50:35Z')
INTERVAL('2019-09-09', '..')

Temporal geometry literals (intervals, CQL-JSON)

Current:

[ "1969-07-16", "1969-07-24" ]
[ "1969-07-16T05:32:00Z", "1969-07-24T16:50:35Z" ]
[ "2019-09-09", ".." ]

CQL2:

{ "interval": [ "1969-07-16", "1969-07-24" ] }
{ "interval": [ "1969-07-16T05:32:00Z", "1969-07-24T16:50:35Z" ] }
{ "interval": [ "2019-09-09", ".." ] }

New CQL-JSON structure

CQL text: city='Toronto'

Current:

{ "eq": [ { "property": "city" }, "Toronto" ] }

CQL2:

{
  "op": "=",
  "args": [
    { "property": "city" },
    "Toronto" ]
}

Spatial predicates

Spatial predicate names are now prefixed with S_.

Current:

INTERSECTS(geometry,POLYGON((36.319836 32.288087,36.320041 32.288032,36.320210 32.288402,36.320008 32.288458,36.319836 32.288087)))

CQL2:

S_INTERSECTS(geometry,POLYGON((36.319836 32.288087,36.320041 32.288032,36.320210 32.288402,36.320008 32.288458,36.319836 32.288087)))

Temporal predicates

  • Temporal predicate names are now prefixed with T_, new CQL-Text syntax similar to spatial predicates.
  • The required temporal predicate ANYINTERACTS no longer exists.
  • Temporal predicates BEGINS, BEGUNBY, ENDS, ENDEDBY were renamed to T_STARTS, T_STARTEDBY, T_FINISHES, T_FINISHEDBY respectively.
  • New temporal predicates: T_DISJOINT, T_INTERSECTS, T_MEETS, T_METBY

Current:

touchdown DURING 1969-07-16T13:32:00Z/1969-07-24T16:50:35Z

CQL2:

T_DURING(touchdown, INTERVAL("1969-07-16T13:32:00Z", "1969-07-24T16:50:35Z"))

Array predicates

Array predicate names are now prefixed with A_, new CQL-Text syntax similar to spatial predicates.

Current:

layer:ids ACONTAINS ["layers-ca","layers-us"]

CQL2:

A_CONTAINS(layer:ids, ["layers-ca","layers-us"])

CASEI and ACCENTI functions

New functions CASEI and ACCENTI for case-insensitive and accent-insensitive matching.

CQL2-Text:

CASEI(road_class) IN (CASEI('Οδος'), CASEI('Straße'))

CQL2-JSON:

{
  "op": "in",
  "args": [
    { "function": { "name": "casei", "args": ["road_class"] } },
    [
      { "function": { "name": "casei", "args": ["Οδος"] } },
      { "function": { "name": "casei", "args": ["Straße"] } }
    ]
  ]
}

Additional changes from the BNF rules:

  • Boolean literal values are now limited to just "TRUE" or "FALSE" (current implementation already conforms to this).
  • Scalar expressions now include instant literals.
  • LIKE operator modifiers (WILDCARD, NOCASE, SINGLECHAR, ESCAPECHAR) no longer exist.
  • IN list operands only allow scalar expressions.
  • Character literals no longer include binary or hexadecimal strings.

Not included in the analysis:

  • Custom functions.
  • Arithmetic operations.

@bekakh
Copy link
Contributor

bekakh commented Dec 20, 2021

@cportele - A few questions/remarks that I have for the CQL2 draft document:

  • Second half of Example 7 seems to be outdated.
  • inListOperand is not defined in the CQL2 BNF.
  • utcTime no longer has a timezone offset. Not sure if it is intentional or not.
  • Are boolean literal values "TRUE" and "FALSE" supposed to be case sensitive?

@cportele
Copy link
Member Author

Thanks, I have created a PR: opengeospatial/ogcapi-features#659

Second half of Example 7 seems to be outdated.

Yes, the JSON is outdated (the Text example is correct).

inListOperand is not defined in the CQL2 BNF.

Yes, that is an error. inListOperand needs to be replaced by scalarExpression.

utcTime no longer has a timezone offset. Not sure if it is intentional or not.

There is a timezone (utcTime = timeHour ":" timeMinute ":" timeSecond "Z"), it is now fixed to "Z" (UTC).

Are boolean literal values "TRUE" and "FALSE" supposed to be case sensitive?

No, BNF is case-insensitive.

@bekakh bekakh mentioned this issue Jan 14, 2022
5 tasks
@cportele cportele assigned cportele and unassigned bekakh Feb 7, 2022
@cportele cportele linked a pull request Feb 7, 2022 that will close this issue
5 tasks
@cportele cportele modified the milestones: 3.x.0, 3.2.0 Feb 7, 2022
@cportele cportele mentioned this issue Feb 8, 2022
4 tasks
@azahnen azahnen changed the title Updating the CQL implementation update the CQL implementation Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants