fcb_core/
lib.rs

1//! # FlatCityBuf Core Library
2//!
3//! A high-performance Rust library for encoding and decoding CityJSON data to the FlatCityBuf (FCB) binary format.
4//! FCB uses FlatBuffers for efficient serialization with support for spatial and attribute indexing.
5//!
6//! ## Attribution
7//!
8//! **Portions of this software are derived from FlatGeobuf**
9//! - Source: <https://github.com/flatgeobuf/flatgeobuf>
10//! - License: BSD 2-Clause License
11//! - Copyright (c) 2018-2024, Björn Harrtell and contributors
12//!
13//! Specifically, the following components contain code derived from FlatGeobuf:
14//! - Spatial indexing algorithms (packed R-tree implementation)
15//! - HTTP range request handling (for Rust native part)
16//! - Binary format design patterns
17//!
18//! We extend our gratitude to the FlatGeobuf team for their excellent work on efficient
19//! geospatial binary formats, which provided the foundation for FlatCityBuf's spatial
20//! indexing and serialization architecture.
21//!
22//! ## License
23//!
24//! This project is licensed under the MIT License.
25//! FlatGeobuf portions remain under their original BSD 2-Clause License.
26
27mod cj_utils;
28mod cjerror;
29mod const_vars;
30pub mod error;
31pub mod fb;
32#[allow(dead_code, unused_imports, clippy::all, warnings)]
33#[cfg(all(feature = "http", not(target_arch = "wasm32")))]
34pub mod http_reader;
35
36pub mod packed_rtree;
37mod reader;
38pub mod static_btree;
39mod writer;
40
41pub use cj_utils::*;
42pub use const_vars::*;
43pub use error::Error;
44pub use fb::*;
45pub use packed_rtree::{NodeItem, PackedRTree, Query as SpatialQuery, SearchResultItem};
46pub use reader::*;
47pub use static_btree::{
48    Entry, FixedStringKey, Float, Key, KeyType, MemoryIndex, MemoryMultiIndex, MultiIndex,
49    Operator, Query, QueryCondition, StreamIndex, StreamMultiIndex,
50};
51pub use writer::*;
52
53#[cfg(all(feature = "http", not(target_arch = "wasm32")))]
54pub use http_reader::*;
55
56pub fn check_magic_bytes(bytes: &[u8]) -> bool {
57    bytes[0..3] == MAGIC_BYTES[0..3] && bytes[4..7] == MAGIC_BYTES[4..7] && bytes[3] <= VERSION
58}