|
1 |
| -# CQL2-RS |
| 1 | +# cql2-rs |
2 | 2 |
|
3 |
| -## WORK IN PROGRESS, NOT READY FOR USE |
| 3 | +[](https://github.com/developmentseed/cql2-rs/actions/workflows/ci.yml) |
4 | 4 |
|
5 |
| -Parse, validate, and convert CQL2-Text and CQL2-JSON. |
| 5 | +Parse, validate, and convert [Common Query Language (CQL2)](https://www.ogc.org/standard/cql2/) text and JSON. |
6 | 6 |
|
7 |
| -## CLI |
| 7 | +## Usage |
8 | 8 |
|
9 |
| -At its simplest, the command-line interface (CLI) is a pass-through validator: |
| 9 | +### API |
10 | 10 |
|
11 |
| -```shell |
12 |
| -$ cql2 < tests/fixtures/text/example01.txt # will succeed if the CQL2 is valid |
13 |
| -("landsat:scene_id" = 'LC82030282019133LGN00') |
| 11 | +```toml |
| 12 | +[dependencies] |
| 13 | +cql = "0.1" |
14 | 14 | ```
|
15 | 15 |
|
16 |
| -You can convert formats: |
| 16 | +Then: |
17 | 17 |
|
18 |
| -```shell |
19 |
| -$ cql2 -o json < tests/fixtures/text/example01.txt |
20 |
| -{"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]} |
21 |
| -``` |
| 18 | +```rust |
| 19 | +use cql2::Expr; |
22 | 20 |
|
23 |
| -Use `-v` to get detailed validation information: |
24 |
| - |
25 |
| -```shell |
26 |
| -$ cql2 'wrong' -v |
27 |
| -[ERROR] Invalid CQL2: wrong |
28 |
| -For more detailed validation information, use -vv |
29 |
| -jsonschema validation failed with file:///tmp/cql2.json# |
30 |
| -- at '': oneOf failed, none matched |
31 |
| - - at '': missing properties 'op', 'args' |
32 |
| - - at '': missing properties 'op', 'args' |
33 |
| - - at '': oneOf failed, none matched |
34 |
| - - at '': missing properties 'op', 'args' |
35 |
| - - at '': missing properties 'op', 'args' |
36 |
| - - at '': missing properties 'op', 'args' |
37 |
| - - at '': missing properties 'op', 'args' |
38 |
| - - at '': missing properties 'op', 'args' |
39 |
| - - at '': missing properties 'op', 'args' |
40 |
| - - at '': missing properties 'op', 'args' |
41 |
| - - at '': missing properties 'op', 'args' |
42 |
| - - at '': missing properties 'op', 'args' |
43 |
| - - at '': want boolean, but got object |
| 21 | +let expr: Expr = "landsat:scene_id = 'LC82030282019133LGN00'".parse().unwrap(); |
| 22 | +assert!(expr.is_valid()); |
| 23 | +println!("{}", expr.to_json().unwrap()); |
44 | 24 | ```
|
45 | 25 |
|
46 |
| -cql2-text parsing errors are pretty-printed: |
47 |
| - |
48 |
| -```shell |
49 |
| -$ cql2 '(foo ~= "bar")' |
50 |
| -[ERROR] Parsing error: (foo ~= "bar") |
51 |
| - --> 1:6 |
52 |
| - | |
53 |
| -1 | (foo ~= "bar") |
54 |
| - | ^--- |
55 |
| - | |
56 |
| - = expected NotFlag, And, Or, ConcatInfixOp, Add, Subtract, Multiply, Divide, Modulo, Power, Eq, Gt, GtEq, Lt, LtEq, NotEq, Is, or IsNullPostfix |
57 |
| -``` |
| 26 | +See [the documentation](https://docs.rs/cql2) for more. |
| 27 | + |
| 28 | +## CLI |
58 | 29 |
|
59 |
| -Use `cql2 --help` to get a complete listing of the CLI arguments and formats. |
| 30 | +See [the cql-cli README](./cli/README.md) for details. |
60 | 31 |
|
61 |
| -## Response |
| 32 | +## Responses |
62 | 33 |
|
63 | 34 | Responses may not match the input.
|
64 | 35 |
|
65 |
| -### CQL2-Text Differences |
| 36 | +### cql2-text differences |
66 | 37 |
|
67 |
| -- all identifiers in output are double quoted |
68 |
| -- position of "NOT" keywords is standardized to be before the expression (ie "... NOT LIKE ..." will become "NOT ... LIKE ..." |
69 |
| -- The Negative operator on anything besides a literal number becomes "* -1" |
| 38 | +- All identifiers in output are double quoted |
| 39 | +- The position of "NOT" keywords is standardized to be before the expression (ie "... NOT LIKE ..." will become "NOT ... LIKE ..." |
| 40 | +- The negative operator on anything besides a literal number becomes "* -1" |
70 | 41 | - Parentheses are added around all expressions
|
71 | 42 |
|
72 |
| -Tasks to get to ready-to-use state: |
73 |
| -- [x] Parse all examples from CQL2 examples into json that passes json schema validation. |
74 |
| -- [x] Add tests that compare OGC examples to parsed/standardized/validated CQL2-Text and CQL2-JSON |
75 |
| -- [ ] Fix issues with Z, ZM, and M WKT variants |
| 43 | +## Development |
| 44 | + |
| 45 | +See [CONTRIBUTING.md](./CONTRIBUTING.md) for information about contributing to this project. |
| 46 | + |
| 47 | +## License |
| 48 | + |
| 49 | +**cql2-rs** is licensed under the MIT license. |
| 50 | +See [LICENSE](./LICENSE) for details. |
0 commit comments