Skip to content

Commit 21b9a77

Browse files
tz12323CopilotSunrisepeak
authored
feat: add richdem package (#527)
* feat: add richdem package Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(richdem): correct package lookup and validate serial terrain core --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: sunrisepeak <speakshen@163.com>
1 parent 2461f18 commit 21b9a77

7 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add compat.richdem
2+
3+
The pinned revision 9a1c97bb2529e386451a7dd54768b8b74bb4d620 declares
4+
project version 2.2.11 in upstream CMakeLists.txt. It is not a release tag;
5+
the descriptor preserves the PR's requested source snapshot and version.
6+
The archive hash was checked twice. License: MIT.
7+
8+
This Form B build compiles richdem.cpp, random.cpp and terrain generation
9+
sources, exposing upstream include/. It is deliberately the serial core:
10+
GDAL, Boost serialization and OpenMP are disabled. The proposed gdal feature
11+
was removed because adding gdal.cpp alone leaves USEGDAL disabled and cannot
12+
supply the required SDK and runtime. No unsupported feature is advertised.
13+
14+
The descriptor lives under pkgs/c/compat.richdem.lua, matching the full
15+
package name; the consumer redirects compat to this checkout. It fills a
16+
3x3 depression and verifies random-state save/restore, exercising both the
17+
public terrain algorithm and linked core symbols.
18+
19+
No mirror upload was performed; plain-string GLOBAL URLs provide CN fallback.
20+
Local validation with the CI-pinned mcpp 2026.10.1.2 and gcc 16.1.0:
21+
`mcpp test -p richdem`: `test result ok. 1 passed; 0 failed`.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ the online index; open a PR and confirm CI is green.
6363
A PR runs lint and tests only the workspace members that depend on the changed descriptors; after the merge,
6464
`deploy-site` publishes the site.
6565

66+
Additional example: [`compat.richdem`](pkgs/c/compat.richdem.lua) — C++ sources, serial terrain analysis; [`consumer test`](tests/examples/richdem/mcpp.toml).
67+
6668
## Documentation
6769

6870
- [Library shapes and descriptor templates](docs/package-types.md)

‎README.zh-CN.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ agent(如 Claude Code)即可:
5959

6060
提交 PR 后,CI 执行 lint,并只测试依赖了被修改描述符的 workspace 成员;合并后,`deploy-site` 发布站点。
6161

62+
新增示例: [`compat.richdem`](pkgs/c/compat.richdem.lua) — C++ sources, serial terrain analysis; [`消费测试`](tests/examples/richdem/mcpp.toml)。
63+
6264
## 文档
6365

6466
- [库形态与描述符模板](docs/zh/package-types.md)

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ members = [
8585
"tests/examples/openssl",
8686
"tests/examples/recastnavigation",
8787
"tests/examples/recastnavigation-features",
88+
"tests/examples/richdem",
8889
"tests/examples/protobuf",
8990
"tests/examples/protobuf-upb",
9091
"tests/examples/protobuf-gzip",

‎pkgs/c/compat.richdem.lua‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Form B inline descriptor for RichDEM, a C++ library for high-performance
2+
-- terrain analysis.
3+
--
4+
-- Serial core build: GDAL, Boost serialization and OpenMP are disabled.
5+
-- GDAL needs a define, headers and a runtime dependency, so a sources-only
6+
-- feature cannot enable it correctly. Do not advertise an inert gdal feature.
7+
package = {
8+
spec = "1",
9+
namespace = "compat",
10+
name = "richdem",
11+
description = "High-performance terrain analysis library",
12+
licenses = {"MIT"},
13+
repo = "https://github.com/r-barnes/richdem",
14+
type = "package",
15+
16+
xpm = {
17+
linux = {
18+
["2.2.11"] = {
19+
url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz",
20+
sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b",
21+
},
22+
},
23+
macosx = {
24+
["2.2.11"] = {
25+
url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz",
26+
sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b",
27+
},
28+
},
29+
windows = {
30+
["2.2.11"] = {
31+
url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz",
32+
sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b",
33+
},
34+
},
35+
},
36+
37+
mcpp = {
38+
language = "c++23",
39+
import_std = false,
40+
c_standard = "c11",
41+
include_dirs = { "*/include" },
42+
sources = {
43+
"*/src/richdem.cpp",
44+
"*/src/random.cpp",
45+
"*/src/terrain_generation/terrain_generation.cpp",
46+
"*/src/terrain_generation/PerlinNoise.cpp",
47+
},
48+
targets = { ["richdem"] = { kind = "lib" } },
49+
deps = {},
50+
},
51+
}

‎tests/examples/richdem/mcpp.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "richdem-tests"
3+
version = "0.1.0"
4+
5+
[dependencies.compat]
6+
richdem = "2.2.11"
7+
8+
[indices]
9+
compat = { path = "../../.." }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <richdem/common/Array2D.hpp>
2+
#include <richdem/common/random.hpp>
3+
#include <richdem/depressions/depressions.hpp>
4+
5+
int main() {
6+
richdem::Array2D<double> dem(3, 3, 5.0);
7+
dem(1, 1) = 1.0;
8+
richdem::FillDepressions<richdem::Topology::D8>(dem);
9+
if (dem(1, 1) != 5.0 || dem(0, 0) != 5.0) return 1;
10+
11+
richdem::seed_rand(1);
12+
const auto state = richdem::SaveRandomState();
13+
const int first = richdem::uniform_rand_int(1, 10);
14+
richdem::SetRandomState(state);
15+
return first >= 1 && first <= 10 &&
16+
richdem::uniform_rand_int(1, 10) == first ? 0 : 2;
17+
}

0 commit comments

Comments
 (0)