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
Commands
ser - Serialize CityJSON to FCB
Convert CityJSON files to FlatCityBuf format with optional indexing.
Options:
-i, --input INPUT...- Input file(s) or glob patterns (supports multiple files, use '-' for stdin)-o, --output OUTPUT- Output file (use '-' for stdout)-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, --spatial-index- Enable spatial indexing (default: true)--attr-branching-factor FACTOR- Branching factor for attribute index (default: 256)-b, --bbox BBOX- Bounding box filter in format "minx,miny,maxx,maxy"-g, --ge- Automatically calculate and set geospatial extent in header (default: true)
Examples:
# basic conversion from CityJSONSeq
# convert CityJSON file (standard .json format)
# multiple input files
# glob patterns to process all matching files
# with attribute indexing
# index all attributes
# with bounding box filter
# from stdin to stdout
|
deser - Deserialize FCB to CityJSON
Convert FlatCityBuf files back to CityJSON format.
Options:
-i, --input INPUT- Input FCB file (use '-' for stdin)-o, --output OUTPUT- Output file (use '-' for stdout)
Examples:
# basic conversion
# from stdin to stdout
|
info - Show FCB file information
Display metadata and statistics about an FCB file.
Example:
Output includes:
- File size in MB
- FCB version
- Feature count
- Bounding box coordinates
- Indexed attributes
- Title (if present)
- Geographical extent
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
Multi-file Support: The
sercommand accepts multiple input files and glob patterns. 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.