Skip to content

cql2-rs

cql2-rs is Python package, command-line interface (CLI), and Rust crate for parsing, validating, and converting Common Query Language (CQL2).

Python

>>> from cql2 import Expr
>>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
>>> expr.to_json()
{'op': '=', 'args': [{'property': 'landsat:scene_id'}, 'LC82030282019133LGN00']}

Javascript

> import init, { Expr } from 'cql2-wasm';
> await init();  // the published package is a `--target web` build
> const expr = new Expr("landsat:scene_id = 'LC82030282019133LGN00'");
> expr.to_json()  // a JSON string, not an object
'{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}'

CLI

$ cql2 < examples/text/example01.txt # will succeed if the CQL2 is valid
landsat:scene_id = 'LC82030282019133LGN00'

Rust

use cql2::Expr;
let expr: Expr = "landsat:scene_id = 'LC82030282019133LGN00'".parse().unwrap();
let json = expr.to_json().unwrap();