Generate a leaf-level DCEL map from a hierarchical zone tree
Project description
dcel-map-generator
Generate whimsical continent-style maps from a rooted hierarchy of zones. The pipeline produces a leaf-level DCEL planar subdivision, an optional rendered PNG, and a frontend-ready JSON bundle for interactive exploration.
Installation
pip install dcel-map-generator
Requires Python 3.11+.
Quick Example
from dcel_builder import generate_dcel
dcel, report = generate_dcel(
zone_edges_path="zone_edges.json",
tree_stats_path="zone_tree_stats.json",
zone_index_path="zone_index.json",
seed=42,
)
interior_faces = [f for f in dcel.faces if not f.is_outer]
print(f"Generated {len(interior_faces)} leaf territories")
Python API
generate_dcel(...) -> (DCEL, report)
Build a leaf-level DCEL from a rooted zone tree.
generate_frontend_bundle(...) -> (bundle_dict, report)
Build a frontend-ready hierarchy bundle (JSON-serializable dict) that can be consumed by the companion React component @alonso-cancino/dcel-map-frontend.
generate_map_artifacts(...) -> (DCEL, report, tree, zone_index)
Low-level entry point that returns all intermediate artifacts.
All three functions accept the same parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
zone_edges_path |
str | Path |
required | Directed [parent, child] edge-list JSON |
tree_stats_path |
str | Path |
required | Sidecar stats JSON (can be {}) |
zone_index_path |
str | Path |
required | { "id": "name" } mapping JSON |
seed |
int | None |
None |
RNG seed for reproducible maps |
resolution |
int |
512 |
Raster grid size H x H |
land_fraction |
float |
0.40 |
Target fraction of land pixels |
noise_exponent |
float |
2.3 |
Power-law exponent for spectral noise |
warp_strength |
float |
0.10 |
Domain-warp amplitude (fraction of resolution) |
split_mode |
str |
"contour_guided" |
Split strategy: contour_guided, field_guided, or seeded |
quiet |
bool |
False |
Suppress progress output |
CLI
The package installs a dcel-map command:
dcel-map \
--zone-edges zone_edges.json \
--tree-stats zone_tree_stats.json \
--zone-index zone_index.json \
--output dcel_map.json \
--render --render-output map.png \
--frontend-bundle map_bundle.json \
--seed 42 --validate
Key flags:
| Flag | Description |
|---|---|
--output |
Path for the output DCEL JSON |
--render |
Render the DCEL to a PNG image |
--render-output |
PNG output path (default: dcel_map.png) |
--frontend-bundle |
Generate a frontend-ready JSON bundle |
--seed |
RNG seed for reproducibility |
--resolution |
Raster grid size (default: 512) |
--split-mode |
contour_guided (default), field_guided, or seeded |
--validate |
Run structural invariant checks before writing |
--quiet |
Suppress progress output |
Input Files
The generator expects three JSON files describing a rooted tree of zones:
zone_edges.json — directed parent-child pairs:
[[0, 1], [0, 2], [1, 3], [1, 4]]
zone_index.json — zone ID to display name:
{"0": "World", "1": "North", "2": "South", "3": "Tundra", "4": "Forest"}
zone_tree_stats.json — optional metadata (an empty {} is accepted).
Outputs
- DCEL JSON — serialized planar subdivision with vertices, half-edges, and faces. Each interior face is tagged with a
zone_idfrom the input tree. - PNG render — static map image colored by zone.
- Frontend bundle — JSON structure with SVG paths, bounding boxes, hierarchy, and zoom thresholds for interactive rendering.
How It Works
The pipeline is tree-first:
- Load a rooted hierarchy from the edge-list
- Generate a continent mask using spectral noise with domain warping
- Recursively partition each parent region among its children using weighted splits
- Extract leaf polygons from the raster partition
- Build a DCEL planar subdivision
Split modes control how regions are divided:
contour_guided— splits along raster contour lines (organic, natural-looking boundaries)field_guided— uses distance/flow fields for partitioningseeded— random Voronoi-like splits
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dcel_map_generator-0.8.1.tar.gz.
File metadata
- Download URL: dcel_map_generator-0.8.1.tar.gz
- Upload date:
- Size: 437.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c55f115d7e7a16ce5a366b9b25c85eb8895467f03acdf5a9a2a19621bd570bc9
|
|
| MD5 |
19a0222cc5e1cf42ffd5a5005557c7c3
|
|
| BLAKE2b-256 |
0c6e2cc319d74ab60a483fa05f79621a9a844e6d6450968bd636c4592c81b0d4
|
Provenance
The following attestation bundles were made for dcel_map_generator-0.8.1.tar.gz:
Publisher:
release.yml on alonso-cancino/map-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dcel_map_generator-0.8.1.tar.gz -
Subject digest:
c55f115d7e7a16ce5a366b9b25c85eb8895467f03acdf5a9a2a19621bd570bc9 - Sigstore transparency entry: 1211521363
- Sigstore integration time:
-
Permalink:
alonso-cancino/map-generator@e395c127149ec8e6a6734907dd594423a2c78f6d -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/alonso-cancino
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e395c127149ec8e6a6734907dd594423a2c78f6d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dcel_map_generator-0.8.1-py3-none-any.whl.
File metadata
- Download URL: dcel_map_generator-0.8.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7ab66643a5fe459d5d8e44b0f394da45b01b7e4f7f23af453d813945a183034
|
|
| MD5 |
afd139d39f220ec70cf0291179896507
|
|
| BLAKE2b-256 |
939d2c763a98a24b22ee8d0df94fb103db6ad4f9fd5692dc9ce323126b33bbcd
|
Provenance
The following attestation bundles were made for dcel_map_generator-0.8.1-py3-none-any.whl:
Publisher:
release.yml on alonso-cancino/map-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dcel_map_generator-0.8.1-py3-none-any.whl -
Subject digest:
c7ab66643a5fe459d5d8e44b0f394da45b01b7e4f7f23af453d813945a183034 - Sigstore transparency entry: 1211521471
- Sigstore integration time:
-
Permalink:
alonso-cancino/map-generator@e395c127149ec8e6a6734907dd594423a2c78f6d -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/alonso-cancino
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e395c127149ec8e6a6734907dd594423a2c78f6d -
Trigger Event:
workflow_dispatch
-
Statement type: