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

#9285 support for CQL function parsing and XML conversion #9300

Merged
merged 6 commits into from
Jul 31, 2023

Conversation

offtherailz
Copy link
Member

@offtherailz offtherailz commented Jul 26, 2023

Description

This PR introduce the capabilities to parse:

  • CQL filter functions
  • WKT geometries
  • Improves conversion from CQL to OGC XML filter supporting functions and geometries.

This PR allows additional tools like panels injected in the filter panel, to support advanced filtering functionalities. In particular it has been developed to support jsonArrayContains and jsonPointer.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?

Actually parsing CQL do not support WKT and functions.

What is the new behavior?

Fix #9285, introducing the support for parsing CQL functions, WKT and to convert these into XML OGC filters.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

This is an code only change. No new UI test needs to be added.

@offtherailz offtherailz added this to the 2023.02.00 milestone Jul 26, 2023
@offtherailz offtherailz self-assigned this Jul 26, 2023
@offtherailz offtherailz changed the title #9265 support for CQL function parsing and XML conversion #9285 support for CQL function parsing and XML conversion Jul 26, 2023
@offtherailz offtherailz requested a review from MV88 July 26, 2023 16:06
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

just a few things

throw new Error("WKT parsing for CQL filter not supported yet");
}; // TODO: use wkt-parser
const spatialOperators = {
import {toGeoJSON} from '../../WKT';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be changed to toGeoJSONGeometry

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a correct name. WKT provides only syntax for geometries, so it is implicit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree and at this point is pointless discuss further so I'm going to approve it as you did.


/**
* Parse a CQL filter. returns an AST object representation of the filter.
* For the moment this parser doesn't support WKT parsing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed or edited?

Suggested change
* For the moment this parser doesn't support WKT parsing.
* For the moment this parser doesn't support WKT parsing.

if (includes(logical, type)) {
return filterBuilder[type](
...filters.map(fromObject(filterBuilder))
);
}
if (includes(cql, type)) {
return "";
return ""; // TODO: implement in filterBuilder as empty filter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include and Exclude are only part of CQL/ECQL of geoserver. They do not have a proper equivalent in OGC filters.
This is a suggestion for a future implementation of emptyFilter in filterBuilder, equivalent to the "include" cql filter

@@ -0,0 +1,144 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyrights

@@ -0,0 +1,74 @@
import expect from 'expect';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyrights

@@ -0,0 +1,144 @@

const parsePoint = (coordinates) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add jsdoc for these functions

@offtherailz offtherailz requested a review from MV88 July 31, 2023 09:34
@@ -81,6 +125,13 @@ const parseMultiPolygon = (coordinates) => {
};
};
let toGeoJSON;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is a let and not exported as const ?

throw new Error("WKT parsing for CQL filter not supported yet");
}; // TODO: use wkt-parser
const spatialOperators = {
import {toGeoJSON} from '../../WKT';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree and at this point is pointless discuss further so I'm going to approve it as you did.

Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why toGeoJSON is a let and not exported as const?

can this be changed?

@offtherailz
Copy link
Member Author

@MV88 toGeoJSON is required by the function to transform parseGeometryCollection and vice-versa.
So the function have to be defined before the other. Anyway I don't see the problem. const make sense inside the module.
They are not "exported as const" or "exported as let".

https://stackoverflow.com/questions/32558514/javascript-es6-export-const-vs-export-let

@offtherailz offtherailz requested a review from MV88 July 31, 2023 10:18
@MV88 MV88 merged commit 359f7d2 into geosolutions-it:master Jul 31, 2023
@MV88
Copy link
Contributor

MV88 commented Jul 31, 2023

@ElenaGallo please test in DEV

@offtherailz
Copy link
Member Author

No additional UI test needed for this PR. Only existing test for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for functions in CQL filter parser and OGC XML conversion
2 participants