FlatCityBuf CLI
A command-line interface for converting between CityJSON and FlatCityBuf (FCB) formats, with support for spatial and attribute indexing.
Installation
Option 1: Install from crates.io (Recommended)
This installs the fcb binary to your Cargo bin directory (usually ~/.cargo/bin/).
Option 2: Build from Source
# Clone the repository
# Build in release mode
Option 3: Run with Cargo (Development)
# Example: convert CityJSONSeq to FCB
Usage
Input and output are positional: the input comes first, the output second. The
read-only command inspect takes a single positional argument.
Commands
ser - Serialize CityJSON to FCB
Convert CityJSON files to FlatCityBuf format with optional indexing.
Arguments:
<INPUT>...- Input file(s) or glob patterns (supports multiple files; each path must end in.jsonor.jsonl--serdoes not read from stdin)<OUTPUT>- Output file, always the last positional (use '-' for stdout)
Options:
-a, --attr-index ATTRIBUTES- Comma-separated list of attributes to create index for-A, --index-all-attributes- Index all attributes found in the dataset-s, --no-spatial-index- Disable the spatial index (it is written by default)--attr-branching-factor FACTOR- Branching factor for attribute index (default: 16 with--attr-index, 256 with--index-all-attributes)--index-node-size SIZE- Node size of the spatial R-tree index (default: 16)--no-feature-count- Write afeatures_countof 0, meaning "unknown", which forces readers to scan to EOF (conformance fixtures only)-b, --bbox BBOX- Bounding box filter in format "minx,miny,maxx,maxy"-g, --ge- Automatically calculate and set geospatial extent in header
Examples:
# basic conversion from CityJSONSeq
# convert CityJSON file (standard .json format)
# multiple input files -- the last positional is the output
# glob patterns to process all matching files
# with attribute indexing
# index all attributes
# with bounding box filter
# to stdout (input must still be a real file path)
deser - Deserialize FCB to CityJSON
Convert FlatCityBuf files back to CityJSON format.
Arguments:
<INPUT>- Input FCB file (use '-' for stdin)<OUTPUT>- Output file (use '-' for stdout)
Examples:
# basic conversion
# from stdin to stdout
|
inspect - Inspect an FCB file
Show what an FCB dataset's header declares, either in a full-screen terminal UI or as a static text report. Only the header is read -- feature bytes are never fetched -- so inspecting a remote file over HTTP range requests costs a couple of small requests regardless of dataset size.
Arguments:
<SOURCE>- Local path or HTTP(S) URL to an FCB file
Options:
--static- print the static report instead of the terminal UI
Output mode: with stdout on a terminal you get the interactive UI; with
stdout piped or redirected inspect prints the static report and exits 0.
--static forces the report even on a terminal, which is what scripts and the
just inspect recipe use.
The static report includes:
- Source (the path or URL) and file size (remote sources report
unknown) - CityJSON version, title, identifier and reference date, when present
- Feature count and number of attribute columns
- Geographical extent (min/max and dimensions), when set
- Index summary: whether a spatial R-tree is present and its node size, plus the names of the indexed attributes
- Coordinate reference system (code, version, code string), when set
- Coordinate transform (scale and translate), when present
Tabs (terminal UI):
- Metadata - version, feature count, index sizes, extent, transform, CRS
- Columns - the header attribute schema, one row per column
- Map - the dataset extent drawn on a world map; shown only for a geographic CRS, otherwise the projected extent is printed instead
Key bindings:
q,Esc,Ctrl-C- quitTab,→,l- next tabShift-Tab,←,h- previous tab↓,j/↑,k- scroll the column listg/G- jump to the first / last column
Examples:
# local file
# remote file over HTTP range requests -- only the header is fetched
# static report, for scripts and captured output
No terminal, no problem. The terminal UI needs an interactive TTY, so with stdout redirected or piped
inspectfalls back to the static report and exits 0. Pass--staticto get that same report on a terminal; both paths print byte-identical, colour-free text.
cbor - Convert CityJSON to CBOR
Convert CityJSON to Concise Binary Object Representation format.
bson - Convert CityJSON to BSON
Convert CityJSON to Binary JSON format.
Format Support
Input Formats
- CityJSON (
.city.json) - Standard CityJSON files - CityJSON Text Sequences (
.city.jsonl) - Line-delimited CityJSON features - FCB (
.fcb) - FlatCityBuf binary format
Remote Input:
inspectalso accepts anhttp://orhttps://URL and reads the header over HTTP range requests. The other commands (ser,deser,cbor,bson) take local paths only, plus-for stdin/stdout where documented.
Multi-file Support: The
sercommand accepts multiple input files and glob patterns; the last positional argument is always the output. When merging files with different coordinate transforms, vertices are automatically aligned to the first file's transform.
Output Formats
- FCB (
.fcb) - FlatCityBuf binary format with optional indexing - CityJSON Text Sequences (
.city.jsonl) - Line-delimited CityJSON features - CBOR - Concise Binary Object Representation
- BSON - Binary JSON
Examples Workflow
# 1. convert cityjson to fcb with attribute indexing
# 2. check file information
# 3. convert back to cityjson
# 4. filter by bounding box and index all attributes
Error Handling
The CLI provides detailed error messages for common issues:
- Invalid file formats
- Missing input files
- Malformed bounding box coordinates
- Memory limitations for large datasets
License
MIT License - see LICENSE file for details.