Skip to main content

godot_gis/
lib.rs

1//! # Godot-GIS
2//!
3//! A Godot-Rust GDExtension for integrating Geographic Information Systems (GIS) with Godot.
4//!
5//! This crate provides geometry types, coordinate transformations, spatial indexing,
6//! and support for loading/saving Mapbox Vector Tiles (MVT).
7//!
8//! ## Core Modules
9//!
10//! - [`geometry`] - GIS geometry types (Point, Line, Polygon, etc.) with geo algorithm support
11//! - [`projection`] - Coordinate reference system transformations using PROJ
12//! - [`rstar`] - R*-tree spatial indexing for efficient spatial queries
13//! - [`formats`] - Resource loaders and savers for geographic data formats (MVT, GPKG, Shapefile)
14//! - [`mvt`] - Mapbox Vector Tile resources and layers
15//! - [`gpkg`] - GeoPackage resources and layers
16//! - [`geojson`] - GeoJSON resources and layers
17//! - [`text`] - Experimental; Text rendering utilities for curved paths
18//! - [`graph`] - Experimental; Graph networks and algorithms
19//! - [`renderer`] - Renderer; Renders features using Godot's RenderServer API
20//!
21//! ## Quick Start
22//!
23//! When using as a Godot addon, the extension registers automatically. When using as a
24//! Rust crate with the `no-extension-library` feature, you must register godot_gis manually with `godot_gis::register()`
25//! inside your own extension.
26//!
27//! ## Features
28//!
29//! - `mvt` (default) - Enables Mapbox Vector Tile (.mvt) support
30//! - `gpkg` (default) - Enables GeoPackage (.gpkg) support
31//! - `shp` (default) - Enables Shapefile (.shp) support
32//! - `no-extension-library` - Disables standalone extension, for embedding in other extensions
33
34pub mod formats;
35
36pub mod geometry;
37pub mod projection;
38pub mod renderer;
39pub mod rstar;
40pub mod singleton;
41pub mod text;
42
43#[cfg(feature = "graph")]
44pub mod graph;
45
46#[cfg(feature = "geojson")]
47pub mod geojson;
48
49#[cfg(feature = "gpkg")]
50pub mod gpkg;
51
52#[cfg(feature = "mvt")]
53pub mod mvt;
54
55#[cfg(feature = "shp")]
56pub mod shp;
57
58#[allow(dead_code)]
59struct GodotGis;
60
61pub fn init() {
62    formats::register_resource_formats();
63}
64
65pub fn deinit() {
66    formats::unregister_resource_formats();
67}
68
69#[cfg(not(feature = "no-extension-library"))]
70use godot::prelude::*;
71
72#[cfg(not(feature = "no-extension-library"))]
73#[gdextension]
74unsafe impl ExtensionLibrary for GodotGis {
75    fn on_stage_init(stage: InitStage) {
76        if stage == InitStage::Scene {
77            init();
78        }
79    }
80
81    fn on_stage_deinit(stage: InitStage) {
82        if stage == InitStage::Scene {
83            deinit();
84        }
85    }
86}