cityjson-index
Index CityJSON datasets with a persistent SQLite sidecar. cityjson-index is the Rust crate; cjindex is the CLI.
Problem
CityJSON datasets are often large, awkward to scan repeatedly, and split across storage layouts that make ad hoc testing expensive.
This crate gives you a consistent indexing layer so you can:
- inspect dataset layout and freshness
- reindex changed data
- fetch features by identifier
- query features by bounding box
- read regular CityJSON, CityJSONSeq / NDJSON, and feature-file datasets through the same API
What It Does
cityjson-index aims to be a small, predictable indexing layer for CityJSON data:
- builds or refreshes a
.cityjson-index.sqlitesidecar - tracks indexed source and feature metadata
- reconstructs CityJSON feature payloads on read
- exposes a CLI for dataset inspection, querying, and retrieval
Install
Library
[]
= "0.3.0"
CLI
Or run it from a checkout:
Usage
As a Library
The main entry points are:
cityjson_index::CityIndexcityjson_index::resolve_datasetcityjson_index::StorageLayout
Example:
use Path;
use ;
let resolved = resolve_dataset?;
let index = open?;
let status = index.status?;
assert!;
# Ok::
As a CLI
The CLI is dataset-oriented:
Useful patterns:
inspectreports detected layout, freshness, and coveragevalidateexits non-zero when the index is missing, stale, or out of syncgetandqueryemit a line-oriented CityJSON stream
Explicit low-level mode is still available when you want to specify the layout directly:
Storage Layouts
CityJSONSeq / NDJSON
Each .city.jsonl file begins with metadata, followed by one feature per line. The index stores byte offsets for each feature line.
CityJSON
Regular CityJSON files share a vertices array and a CityObjects dictionary. The index stores the feature package ranges and reconstructs the requested model on read.
Feature Files
Each feature lives in its own file. Metadata is discovered through ancestor .json files and cached in the SQLite index.
Development
This repository includes helper binaries and benchmarks under src/bin/ and benches/.
They are gated behind the dev-binaries feature so the published CLI stays focused on cjindex.
Useful local commands:
just prep-test-data and just bench-release require the dev-binaries feature.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Contributing
Contributions are welcome.
Please keep changes focused, add tests when behavior changes, and run just ci before opening a pull request.