Skip to content

Latest commit

Β 

History

550 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlatCityBuf πŸ™οΈ

FlatCityBuf Logo

A cloud-optimized binary format for storing and retrieving 3D city models

Ask DeepWiki License: MIT Rust WebAssembly

Bringing the semantic richness of CityJSON with the performance of FlatBuffers

πŸš€ Getting Started β€’ πŸ“Š Benchmarks β€’ πŸ“– Documentation β€’ πŸ“š API Reference β€’ 🀝 Contributing


✨ Overview

FlatCityBuf revolutionizes 3D city model storage and retrieval by combining the semantic richness of CityJSON with the performance benefits of FlatBuffers binary serialization and advanced spatial indexing techniques.

Demo

Try the browser viewer live at flatcitybuf-prototype.hideba.me β€” open a .fcb over HTTP range requests (the full 3DBAG dataset by default) or a local file, run spatial and attribute queries, and render the result with deck.gl. No server component; reading is pure TypeScript, with export to CityJSON/OBJ using a lazy-loaded WASM helper. Source in examples/web. Supersedes the earlier WASM-based prototype.

CleanShot.2026-08-20.at.11.33.07-converted-converted.mov

Example FlatCityBuf File

🎯 Why FlatCityBuf?

Traditional CityJSON formats face significant challenges in large-scale urban applications:

  • Slow parsing: Entire files must be loaded and parsed
  • Memory intensive: High memory consumption for large datasets
  • No spatial queries: Lack of efficient spatial indexing
  • Limited cloud support: Poor performance with remote data access

πŸš€ Key Features

Feature Benefit
⚑ Zero-copy Access Access specific city objects without parsing entire files
☁️ Cloud Optimized HTTP range requests for partial data retrieval
πŸ—ΊοΈ Spatial Indexing Packed R-tree for lightning-fast spatial queries
πŸ” Attribute Indexing Static B+Tree for instant attribute-based filtering
🌐 Multi-platform Rust core plus a pure TypeScript reader for the browser and Node.js

πŸš„ Performance & Benchmarks

FlatCityBuf delivers 10-20Γ— faster data retrieval compared to CityJSONTextSequence formats:

Speed Comparison Results

Dataset CityJSON FlatCityBuf Speed Improvement Memory Reduction
3DBAG 56 ms 6 ms 8.6Γ— 4.7Γ— less memory
3DBV 3.8 s 122ms 32.6Γ— 4.5Γ— less memory
Helsinki 4.0 s 132ms 30.6Γ— 2.9Γ— less memory
NYC 887 ms 43 ms 20.7Γ— 4.1Γ— less memory

πŸ“ˆ Performance: 8.6-256Γ— faster queries with 2.1-6.4Γ— less memory usage


πŸ—οΈ Project Structure

flatcitybuf/
β”œβ”€β”€ πŸ¦€ src/rust/         # Rust reader + writer (fcb_core, cli, fcb_api)
β”œβ”€β”€ βš™οΈ src/cpp/          # Native C++ reader + writer
β”œβ”€β”€ 🐍 src/py/           # Pure-Python reader (no compiled dependency)
β”œβ”€β”€ 🌐 src/ts/           # Pure TypeScript reader (browser + Node.js)
β”œβ”€β”€ πŸ“š docs/             # Format specification and per-language guides
β”œβ”€β”€ βœ… conformance/      # Shared oracle corpus every implementation validates against
└── πŸ§ͺ examples/         # Usage examples, tutorials and the web demo

Technology Stack

  • Core: Rust with zero-copy deserialization
  • Serialization: FlatBuffers schema with custom optimizations
  • Spatial Index: Packed R-tree for efficient range queries
  • Attribute Index: Static B+Tree for attribute indexing
  • Web Support: Pure TypeScript reader (@cityjson/flatcitybuf), no WebAssembly
  • CLI: Comprehensive command-line tools

Language Implementations

FlatCityBuf has four independent, from-scratch implementations of the same format β€” no FFI between them; each parses (and, for Rust and C++, produces) the bytes directly. Rust is the authoritative reference:

  • Rust – Reader and writer, the reference implementation (cargo install fcb_cli)
  • C++ – Native reader and writer, conformant; no CXX bridge or Rust dependency
  • Python – Pure-Python native reader, conformant, no compiled dependency (pip install flatcitybuf)
  • TypeScript – Native reader for the browser or Node.js, conformant (@cityjson/flatcitybuf)

πŸš€ Getting Started

Prerequisites

  • Rust toolchain (recent stable)
  • Node.js β‰₯ 22.12 (for the TypeScript reader in src/ts)

πŸ“¦ Installation

Package Manager Installation (Recommended)

Rust CLI: Install from crates.io

cargo install fcb_cli --locked

