Skip to main content

High-performance GeoTIFF to Cesium quantized-mesh terrain tile generator

Project description

alcesium-terrain-maker

High-performance GeoTIFF → Cesium quantized-mesh-1.0 terrain tile generator.

Python API + Cython/AVX512 native core(默认开启 AVX512,需 CPU 支持)。GDAL is required at runtime (not bundled in the wheel).

Requirements

  • Python >= 3.11
  • CMake >= 3.22, C++17 compiler, Ninja
  • GDAL >= 3.4 with Python bindings (osgeo)
  • NumPy (build + runtime for tests)

Installing GDAL

Conda (recommended on Windows):

conda install -c conda-forge gdal

Linux:

sudo apt install gdal-bin libgdal-dev python3-gdal

Build & Install

# 安装到当前环境(开发)
uv sync --extra dev
uv pip install -e ".[dev]"

# 打一个 wheel(当前 Python 版本)→ dist/
uv build --wheel --out-dir dist

# Windows:注入 MSVC 后构建(推荐)
.\scripts\build_wheel.ps1

# 全量:Windows 3.11–3.14 + Linux manylinux(需 Docker)
.\scripts\build_local_wheels.ps1

# 上传 PyPI
.\scripts\upload_wheels.ps1

详见 scripts/README.md

默认 wheel 开启 AVX512(性能优先)。在不支持 AVX512 的老 CPU 上需关闭后重编:

uv build --wheel -Ccmake.define.ATM_USE_AVX512=OFF
# 或仅 AVX2:
uv build --wheel -Ccmake.define.ATM_USE_AVX512=OFF -Ccmake.define.ATM_USE_AVX2=ON
# 或完全可移植(无 SIMD 指令集要求):
uv build --wheel -Ccmake.define.ATM_USE_AVX512=OFF -Ccmake.define.ATM_USE_AVX2=OFF

PowerShell 脚本可加 -Portable.\scripts\build_wheel.ps1 -Portable

Python API

from pathlib import Path
from alcesium_terrain_maker import TerrainBuilder, TerrainConfig

config = TerrainConfig(
    profile="geodetic",       # or "mercator"
    overlap_mode="MEAN",      # LAST | FIRST | MEAN | MIN | MAX
    buffer_m=500.0,
    buffer_mode="FADE",       # EXTEND | FADE
    max_zoom=14,
    thread_count=16,
)

builder = TerrainBuilder(config)
result = builder.build(
    inputs=[Path("dem_a.tif"), Path("dem_b.tif")],
    output_dir=Path("terrain_out"),
)

print(result.tiles_written, result.layer_json_path)

Multi-GeoTIFF overlap

Each source is sampled independently per tile. Overlap pixels are merged using overlap_mode:

Mode Behavior
LAST Later inputs overwrite earlier
FIRST Earlier values kept where present
MEAN Average of valid values
MIN / MAX Minimum / maximum elevation

Boundary buffer

buffer_m extends each source outward. Applied per-source during tile sampling (not by merging rasters):

  • EXTEND: outer ring height copied from nearest valid edge pixel
  • FADE: linear decay toward 0; pixels originally below 0 stay frozen in the buffer zone

Output layout

terrain_out/
├── layer.json
└── {z}/{x}/{y}.terrain   # gzip-compressed quantized-mesh-1.0

Load in CesiumJS

const viewer = new Cesium.Viewer("cesiumContainer", {
  terrainProvider: await Cesium.CesiumTerrainProvider.fromUrl("./terrain_out/"),
});

Project layout

src/alcesium_terrain_maker/   # Python + Cython sources
extern/zlib/                  # zlib (FetchContent at build time)
extern/mesh_simplify/         # Chunked LOD grid simplification (C++)

Tests

pytest tests/

Performance tips

  • Use COG / tiled GeoTIFF (gdal_translate -co TILED=YES -co BLOCKXSIZE=65)
  • Set thread_count to CPU core count
  • Input elevation should be ellipsoidal heights in meters (WGS84)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

alcesium_terrain_maker-0.1.0-cp314-cp314-win_amd64.whl (301.9 kB view details)

Uploaded CPython 3.14Windows x86-64

alcesium_terrain_maker-0.1.0-cp313-cp313-win_amd64.whl (296.4 kB view details)

Uploaded CPython 3.13Windows x86-64

alcesium_terrain_maker-0.1.0-cp312-cp312-win_amd64.whl (296.2 kB view details)

Uploaded CPython 3.12Windows x86-64

alcesium_terrain_maker-0.1.0-cp311-cp311-win_amd64.whl (297.8 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file alcesium_terrain_maker-0.1.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 08cafe5b46e7f8628e28f9d6a42b083b8608cb23a4d61aec8181f8e17f173144
MD5 c86294103ac7871a44e4060bee33a505
BLAKE2b-256 935b8e5db437717c5425323fbb0e15c3754b02ab4da52b9615d96038667bb898

See more details on using hashes here.

File details

Details for the file alcesium_terrain_maker-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ace29aeb14162c0dce97b31d16a8dd6ddb0ab9d4a9530c75e44154a696ca455f
MD5 b78fc3cd632066df1ea4abf4536d9e09
BLAKE2b-256 61a8997eed9efef02d79c793606670da70cfba1cda8de0d59b0a7493db4b94f7

See more details on using hashes here.

File details

Details for the file alcesium_terrain_maker-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3758ce4ff86eecd74856bb761f4f4731635b875630fdbef483a63cea60b1a84a
MD5 a4ef92d3c4949761e13738785cd3fe2c
BLAKE2b-256 4defe4f8edbdaf50d94e69d5212421649dde93f11cb70418bce7c25e8012f471

See more details on using hashes here.

File details

Details for the file alcesium_terrain_maker-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0132ad0ab2150d87a31aef985ed0458f1dbf307ca5b78e57fe9bafaf0db903ce
MD5 59e7b9b10bd21041764e2a070fed44c3
BLAKE2b-256 50c7c3c096b3827cc27b3a6936eb93f38661495fc8b967380943530ef0f8f238

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page