Logo
  • Home

Tutorials

  • Translate your first filter

How-to guides

  • Search the catalogue
  • Convert responses
  • Develop and preview documentation

Reference

  • Python API
  • Operators
  • Attributes
  • CLI
  • OData-STAC crosswalk
  • Container builds
  • Example notebooks
    • pygeofilter CDSE OData support for CQL2
    • Supported Comparison operators
    • Spatial operators
    • Temporal operators

Explanation

  • Translation and conversion
pygeofilter CDSE OData support for CQL2
  • Reference
  • Example notebooks
  • Temporal operators
  • Edit on Terradue/pygeofilter-odata-cdse

Description CQL2 Operator Resulting OData Operator
The subject is a temporal entity that occurs after the object t_after gt
The subject is a temporal entity that occurs before the object t_before lt
Beginning of a temporal entity. t_begins ge
End of a temporal entity. t_ends le
In [1]:
Copied!
from pygeocdse.evaluator import to_cdse

cql2_filter = {
    "op": "and",
    "args": [
        {
            "op": "t_after",
            "args": [
                {"property": "ContentDate/Start"},
                {"timestamp": "2023-02-01T00:00:00Z"}
            ],
        },
        {
            "op": "t_before",
            "args": [
                {"property": "ContentDate/Start"},
                {"timestamp": "2023-02-28T23:59:59Z"}
            ],
        },
    ],
}

print(to_cdse(cql2_filter))
from pygeocdse.evaluator import to_cdse cql2_filter = { "op": "and", "args": [ { "op": "t_after", "args": [ {"property": "ContentDate/Start"}, {"timestamp": "2023-02-01T00:00:00Z"} ], }, { "op": "t_before", "args": [ {"property": "ContentDate/Start"}, {"timestamp": "2023-02-28T23:59:59Z"} ], }, ], } print(to_cdse(cql2_filter))
ContentDate/Start gt 2023-02-01T00:00:00+00:00 and ContentDate/Start lt 2023-02-28T23:59:59+00:00

Please take note that the ISO format for dates in OData are internally handled, so users can express dates in CQL2 supported formats.

Intervals¶

Intervals apply to one property. t_after excludes the lower bound; t_before excludes the upper bound. t_begins and t_ends include both bounds. See operator reference.

In [2]:
Copied!
from pygeocdse.evaluator import to_cdse

cql2_filter = {
    "op": "and",
    "args": [
        {
            "op": "t_after",
            "args": [
                {"property": "ContentDate/Start"},
                {"interval": ["2023-02-01T00:00:00Z", "2023-02-01T23:59:59Z"]},
            ],
        },
        {
            "op": "t_before",
            "args": [
                {"property": "ContentDate/End"},
                {"interval": ["2023-02-28T00:00:00Z", "2023-02-28T23:59:59Z"]}
            ],
        },
    ]
}

print(to_cdse(cql2_filter))
from pygeocdse.evaluator import to_cdse cql2_filter = { "op": "and", "args": [ { "op": "t_after", "args": [ {"property": "ContentDate/Start"}, {"interval": ["2023-02-01T00:00:00Z", "2023-02-01T23:59:59Z"]}, ], }, { "op": "t_before", "args": [ {"property": "ContentDate/End"}, {"interval": ["2023-02-28T00:00:00Z", "2023-02-28T23:59:59Z"]} ], }, ] } print(to_cdse(cql2_filter))
ContentDate/Start gt 2023-02-01T00:00:00+00:00 and ContentDate/Start le 2023-02-01T23:59:59+00:00 and ContentDate/End ge 2023-02-28T00:00:00+00:00 and ContentDate/End lt 2023-02-28T23:59:59+00:00

Time deltas¶

ISO 8601 duration format is supported inside Time intervals, the interpreter will take care of converting datetimes.

A duration can be used as the end parameter of the interval:

In [3]:
Copied!
from pygeocdse.evaluator import to_cdse

cql2_filter = {
    "op": "t_after",
    "args": [
        {"property": "ContentDate/Start"},
        {"interval": ["2023-02-28T00:00:00Z", "PT4S"]},
    ],
}

print(to_cdse(cql2_filter))
from pygeocdse.evaluator import to_cdse cql2_filter = { "op": "t_after", "args": [ {"property": "ContentDate/Start"}, {"interval": ["2023-02-28T00:00:00Z", "PT4S"]}, ], } print(to_cdse(cql2_filter))
ContentDate/Start gt 2023-02-28T00:00:00+00:00 and ContentDate/Start le 2023-02-28T00:00:04+00:00

And in the start parameter of the interval:

In [4]:
Copied!
from pygeocdse.evaluator import to_cdse

cql2_filter = {
    "op": "t_after",
    "args": [
        {"property": "ContentDate/Start"},
        {"interval": ["PT4S", "2023-02-28T00:00:00Z"]},
    ],
}

print(to_cdse(cql2_filter))
from pygeocdse.evaluator import to_cdse cql2_filter = { "op": "t_after", "args": [ {"property": "ContentDate/Start"}, {"interval": ["PT4S", "2023-02-28T00:00:00Z"]}, ], } print(to_cdse(cql2_filter))
ContentDate/Start gt 2023-02-27T23:59:56+00:00 and ContentDate/Start le 2023-02-28T00:00:00+00:00
Previous Next

Apache License, Version 2.0

Built with MkDocs using a theme provided by Read the Docs.
Terradue/pygeofilter-odata-cdse « Previous Next »