This installs the fcb binary to your Cargo bin directory (usually ~/.cargo/bin/).

C++: Install via vcpkg

The flatcitybuf port is served from a custom vcpkg registry: add the registry to your project's vcpkg-configuration.json, depend on flatcitybuf (feature curl for the HTTP reader), and link flatcitybuf::flatcitybuf. Registry configuration and current baselines: src/cpp/INSTALL.md

Python: Install from PyPI

pip install flatcitybuf

For more details, see PyPI documentation

JavaScript/TypeScript: Install from npm

npm install @cityjson/flatcitybuf

For more details, see npm documentation

Build from Source

# Clone the repository
git clone https://github.com/HideBa/flatcitybuf.git
cd flatcitybuf/src/rust

# Build the core library and CLI
cargo build --workspace --all-features --exclude fcb_py --release

The browser/Node.js reader is a separate pure TypeScript package in src/ts (published as @cityjson/flatcitybuf); build it with npm ci && npm run build from src/ts. See the TypeScript guide.

πŸ› οΈ CLI Usage

Convert CityJSON/CityJSONSeq to FlatCityBuf

Replace cargo run -p fcb_cli -- with fcb in the following commands if you want to use the installed binary directly.

Input and output are positional: the input comes first, the output second.

# Basic conversion from CityJSONSeq
fcb ser input.city.jsonl output.fcb

# Convert standard CityJSON file
fcb ser city.city.json output.fcb

# Multiple input files -- the last positional is the output
fcb ser file1.city.jsonl file2.city.jsonl merged.fcb

# Glob patterns to process all matching files
fcb ser 'data/*.city.jsonl' output.fcb
fcb ser 'cities/**/*.city.json' all_cities.fcb

# With spatial index and attribute index
fcb ser data.city.jsonl data.fcb --attr-index attribute_name,attribute_name2

# Back to CityJSONSeq
fcb deser data.fcb output.city.jsonl

# Show information about the file (static text report)
fcb inspect data.fcb --static

# Browse a dataset in an interactive terminal UI (local path or http(s):// URL,
# which reads only the header over range requests)
fcb inspect data.fcb

πŸ§ͺ Run Benchmarks

# Core reading benchmarks
cargo bench -p fcb_core --bench read -- --release

πŸ“š Documentation

Document What it is for
Format specification The binary format, from schema level down to byte offsets, constants and formulas
Rust guide Building, testing and using the Rust reader, writer and fcb CLI
C++ guide Building, testing and using the native C++ reader and writer
Python guide Installing and using the pure-Python reader
TypeScript guide Installing and using the TypeScript reader in the browser or Node.js
Datasets The public .fcb and CityJSONSeq files, what is hosted and where
Testing The full manual verification procedure, local and remote
Upstream findings Permanent record of defects found across the implementations, each cited and reproduced
Contributing How to report bugs, request features and submit pull requests

🀝 Contributing

We welcome contributions from the community! Please see our Contributing Guidelines for details on:

  • πŸ› Reporting bugs
  • πŸ’‘ Requesting features
  • πŸ”§ Submitting pull requests
  • πŸ“ Improving documentation

πŸ™ Acknowledgements & Special Thanks

Core Contributors

This project builds upon the excellent work of the geospatial and 3D GIS community:

Technical Foundations

  • FlatGeobuf - FlatGeobuf team Licensed under BSD 2-Clause License. Provided the foundational spatial indexing algorithms and FlatBuffers integration patterns.

  • CityBuf - 3DBAG organisation Original FlatBuffers schema for CityJSON features, authored by Ravi Peters (3DGI) and BalΓ‘zs Dukai (3DGI).

Standards & Specifications

  • CityJSON - For the semantic foundation of 3D city models
  • FlatBuffers - Google's cross-platform serialization library
  • OGC CityGML - International standard for 3D city models

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“– Citation

The reserach paper has been published on 20th 3D GeoInfo conference in 2025. The paper is publicly availabe on ISPRS achives and its DOI is 10.5194/isprs-archives-XLVIII-4-W15-2025-17-2025

If you use FlatCityBuf in your research, please cite:

@inproceedings{25_3dgeoinfo_fcb,
 author = {Baba, Hidemichi and Ledoux, Hugo and Peters, Ravi},
 title = {{FlatCityBuf}: {A} new cloud-optimised {CityJSON} format},
 booktitle = {Proceedings 20th 3D GeoInfo Conference},
 year = {2025},
 volume = {XLVIII-4/W15-2025},
 pages = {17--24},
 address = {Tokyo, Japan},
 publisher = {ISPRS},
 doi = {10.5194/isprs-archives-XLVIII-4-W15-2025-17-2025}
}

Releases

Packages

Used by

Contributors

Languages