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.1-cp314-cp314-win_amd64.whl (302.1 kB view details)

Uploaded CPython 3.14Windows x86-64

alcesium_terrain_maker-0.1.1-cp313-cp313-win_amd64.whl (296.6 kB view details)

Uploaded CPython 3.13Windows x86-64

alcesium_terrain_maker-0.1.1-cp312-cp312-win_amd64.whl (296.4 kB view details)

Uploaded CPython 3.12Windows x86-64

alcesium_terrain_maker-0.1.1-cp311-cp311-win_amd64.whl (298.0 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

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

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6d3aea06bb4cd3629308a20fd8a414695b3d20eafd528c920eda20befbda2eee
MD5 d77bf728dbad1c1d213935fc3fba1ba9
BLAKE2b-256 9c0b52385d188702b268633483cdf814830cd0fa6634d62db0aa2d5a22452e63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9f7dc1553eec05ce74d95504ea4b0411757a27226846eaa05097c22bb8df431f
MD5 fb98808d5473ddf33c88d4754426d04b
BLAKE2b-256 40c4a4aaf84da5469d72e3aea035a73ac8635c018db4ee582f0a19e038c9dd21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e73c5391b6fe9724dc938e985447c0e670aaa993930d0f48e565eb8ff37c9a25
MD5 a68e11d331b370466e8c56bb3f99308d
BLAKE2b-256 a125d5f3dc5be7bf8e9bb8e4f3d2d1b3e90890ebfbf9f27eadccd4f7e0033670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for alcesium_terrain_maker-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7406707313b608f1dc1153c348199985df2d6ff6a74570213c8e9eb42f79d250
MD5 8b1090489171ab9366da831e3e15411c
BLAKE2b-256 3963de83a08dd9c6ff1738632204f6a9a09f3cb8974a2ae03deab3de4c753f33

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