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

Add CQL fillter and filter-crs query parameters #130

Merged
merged 2 commits into from
Mar 4, 2022

Conversation

dr-jts
Copy link
Collaborator

@dr-jts dr-jts commented Mar 4, 2022

This PR adds query parameters filter and filter-crs, with filters expressed in the CQL text language.

Note: the CQL language parser is a direct copy from pg_featureserv. Ideally these will be kept in synch going forward.

CQL Support

CQL expressions supported are:

  • property names (id, name)
  • character literals ('foo', 'A text value')
  • numeric literals ( 12, 98.678)
  • arithmetic operators +,-,*,/ and % (modulo).
    • Subexpressions can be parenthesized to express evaluation order.
  • binary comparisons (<,<=,>,>=,=,<>)
  • property [NOT] BETWEEN a AND B
  • property [NOT] IN ( value-list )
  • property [NOT] (LIKE | ILIKE) pattern
    • pattern can include % wildcards
  • property [NOT] IS NULL
  • boolean combinations (AND,OR,NOT and (...))

Geometry Literals

POINT (1 2)
LINESTRING (0 0, 1 1)
POLYGON ((0 0, 0 9, 9 0, 0 0))
POLYGON ((0 0, 0 9, 9 0, 0 0),(1 1, 1 8, 8 1, 1 1))
MULTIPOINT ((0 0), (0 9))
MULTILINESTRING ((0 0, 1 1),(1 1, 2 2))
MULTIPOLYGON (((1 4, 4 1, 1 1, 1 4)), ((1 9, 4 9, 1 6, 1 9)))
GEOMETRYCOLLECTION (POLYGON((1 4, 4 1, 1 1, 1 4)), LINESTRING (3 3, 5 5), POINT (1 5))
ENVELOPE (1, 2, 3, 4)

Spatial Predicates

  • INTERSECTS - tests whether two geometries intersect
  • DISJOINT - tests whether two geometries have no points in common
  • CONTAINS - tests whether a geometry contains another
  • WITHIN - tests whether a geometry is within another
  • EQUALS - tests whether two geometries are topologically equal
  • CROSSES - tests whether the geometries cross
  • OVERLAPS - tests whether the geometries overlap
  • TOUCHES - tests whether the geometries touch
  • DWITHIN - tests whether two geometries are within a given distance

Examples

https://localhost:7801/public.geonames.html?filter=type=%27LK%27

https://localhost:7801/ne.admin_0_countries.html?filter=pop_est%20%3C%202000000%20AND%20continent%20=%20%27Europe%27

https://localhost:7801/ebc.voting_area.html?filter=DWITHIN(geom,POINT(1000000%20400000),60000)&filter-crs=3005

Not included (yet)

  • Temporal filters
  • Documentation (can be copied from pg_featureserv)
  • Multi-layer requests

@dr-jts dr-jts added the enhancement New feature or request label Mar 4, 2022
@dr-jts dr-jts requested a review from pramsey March 4, 2022 20:52
@pramsey pramsey merged commit f9744cc into CrunchyData:master Mar 4, 2022
@dr-jts dr-jts mentioned this pull request Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants