5 releases (3 breaking)
| 0.4.1 | Sep 12, 2025 |
|---|---|
| 0.3.1 | Jun 17, 2024 |
| 0.3.0 | Apr 18, 2024 |
| 0.2.0 | Feb 9, 2024 |
| 0.1.0 | Feb 7, 2024 |
#129 in WebAssembly
73KB
1.5K
SLoC
cjseq
cjseq is a Rust libray+binary for creating, processing, and modifying CityJSONSeq files, as well as converting to/from CityJSON.
Installation
Installing the binary
- Install the Rust compiler
- Run
cargo install cjseq - Then a binary called
cjseqis installed system-wide
Installing the library
- Install the Rust compiler
- Run
cargo install cjseq
Compiling the project
- Install the Rust compiler
- Clone the repository:
git clone https://github.com/cityjson/cjseq.git - Build the project:
cargo build --release - Run the program:
./target/release/cjseq --help
Usage
cjseq takes input from either a file or the standard input (stdin, if no file path is given as argument), and it always outputs the results to the standard output (stdout).
The output can be a CityJSON object or a CityJSONSeq stream.
Convert CityJSON to CityJSONSeq
The operator "cat" converts a CityJSON file to a CityJSONSeq stream:
cjseq cat myfile.city.json > myfile.city.jsonl
Alternatively, to use stdin as input:
cat myfile.city.json | cjseq cat
Convert CityJSONSeq to CityJSON
The operator "collect" converts a CityJSONSeq stream to a CityJSON file:
cat ./data/3dbag_b2.city.jsonl | cjseq collect > 3dbag_b2.city.json
cjseq collect ./data/3dbag_b2.city.jsonl > 3dbag_b2.city.json
Notice that globbing works for the collect command:
cat ./data/*.city.jsonl | cjseq collect > hugefile.city.json
Filter CityJSONSeq
An input stream of CityJSONSeq can be filtered with the following operators:
--bbox <minx> <miny> <maxx> <maxy>
Bounding box filter
--cotype <COTYPE>
Keep only the CityObjects of this type
--exclude
Excludes the selection, thus remove the selected city object(s)
--radius <x> <y> <radius>
Circle filter: centre + radius
--random <X>
1/X chances of a given feature being kept
As an example:
cat myfile.city.jsonl | cjseq filter --bbox 85007 446179 85168 446290 > mysubset.city.jsonl
Input constraints
- the input CityJSON/Seq must be v1.1 or v2.0 (v1.0 will panic).
- the input JSON must be CityJSON schema-valid, use cjval to validate.
WASM bindings
cjseq can be used in JavaScript/TypeScript applications via WASM bindings.
cargo install wasm-pack
Build the WASM bindings:
wasm-pack build --release --target web --out-dir js
Dependencies
~9–12MB
~219K SLoC