topobathykit 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. topobathykit-0.3.0/.githooks/commit-msg +4 -0
  2. topobathykit-0.3.0/.githooks/pre-commit +4 -0
  3. topobathykit-0.3.0/.githooks/pre-push +6 -0
  4. topobathykit-0.3.0/.githooks/run-hooks +21 -0
  5. topobathykit-0.3.0/.githooks/run-local +16 -0
  6. {topobathykit-0.2.0 → topobathykit-0.3.0}/CONTRIBUTING.md +12 -4
  7. {topobathykit-0.2.0 → topobathykit-0.3.0}/PKG-INFO +6 -2
  8. {topobathykit-0.2.0 → topobathykit-0.3.0}/README.md +5 -1
  9. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/requirements-docs.txt +1 -1
  10. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/conf.py +7 -3
  11. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/data_sources.rst +1 -0
  12. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/policy_dsl.rst +38 -2
  13. {topobathykit-0.2.0 → topobathykit-0.3.0}/environment.yml +1 -1
  14. {topobathykit-0.2.0 → topobathykit-0.3.0}/policies/examples/outer_shelf_gmrt.yaml +5 -1
  15. {topobathykit-0.2.0 → topobathykit-0.3.0}/pyproject.toml +1 -1
  16. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/cache-viewer.html +4 -0
  17. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/dem-viewer.html +140 -61
  18. topobathykit-0.2.0/service/static/index.html → topobathykit-0.3.0/service/static/tile-viewer.html +158 -41
  19. topobathykit-0.3.0/service/tests/test_dem_downsample.py +77 -0
  20. topobathykit-0.3.0/service/tests/test_dem_viewer_bbox.py +162 -0
  21. topobathykit-0.3.0/service/tests/test_policy_dynamic_post.py +218 -0
  22. topobathykit-0.3.0/service/tests/test_viewer_policies.py +148 -0
  23. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/main.py +161 -45
  24. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/models.py +14 -2
  25. topobathykit-0.3.0/service/topobathyserve/policy_catalog.py +78 -0
  26. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/routers/dem_viewer.py +235 -45
  27. topobathykit-0.3.0/src/topobathykit/policy/schema.py +300 -0
  28. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/base.py +81 -0
  29. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/gebco_2025.py +61 -3
  30. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/noaa_bluetopo.py +44 -26
  31. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/runtime.py +47 -4
  32. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_noaa_multi_survey.py +2 -2
  33. topobathykit-0.3.0/tests/unit/test_gebco_tid_filter.py +118 -0
  34. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_noaa_bluetopo_provider.py +123 -0
  35. topobathykit-0.3.0/tests/unit/test_plateau_mask.py +182 -0
  36. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_policy.py +80 -0
  37. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_provider_base.py +22 -0
  38. topobathykit-0.2.0/service/tests/test_policy_dynamic_post.py +0 -118
  39. topobathykit-0.2.0/src/topobathykit/policy/schema.py +0 -168
  40. {topobathykit-0.2.0 → topobathykit-0.3.0}/.agent/rules/context.md +0 -0
  41. {topobathykit-0.2.0 → topobathykit-0.3.0}/.github/copilot-instructions.md +0 -0
  42. {topobathykit-0.2.0 → topobathykit-0.3.0}/.github/workflows/docs.yml +0 -0
  43. {topobathykit-0.2.0 → topobathykit-0.3.0}/.github/workflows/publish.yml +0 -0
  44. {topobathykit-0.2.0 → topobathykit-0.3.0}/.github/workflows/tests.yml +0 -0
  45. {topobathykit-0.2.0 → topobathykit-0.3.0}/.gitignore +0 -0
  46. {topobathykit-0.2.0 → topobathykit-0.3.0}/.markdownlint.yaml +0 -0
  47. {topobathykit-0.2.0 → topobathykit-0.3.0}/.pre-commit-config.yaml +0 -0
  48. {topobathykit-0.2.0 → topobathykit-0.3.0}/Dockerfile +0 -0
  49. {topobathykit-0.2.0 → topobathykit-0.3.0}/LICENSE +0 -0
  50. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/Makefile +0 -0
  51. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/VISION.md +0 -0
  52. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_extra/CNAME +0 -0
  53. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/dem-viewer-provenance.png +0 -0
  54. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/dem-viewer.png +0 -0
  55. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/hydrate.png +0 -0
  56. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/northfork.png +0 -0
  57. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/repo-logo.png +0 -0
  58. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/topobathy-blues-with-countours.png +0 -0
  59. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/topobathy-sources.png +0 -0
  60. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/_static/topobathyscreenshot.png +0 -0
  61. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/api.rst +0 -0
  62. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/cache_viewer.rst +0 -0
  63. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/cli_tools.rst +0 -0
  64. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/diagrams/runtime_loop.mmd +0 -0
  65. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/fuse_endpoint.md +0 -0
  66. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/gallery.rst +0 -0
  67. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/hydration.md +0 -0
  68. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/index.rst +0 -0
  69. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/performance.rst +0 -0
  70. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/policy_walkthrough.rst +0 -0
  71. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/runtime_architecture.rst +0 -0
  72. {topobathykit-0.2.0 → topobathykit-0.3.0}/docs/source/vision.md +0 -0
  73. {topobathykit-0.2.0 → topobathykit-0.3.0}/policies/examples/gbr_overlay.yaml +0 -0
  74. {topobathykit-0.2.0 → topobathykit-0.3.0}/policies/examples/wlis.yaml +0 -0
  75. {topobathykit-0.2.0 → topobathykit-0.3.0}/scripts/run_hydrate.py +0 -0
  76. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/Dockerfile +0 -0
  77. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/__init__.py +0 -0
  78. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/pyproject.toml +0 -0
  79. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/run_server.py +0 -0
  80. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/cache-viewer.css +0 -0
  81. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/cache-viewer.js +0 -0
  82. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/favicon.ico +0 -0
  83. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/favicon.svg +0 -0
  84. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/hydrate.html +0 -0
  85. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/static/provenance-utils.js +0 -0
  86. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_api_integration.py +0 -0
  87. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_dem_viewer_cache.py +0 -0
  88. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_fuse_endpoint.py +0 -0
  89. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_hydrate_job_process.py +0 -0
  90. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_job_state.py +0 -0
  91. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_policy_hash.py +0 -0
  92. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/tests/test_tile_cache_key.py +0 -0
  93. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/__init__.py +0 -0
  94. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/job_state.py +0 -0
  95. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/topobathyserve/routers/cache_viewer.py +0 -0
  96. {topobathykit-0.2.0 → topobathykit-0.3.0}/service/verify_bathy.py +0 -0
  97. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/__init__.py +0 -0
  98. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/api/cache_api.py +0 -0
  99. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/api/models.py +0 -0
  100. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/config.py +0 -0
  101. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/fusion.py +0 -0
  102. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/gdal_http.py +0 -0
  103. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/manifest.py +0 -0
  104. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/operators/__init__.py +0 -0
  105. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/operators/blend.py +0 -0
  106. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/policy/__init__.py +0 -0
  107. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/policy/loader.py +0 -0
  108. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/__init__.py +0 -0
  109. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/copernicus_dsm.py +0 -0
  110. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/gmrt.py +0 -0
  111. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/jcu_gbr100.py +0 -0
  112. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/nasadem.py +0 -0
  113. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/ncei_bag.py +0 -0
  114. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/ncei_cudem.py +0 -0
  115. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/noaa_topobathy.py +0 -0
  116. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/registry.py +0 -0
  117. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/source_classifier.py +0 -0
  118. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/usgs_3dep.py +0 -0
  119. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/providers/usgs_lidar.py +0 -0
  120. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/quality.py +0 -0
  121. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/scripts/__init__.py +0 -0
  122. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/scripts/build_noaa_index.py +0 -0
  123. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/scripts/cache_manager.py +0 -0
  124. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/scripts/hydrate_cache.py +0 -0
  125. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/utils/cache.py +0 -0
  126. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathykit/vdatum.py +0 -0
  127. {topobathykit-0.2.0 → topobathykit-0.3.0}/src/topobathysim/__init__.py +0 -0
  128. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/conftest.py +0 -0
  129. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_api_caching.py +0 -0
  130. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_fusion_quality.py +0 -0
  131. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_gbr_fusion.py +0 -0
  132. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_integration.py +0 -0
  133. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_lidar_ept.py +0 -0
  134. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_noaa_coastal_lidar_streaming.py +0 -0
  135. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_provider_caching.py +0 -0
  136. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_runtime_pairwise.py +0 -0
  137. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_scenarios.py +0 -0
  138. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_topobathy_leak.py +0 -0
  139. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/integration/test_wlis_fusion.py +0 -0
  140. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_bag_hole_fill.py +0 -0
  141. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_bag_ordering.py +0 -0
  142. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_cache_lru.py +0 -0
  143. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_contours.py +0 -0
  144. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_cudem_fusion.py +0 -0
  145. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_despike.py +0 -0
  146. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_elevation_filter.py +0 -0
  147. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_fuse_geotiff.py +0 -0
  148. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_fusion_cache_version.py +0 -0
  149. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_fusion_seamline.py +0 -0
  150. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_gdal_http.py +0 -0
  151. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_gebco.py +0 -0
  152. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_gmrt.py +0 -0
  153. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_grid_alignment.py +0 -0
  154. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_hydrate_isolation.py +0 -0
  155. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_hydration_integrity.py +0 -0
  156. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_merge_determinism.py +0 -0
  157. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_multicell_mosaic.py +0 -0
  158. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_noaa_topobathy.py +0 -0
  159. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_noaa_whole_coverage.py +0 -0
  160. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_provider_concurrency.py +0 -0
  161. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_quality.py +0 -0
  162. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_raster_ops.py +0 -0
  163. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_rename_compat.py +0 -0
  164. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_runtime.py +0 -0
  165. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_runtime_shapes.py +0 -0
  166. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_tile_geotiff.py +0 -0
  167. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_usgs_3dep.py +0 -0
  168. {topobathykit-0.2.0 → topobathykit-0.3.0}/tests/unit/test_vdatum.py +0 -0
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # The clone's own commit-msg hook, if any (for example the git-operations
3
+ # attribution check). The repository adds no commit-msg rules of its own.
4
+ exec "$(dirname "$0")/run-local" commit-msg "$@"
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # The clone's own pre-commit hook, if any, then lint and type-check the staged files.
3
+ "$(dirname "$0")/run-local" pre-commit "$@" || exit $?
4
+ exec "$(dirname "$0")/run-hooks" run --hook-stage pre-commit
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+ # The clone's own pre-push hook, if any, then every hook on the whole tree, exactly
3
+ # as CI's Lint job runs them. Git passes the refs being pushed on stdin; only the
4
+ # clone's hook reads them.
5
+ "$(dirname "$0")/run-local" pre-push "$@" || exit $?
6
+ exec "$(dirname "$0")/run-hooks" run --all-files --show-diff-on-failure </dev/null
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ # Shared runner for the git hooks in this directory. Runs the hooks from
3
+ # .pre-commit-config.yaml, the same set CI's Lint job runs.
4
+ #
5
+ # The mypy hook is language: system, so mypy must be on PATH and see the
6
+ # project's packages. An activated environment that has both mypy and
7
+ # pre-commit (the micromamba setup) is used as is; otherwise uv runs them over
8
+ # the project's .venv without changing it.
9
+ #
10
+ # Enable once per clone: git config core.hooksPath .githooks
11
+ set -e
12
+ cd "$(git rev-parse --show-toplevel)"
13
+
14
+ if command -v pre-commit >/dev/null 2>&1 && command -v mypy >/dev/null 2>&1; then
15
+ exec pre-commit "$@"
16
+ elif command -v uv >/dev/null 2>&1; then
17
+ exec uv run --no-sync --with mypy --with pre-commit pre-commit "$@"
18
+ else
19
+ echo "git hook: need pre-commit and mypy on PATH, or uv; see CONTRIBUTING.md" >&2
20
+ exit 1
21
+ fi
@@ -0,0 +1,16 @@
1
+ #!/bin/sh
2
+ # Runs the clone's own hook of the given name from .git/hooks, if it is present
3
+ # and executable. Setting core.hooksPath stops git from running those hooks
4
+ # (for example the git-operations attribution checks), so each hook in this
5
+ # directory calls them through here first.
6
+ #
7
+ # Usage: run-local <hook-name> [args...]
8
+ #
9
+ # GITHOOKS_CHAINED stops a loop when a .git/hooks script itself calls back into
10
+ # this directory.
11
+ name=$1
12
+ shift
13
+ [ -n "$GITHOOKS_CHAINED" ] && exit 0
14
+ hook="$(git rev-parse --git-common-dir)/hooks/$name"
15
+ [ -x "$hook" ] || exit 0
16
+ GITHOOKS_CHAINED=1 exec "$hook" "$@"
@@ -116,14 +116,22 @@ For a persistent fix, you may need to configure `limit maxfiles` via `launchctl`
116
116
 
117
117
  ### Pre-commit hooks
118
118
 
119
- We use [pre-commit](https://pre-commit.com/) for formatting, linting, and type checks.
119
+ We use [pre-commit](https://pre-commit.com/) for formatting, linting, and type checks. CI's Lint job runs the same hooks from `.pre-commit-config.yaml` on every push, so run them locally first.
120
+
121
+ Enable the repository's git hooks once per clone:
122
+
123
+ ```bash
124
+ git config core.hooksPath .githooks
125
+ ```
126
+
127
+ The `pre-commit` hook checks staged files before each commit, and the `pre-push` hook runs every hook on the whole tree before each push, as CI does. With `core.hooksPath` set, git no longer runs the clone's own hooks in `.git/hooks`, so each tracked hook (`pre-commit`, `pre-push`, `commit-msg`) first runs the clone's hook of the same name when one is present and executable. The mypy hook needs `mypy` on `PATH` with the project's packages importable. An activated environment that has `pre-commit` and `mypy` (the micromamba setup, plus `pip install pre-commit`) is used as is; otherwise the hooks run both through [uv](https://docs.astral.sh/uv/) over the project's `.venv`. To run them by hand:
120
128
 
121
129
  ```bash
122
- pip install pre-commit
123
- pre-commit install
124
- pre-commit run --all-files
130
+ .githooks/run-hooks run --all-files
125
131
  ```
126
132
 
133
+ Local package versions can differ from CI's micromamba environment, so mypy may still report something in CI that it did not report locally.
134
+
127
135
  ### Type checking
128
136
 
129
137
  - All new code must be type-hinted.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: topobathykit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Policy-driven topobathymetric fusion: fuses overlapping elevation sources into seamless grids with per-pixel provenance.
5
5
  Project-URL: Documentation, https://topobathykit.docs.lhzn.io
6
6
  Project-URL: Issues, https://github.com/lhzn-io/topobathykit/issues
@@ -223,7 +223,11 @@ Open the viewer:
223
223
 
224
224
  - <http://localhost:9595/viewer>
225
225
 
226
- Use the viewer to:
226
+ It opens on the cache inventory, which links to the 3D DEM viewer, the tile viewer and the hydrate
227
+ tool. The DEM viewer lists each fused dataset under its policy name, version and cache key; the tile
228
+ viewer renders nothing until a fusion policy is chosen.
229
+
230
+ Use the viewers to:
227
231
 
228
232
  - inspect seams and coverage
229
233
  - switch to **provenance/source** view
@@ -150,7 +150,11 @@ Open the viewer:
150
150
 
151
151
  - <http://localhost:9595/viewer>
152
152
 
153
- Use the viewer to:
153
+ It opens on the cache inventory, which links to the 3D DEM viewer, the tile viewer and the hydrate
154
+ tool. The DEM viewer lists each fused dataset under its policy name, version and cache key; the tile
155
+ viewer renders nothing until a fusion policy is chosen.
156
+
157
+ Use the viewers to:
154
158
 
155
159
  - inspect seams and coverage
156
160
  - switch to **provenance/source** view
@@ -1,4 +1,4 @@
1
1
  sphinx>=7.0.0
2
- sphinx-rtd-theme>=2.0.0
2
+ lhzn-sphinx-theme>=0.1,<0.2
3
3
  myst-parser>=2.0.0
4
4
  sphinxcontrib-mermaid>=0.9.0
@@ -8,14 +8,13 @@ sys.path.insert(0, os.path.abspath("../../src"))
8
8
  project = "topobathykit"
9
9
  copyright = "2026, Long Horizon Observatory"
10
10
  author = "Daniel Fry"
11
- release = "0.2.0"
11
+ release = "0.3.0"
12
12
 
13
13
  extensions = [
14
14
  "sphinx.ext.autodoc",
15
15
  "sphinx.ext.napoleon",
16
16
  "sphinx.ext.viewcode",
17
17
  "sphinx.ext.mathjax",
18
- "sphinx_rtd_theme",
19
18
  "myst_parser",
20
19
  "sphinxcontrib.mermaid",
21
20
  ]
@@ -23,7 +22,12 @@ extensions = [
23
22
  templates_path = ["_templates"]
24
23
  exclude_patterns: list[str] = []
25
24
 
26
- html_theme = "sphinx_rtd_theme"
25
+ html_theme = "lhzn"
26
+ html_theme_options = {
27
+ "source_repository": "https://github.com/lhzn-io/topobathykit",
28
+ "source_branch": "main",
29
+ "source_directory": "docs/source/",
30
+ }
27
31
  html_static_path = ["_static"]
28
32
  html_extra_path = ["_extra"]
29
33
 
@@ -16,6 +16,7 @@ General Bathymetric Chart of the Oceans (GEBCO)
16
16
  * **Description**: A continuous terrain model for ocean and land, providing global context at 15 arc-second intervals.
17
17
  * **Citation**: GEBCO Compilation Group (2025) GEBCO 2025 Grid (doi:10.5285/1c44ce9e-0a53-431f-9780-3843464522c5).
18
18
  * **Access**: `GEBCO Grid Download <https://www.gebco.net/data_and_products/gridded_bathymetry_data/>`_
19
+ * **Type identifier (TID) grid**: fetched with each 1 x 1 degree elevation tile from the same OPeNDAP server, on the same coordinates, and cached beside it as ``source_id``. Each cell's code says how its depth was obtained (for example 11 multibeam, 40 predicted from satellite gravity, 70 pre-generated grid); :doc:`policy_dsl` lists them. A ``gebco_2025`` step can drop cells by TID with ``exclude_tid`` or ``include_tid``. The TID is a coarse tool: on the Mid-Atlantic Bight shelf break, flat blocks about 120 m shallower than the slope around them are labeled multibeam (TID 11), like the genuine multibeam beside them, so ``drop_plateaus`` is the filter that removes them.
19
20
 
20
21
  Deep-Water Multibeam (Tier 3.8)
21
22
  -------------------------------
@@ -64,11 +64,47 @@ Providers can accept arbitrary metadata or filtering instructions via the ``filt
64
64
  - provider: "noaa_bluetopo"
65
65
  operation: "metric_feather"
66
66
  filter:
67
- exclude_patterns: ["*.interpolated", "Chart*"]
67
+ exclude_patterns: ["*.interpolated", "*Chart*"]
68
68
  max_interpolation_gap_m: 15.0
69
69
 
70
- - **include_patterns** / **exclude_patterns**: A list of strings (supporting ``fnmatch`` wildcards like ``*``) to whitelist or blacklist specific survey IDs or URLs (e.g. omitting historical or interpolated data from BlueTopo or BAGs). For ``usgs_3dep`` the patterns match the STAC asset file name (e.g. ``USGS_13_n41w074.tif``), the same names ``/analyze`` reports.
70
+ - **include_patterns** / **exclude_patterns**: A list of strings (supporting ``fnmatch`` wildcards like ``*``) to whitelist or blacklist specific survey IDs or URLs (e.g. omitting historical or interpolated data from BlueTopo or BAGs). For ``usgs_3dep`` the patterns match the STAC asset file name (e.g. ``USGS_13_n41w074.tif``), the same names ``/analyze`` reports. A glob must match the whole name, so a pattern for text in the middle of a name needs ``*`` on both sides. BlueTopo contributor names look like ``H11445_MB_VR_MLLW.interpolated``, ``GMRT_61m_US3MA1AD`` and ``US,US,graph,Chart 12300_20030301_US3MA1AC_20260417``: ``*.interpolated`` and ``*Chart*`` match them, ``Chart*`` does not. A pattern that starts with ``(?i)`` or ``^`` is a regular expression matched from the start of the name.
71
+ - **keep_gmrt_derived**: ``noaa_bluetopo`` only. On the outer shelf BlueTopo carries NOAA's resampled copy of GMRT, in contributors named ``GMRT_*``. When the policy also has a ``gmrt`` step, these contributors are skipped by default so GMRT is not fused twice (the skip is logged at INFO). Set ``keep_gmrt_derived: true`` to keep them. Kept or not, they are marked ``derived_from: gmrt`` in the provenance.
71
72
  - **max_interpolation_gap_m**: Float distance in meters. Any internal `NaN` gap (data holiday) smaller than this physical distance will be natively interpolated via distance-transform morphology by the provider before it is merged. This heals "screen-door" artifacts without blurring the actual survey boundaries.
73
+ - **exclude_tid** / **include_tid**: ``gebco_2025`` only; give one, not both. A list of GEBCO type identifier (TID) codes: cells whose TID is in ``exclude_tid``, or not in ``include_tid``, are dropped. The codes are those GEBCO 2025 publishes (table below); any other value fails validation. Added in 0.3.0.
74
+ - **drop_plateaus**: any provider. Drops small flat patches whose level is far from that of the cells around them, such as the constant blocks some gridded products leave where a fill was pasted into surveyed terrain. A patch is a 4-connected group of cells whose neighbors differ by at most ``tolerance_m`` and whose values span at most twice that. It is dropped when it has ``min_cells`` to ``max_cells`` cells and its median differs by more than ``min_offset_m`` from the median of the one-cell ring around it (at least 4 finite ring cells). Added in 0.3.0.
75
+
76
+ .. code-block:: yaml
77
+
78
+ - provider: "gebco_2025"
79
+ operation: "overwrite"
80
+ filter:
81
+ exclude_tid: [70] # pre-generated grids
82
+ drop_plateaus:
83
+ min_offset_m: 50 # required
84
+ min_cells: 4 # default 4
85
+ max_cells: 400 # default 400; larger flats are terrain (shelf, plains)
86
+ tolerance_m: 1.0 # default 1.0
87
+
88
+ ``drop_plateaus`` runs on the provider's native grid, before alignment to the canvas, because resampling smears a flat patch into its surroundings. Over the 12.3 million cells of 614 cached GEBCO 2025 tiles (northeastern United States and a few test areas), ``min_offset_m: 50`` with the other defaults dropped 8 cells, all on land: a lake 80 m below its rim and a flat summit 71 m above its ring. Lakes and flat summits are real, so on a step that also covers land, check what the filter drops (the step outcome counts it as ``plateaus_masked``, and the log names the cell).
89
+
90
+ Both filters set dropped cells to NaN, so the cell is treated like any other cell without data: earlier policy steps show through it under ``overwrite`` and transition rules, and ``metric_feather`` blends the step in from the edge of the hole. Where no earlier step has data, the cell stays NaN, apart from the one- and two-pixel gap fill applied to every fused cell. At 15 arc-seconds a dropped GEBCO cell is about 460 m across, so give such areas a layer beneath (or above) that covers them. Step outcomes report the counts as ``tid_masked`` and ``plateaus_masked``.
91
+
92
+ A policy that uses neither option keeps its cache key from before 0.3.0: options left unset are omitted from the policy content that the key hashes.
93
+
94
+ .. list-table:: GEBCO 2025 type identifier (TID) codes
95
+ :header-rows: 1
96
+ :widths: 10 90
97
+
98
+ * - TID
99
+ - Source
100
+ * - 0
101
+ - Land
102
+ * - 10-17
103
+ - Direct measurement: 10 singlebeam, 11 multibeam, 12 seismic, 13 isolated sounding, 14 ENC sounding, 15 lidar, 16 optical light sensor, 17 combination of direct methods
104
+ * - 40-46
105
+ - Indirect: 40 predicted from satellite gravity, 41 interpolated by computer algorithm, 42 contours from charts, 43 contours from ENCs, 44 bathymetric sounding, 45 predicted from flight-derived gravity, 46 grounded iceberg draft
106
+ * - 70-72
107
+ - Unknown: 70 pre-generated grid, 71 unknown source, 72 steering points
72
108
 
73
109
  Operators
74
110
  ---------
@@ -57,11 +57,11 @@ dependencies:
57
57
  - ipykernel
58
58
  # Documentation
59
59
  - sphinx
60
- - sphinx-rtd-theme
61
60
  - myst-parser
62
61
  - sphinxcontrib-mermaid
63
62
  # pip-only (stale or missing on conda-forge)
64
63
  - pip:
65
64
  - httpx
66
65
  - pydap
66
+ - lhzn-sphinx-theme>=0.1,<0.2
67
67
  - -e .
@@ -23,7 +23,10 @@ variables:
23
23
  filter:
24
24
  layer: "topo-mask"
25
25
 
26
- # Surveyed BlueTopo contributors only (no interpolated, upsampled or generalized cells)
26
+ # Surveyed BlueTopo contributors only (no interpolated, upsampled, generalized or chart
27
+ # cells). On the outer shelf BlueTopo also carries NOAA's resampled copy of GMRT
28
+ # (GMRT_61m_*); because this policy has a gmrt step, those contributors are skipped
29
+ # without an exclude pattern. Set keep_gmrt_derived: true to keep them.
27
30
  - provider: "noaa_bluetopo"
28
31
  operation: "metric_feather"
29
32
  blend_distance: 300.0
@@ -32,6 +35,7 @@ variables:
32
35
  - "(?i).*interpolated.*"
33
36
  - "(?i).*upsampled.*"
34
37
  - "(?i).*generaliz.*"
38
+ - "*Chart*"
35
39
 
36
40
  # Survey truth
37
41
  - provider: "ncei_bag"
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "topobathykit"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "Policy-driven topobathymetric fusion: fuses overlapping elevation sources into seamless grids with per-pixel provenance."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -43,6 +43,10 @@
43
43
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"></path><path d="M13 13l6 6"></path></svg>
44
44
  3D DEM Viewer
45
45
  </a>
46
+ <a href="/viewer/tile-viewer.html" target="_blank">
47
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="1 6 1 22 8 18 16 22 23 18 23 2 16 6 8 2 1 6"></polygon><line x1="8" y1="2" x2="8" y2="18"></line><line x1="16" y1="6" x2="16" y2="22"></line></svg>
48
+ Tile Viewer
49
+ </a>
46
50
  </nav>
47
51
  <div class="sidebar-footer">
48
52
  <p>Status: <span class="status-indicator online"></span> Online</p>
@@ -12,7 +12,7 @@
12
12
  #panel {
13
13
  position: absolute; top: 16px; left: 16px; z-index: 10;
14
14
  background: rgba(20, 20, 28, 0.92); padding: 16px; border-radius: 8px;
15
- width: 290px; font-size: 13px;
15
+ width: 340px; font-size: 13px;
16
16
  box-shadow: 0 4px 20px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.08);
17
17
  }
18
18
  #panel h3 { margin: 0 0 4px; font-size: 15px; color: #e0e0e0; }
@@ -35,6 +35,12 @@
35
35
  button:disabled { background: #333 !important; color: #555 !important; cursor: not-allowed; opacity: 0.6; }
36
36
  #stats { font-size: 11px; color: #666; margin-top: 10px; padding-top: 8px; border-top: 1px solid #222; line-height: 1.5; }
37
37
  #error-msg { color: #f55; font-size: 12px; margin-top: 8px; display: none; }
38
+ #dataset-select { font-size: 12px; }
39
+ #dataset-info { font-size: 11px; color: #aaa; margin-top: 6px; line-height: 1.45; word-break: break-word; }
40
+ #dataset-info .row { display: flex; gap: 6px; }
41
+ #dataset-info .k { color: #777; flex: 0 0 70px; }
42
+ #dataset-info .v { min-width: 0; overflow-wrap: anywhere; }
43
+ #dataset-info .desc { color: #888; margin-top: 3px; max-height: 4.4em; overflow-y: auto; }
38
44
 
39
45
  #tooltip {
40
46
  position: absolute; z-index: 20; pointer-events: none; display: none;
@@ -73,11 +79,12 @@
73
79
 
74
80
  <div id="panel">
75
81
  <h3>topobathykit DEM Viewer</h3>
76
- <p class="subtitle"><a href="/viewer/cache-viewer.html">&larr; Cache Manager</a> &middot; <a href="/viewer/hydrate.html">Hydrate</a></p>
82
+ <p class="subtitle"><a href="/viewer/cache-viewer.html">&larr; Cache Manager</a> &middot; <a href="/viewer/hydrate.html">Hydrate</a> &middot; <a href="/viewer/tile-viewer.html">Tile Viewer</a></p>
77
83
 
78
84
  <div class="ctrl">
79
85
  <label>Fused Dataset</label>
80
86
  <select id="dataset-select"><option value="">Loading datasets...</option></select>
87
+ <div id="dataset-info"></div>
81
88
  <div class="row" style="gap:4px;margin-top:4px">
82
89
  <button onclick="loadDataset()" style="flex:1">Load DEM</button>
83
90
  <button onclick="clearCache()" title="Delete cached mosaic and rebuild" style="background:#555;flex:0">Clear Cache</button>
@@ -118,6 +125,8 @@
118
125
  <div id="quality-stats" style="font-size:11px; color:#5af; margin-top:8px; display:none;"></div>
119
126
  </div>
120
127
 
128
+ <div id="nav-keys" style="font-size:11px; color:#888; margin-top:10px; line-height:1.5;"></div>
129
+
121
130
  <div id="provenance-stats"></div>
122
131
  <div id="stats">Select a dataset and click Load.</div>
123
132
  <div id="error-msg"></div>
@@ -145,14 +154,17 @@
145
154
  {
146
155
  "imports": {
147
156
  "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
148
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
157
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/",
158
+ "camera-controls": "https://cdn.jsdelivr.net/npm/camera-controls@3.1.2/dist/camera-controls.module.min.js",
159
+ "vantagekit/three": "https://cdn.jsdelivr.net/gh/lhzn-io/vantagekit@v0.8.3/vantagekit-three.js"
149
160
  }
150
161
  }
151
162
  </script>
152
163
 
153
164
  <script type="module">
154
165
  import * as THREE from 'three';
155
- import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
166
+ import CameraControls from 'camera-controls';
167
+ import { createVantage } from 'vantagekit/three';
156
168
 
157
169
  // ── State ──
158
170
  let demData = null;
@@ -175,15 +187,28 @@ const scene = new THREE.Scene();
175
187
  const camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 0.1, 5000);
176
188
  camera.position.set(0, 300, 400);
177
189
 
178
- const controls = new OrbitControls(camera, canvas);
179
- controls.enableDamping = true;
180
- controls.dampingFactor = 0.08;
181
- controls.screenSpacePanning = true;
182
- controls.maxPolarAngle = Math.PI * 0.85;
183
- controls.mouseButtons = { LEFT: THREE.MOUSE.PAN, MIDDLE: THREE.MOUSE.DOLLY, RIGHT: THREE.MOUSE.ROTATE };
190
+ // Navigation (vantagekit on camera-controls): left drag pans, right drag rotates, the wheel
191
+ // zooms toward the cursor and keeps going past the closest distance; WASD/QE and a gamepad move
192
+ // at a speed set in meters per second. The camera is kept in the URL for sharing.
193
+ const nav = createVantage({
194
+ THREE, CameraControls, camera, dom: canvas,
195
+ metersPerUnit: 100, // SCENE_SCALE = 0.01 scene units per meter
196
+ exaggeration: () => meshExag || 1,
197
+ mouse: 'pan-left',
198
+ minDistance: 0.5, // 50 m; the near plane is 10 m
199
+ maxPolarAngle: Math.PI * 0.85,
200
+ link: true, // writes cv/cam beside the existing ?dataset=
201
+ });
202
+ nav.readLink();
184
203
 
185
204
  // ── Lighting ──
186
- scene.add(new THREE.AmbientLight(0x404050, 0.6));
205
+ // Hemisphere fill in place of a flat ambient: faces pointing up get the same fill as before,
206
+ // faces pointing down (the underside, seen from below the surface) get a warm tint instead of
207
+ // near black, so flying under the terrain shows where you are.
208
+ scene.add(new THREE.HemisphereLight(0x404050, 0xb08a60, 0.6));
209
+ const underLight = new THREE.DirectionalLight(0xffe0c0, 0.6); // lights only downward faces
210
+ underLight.position.set(-100, -400, 200);
211
+ scene.add(underLight);
187
212
  const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
188
213
  dirLight.position.set(200, 400, 300);
189
214
  scene.add(dirLight);
@@ -329,23 +354,16 @@ function rebuildMesh({ frameCamera = false } = {}) {
329
354
  // to anchorY * ratio. Shifting camera and target by the same offset
330
355
  // keeps it at the same place on screen, with the view direction and
331
356
  // distance unchanged.
332
- if (anchorY !== null) {
333
- const dy = anchorY * (zExag / prevExag - 1);
334
- controls.target.y += dy;
335
- camera.position.y += dy;
336
- controls.update();
337
- }
357
+ if (anchorY !== null) nav.rescaleVertical(prevExag, zExag, anchorY);
338
358
  return;
339
359
  }
340
- const box = new THREE.Box3().setFromObject(solidMesh);
341
- const center = box.getCenter(new THREE.Vector3());
342
- const size = box.getSize(new THREE.Vector3());
343
- const maxSpan = Math.max(size.x, size.z);
344
- const elevAngle = 40 * Math.PI / 180;
345
- const dist = maxSpan * 0.9;
346
- controls.target.copy(center);
347
- camera.position.set(center.x, center.y + dist * Math.sin(elevAngle), center.z + dist * Math.cos(elevAngle));
348
- controls.update();
360
+ // The scene origin is the bounds centre (see buildTerrain), so links are geographic.
361
+ const [lonMin, latMin, lonMax, latMax] = demData.meta.bounds;
362
+ nav.setOrigin({ lon: (lonMin + lonMax) / 2, lat: (latMin + latMax) / 2 });
363
+ // Looking north from 40 degrees up, at 0.9 times the larger horizontal span.
364
+ nav.fitBox(new THREE.Box3().setFromObject(solidMesh));
365
+ nav.saveHome();
366
+ nav.applyLink(); // a shared view replaces the framing, once
349
367
  }
350
368
 
351
369
  function applyRenderMode() {
@@ -390,6 +408,45 @@ window.setRenderMode = function(mode) {
390
408
  };
391
409
 
392
410
  // ── Dataset Discovery ──
411
+ const datasetsById = {};
412
+
413
+ function escapeHtml(s) {
414
+ return String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
415
+ }
416
+
417
+ function shortDate(iso) {
418
+ return iso ? iso.slice(0, 16).replace('T', ' ') : '';
419
+ }
420
+
421
+ function bboxText(bbox) {
422
+ return bbox ? `W ${bbox[0].toFixed(3)}, S ${bbox[1].toFixed(3)}, E ${bbox[2].toFixed(3)}, N ${bbox[3].toFixed(3)}` : 'unknown';
423
+ }
424
+
425
+ // Option text carries the policy name itself, since a closed select shows no group label.
426
+ function datasetLabel(ds) {
427
+ const name = ds.policy_name || 'Unnamed policy';
428
+ const version = ds.policy_version ? ` v${ds.policy_version}` : '';
429
+ const updated = ds.updated ? ` | ${shortDate(ds.updated)}` : '';
430
+ return `${name}${version} | ${ds.resolution_m} m | ${ds.cell_count} cells | ${ds.policy_hash}${updated}`;
431
+ }
432
+
433
+ function showDatasetInfo() {
434
+ const ds = datasetsById[document.getElementById('dataset-select').value];
435
+ const el = document.getElementById('dataset-info');
436
+ if (!ds) { el.innerHTML = ''; return; }
437
+ const rows = [
438
+ ['Policy', ds.policy_name || '(no saved policy file)'],
439
+ ['Version', ds.policy_version || ''],
440
+ ['Policy file', ds.policy_file || ''],
441
+ ['Cache key', `${ds.policy_hash_full} (dataset ${ds.id})`],
442
+ ['Grid', `${ds.resolution_m} m, ${ds.crs}, ${ds.cell_count} cells`],
443
+ ['Extent', bboxText(ds.bbox)],
444
+ ['Updated', ds.updated ? `${shortDate(ds.updated)} UTC` : ''],
445
+ ].filter(r => r[1]);
446
+ el.innerHTML = rows.map(([k, v]) => `<div class="row"><span class="k">${k}</span><span class="v">${escapeHtml(v)}</span></div>`).join('') +
447
+ (ds.policy_description ? `<div class="desc">${escapeHtml(ds.policy_description)}</div>` : '');
448
+ }
449
+
393
450
  async function populateDatasets() {
394
451
  try {
395
452
  const showTiles = document.getElementById('show-tiles')?.checked;
@@ -400,26 +457,53 @@ async function populateDatasets() {
400
457
  sel.innerHTML = '';
401
458
  if (datasets.length === 0) {
402
459
  sel.innerHTML = '<option value="">No fused datasets found</option>';
460
+ showDatasetInfo();
403
461
  return;
404
462
  }
405
- for (const ds of datasets) {
406
- const opt = document.createElement('option');
407
- opt.value = ds.id;
408
- const bbox = ds.bbox ? `[${ds.bbox.map(v => v.toFixed(2)).join(', ')}]` : '';
409
- opt.textContent = `${ds.id} (${ds.cell_count} cells) ${bbox}`;
410
- sel.appendChild(opt);
463
+
464
+ // Group by policy name, newest dataset first within a name.
465
+ const groups = new Map();
466
+ const sorted = [...datasets].sort((a, b) =>
467
+ (a.policy_name || '~').localeCompare(b.policy_name || '~') ||
468
+ (b.updated || '').localeCompare(a.updated || '') ||
469
+ a.id.localeCompare(b.id));
470
+ for (const ds of sorted) {
471
+ datasetsById[ds.id] = ds;
472
+ const key = ds.policy_name || 'Unnamed policy (no saved policy file)';
473
+ if (!groups.has(key)) groups.set(key, []);
474
+ groups.get(key).push(ds);
475
+ }
476
+ const placeholder = document.createElement('option');
477
+ placeholder.value = '';
478
+ placeholder.textContent = `Choose a dataset (${datasets.length})...`;
479
+ sel.appendChild(placeholder);
480
+ for (const [name, list] of groups) {
481
+ const group = document.createElement('optgroup');
482
+ group.label = name;
483
+ for (const ds of list) {
484
+ const opt = document.createElement('option');
485
+ opt.value = ds.id;
486
+ opt.textContent = datasetLabel(ds);
487
+ opt.title = [ds.policy_file, bboxText(ds.bbox), ds.policy_description].filter(Boolean).join('\n');
488
+ group.appendChild(opt);
489
+ }
490
+ sel.appendChild(group);
411
491
  }
412
492
 
413
493
  // Auto-select from URL param
414
494
  const params = new URLSearchParams(window.location.search);
415
- if (params.has('dataset')) {
495
+ if (params.has('dataset') && datasetsById[params.get('dataset')]) {
416
496
  sel.value = params.get('dataset');
497
+ showDatasetInfo();
417
498
  loadDataset();
499
+ } else {
500
+ showDatasetInfo();
418
501
  }
419
502
  } catch (e) {
420
503
  document.getElementById('dataset-select').innerHTML = '<option value="">Failed to load datasets</option>';
421
504
  }
422
505
  }
506
+ document.getElementById('dataset-select').addEventListener('change', showDatasetInfo);
423
507
 
424
508
  // ── Cache Management ──
425
509
  window.clearCache = async function() {
@@ -430,11 +514,11 @@ window.clearCache = async function() {
430
514
  const r = await fetch(`/api/v1/dem/datasets/${datasetId}/cache`, {method:'DELETE'});
431
515
  const j = await r.json();
432
516
  if (r.ok) {
433
- document.getElementById('info').innerText = `Cache cleared: ${j.deleted?.join(', ') || 'nothing to clear'}. Click Load DEM to rebuild.`;
517
+ document.getElementById('stats').innerText = `Cache cleared: ${j.deleted?.join(', ') || 'nothing to clear'}. Click Load DEM to rebuild.`;
434
518
  } else {
435
- document.getElementById('info').innerText = `Clear failed: ${j.detail || r.statusText}`;
519
+ document.getElementById('stats').innerText = `Clear failed: ${j.detail || r.statusText}`;
436
520
  }
437
- } catch(e) { document.getElementById('info').innerText = `Clear error: ${e.message}`; }
521
+ } catch(e) { document.getElementById('stats').innerText = `Clear error: ${e.message}`; }
438
522
  };
439
523
 
440
524
  // ── Data Loading ──
@@ -475,6 +559,10 @@ window.loadDataset = async function() {
475
559
  }
476
560
 
477
561
  demData = { buffer, meta };
562
+ // Keep the loaded dataset in the address bar so the view can be shared or reloaded.
563
+ const pageUrl = new URL(window.location);
564
+ pageUrl.searchParams.set('dataset', policyPrefix);
565
+ window.history.replaceState({}, '', pageUrl);
478
566
 
479
567
  let validCount = 0, nanCount = 0, minZ = Infinity, maxZ = -Infinity;
480
568
  for (let i = 0; i < buffer.length; i++) {
@@ -488,8 +576,12 @@ window.loadDataset = async function() {
488
576
  const lodSuffix = meta.scale < 0.99
489
577
  ? ` (LoD ${(meta.scale * 100).toFixed(0)}%, full: ${meta.full_width}x${meta.full_height})`
490
578
  : '';
579
+ const loaded = datasetsById[policyPrefix];
580
+ const loadedName = loaded && loaded.policy_name
581
+ ? `${escapeHtml(loaded.policy_name)}${loaded.policy_version ? ' v' + escapeHtml(loaded.policy_version) : ''}<br>`
582
+ : '';
491
583
  document.getElementById('stats').innerHTML =
492
- `<b>${policyPrefix}</b> (${meta.cell_count} cells)<br>` +
584
+ `Loaded: ${loadedName}<b>${policyPrefix}</b> (${meta.cell_count} cells)<br>` +
493
585
  `Grid: ${meta.width} x ${meta.height} (${(buffer.length / 1e6).toFixed(1)}M cells)${lodSuffix}<br>` +
494
586
  `Bounds: ${meta.bounds[0].toFixed(4)}, ${meta.bounds[1].toFixed(4)} &rarr; ${meta.bounds[2].toFixed(4)}, ${meta.bounds[3].toFixed(4)}<br>` +
495
587
  `CRS: ${meta.crs}<br>` +
@@ -593,7 +685,7 @@ canvas.addEventListener('mousemove', (event) => {
593
685
  canvas.addEventListener('mouseleave', () => { tooltip.style.display = 'none'; _cellAtLat = null; _cellAtLon = null; });
594
686
 
595
687
  let rightMouseDownTime = 0;
596
- canvas.addEventListener('mousedown', (event) => {
688
+ canvas.addEventListener('pointerdown', (event) => {
597
689
  if (event.button === 2) {
598
690
  rightMouseDownTime = Date.now();
599
691
  }
@@ -713,32 +805,19 @@ canvas.addEventListener('contextmenu', async (event) => {
713
805
  }
714
806
  });
715
807
 
716
- // ── WASD Movement ──
717
- const keysDown = {};
718
- const MOVE_SPEED = 2.0;
719
- window.addEventListener('keydown', (e) => { if (e.target.tagName === 'INPUT' || e.target.tagName === 'SELECT') return; keysDown[e.key.toLowerCase()] = true; });
720
- window.addEventListener('keyup', (e) => { keysDown[e.key.toLowerCase()] = false; });
721
-
722
- function applyWASD() {
723
- const forward = new THREE.Vector3(); camera.getWorldDirection(forward); forward.y = 0; forward.normalize();
724
- const strafe = new THREE.Vector3(-forward.z, 0, forward.x);
725
- const delta = new THREE.Vector3();
726
- if (keysDown['w']) delta.add(forward);
727
- if (keysDown['s']) delta.sub(forward);
728
- if (keysDown['a']) delta.sub(strafe);
729
- if (keysDown['d']) delta.add(strafe);
730
- if (keysDown['q'] || keysDown['e']) delta.y += keysDown['e'] ? 1 : -1;
731
- if (delta.lengthSq() > 0) {
732
- delta.normalize().multiplyScalar(MOVE_SPEED);
733
- if (keysDown['shift']) delta.multiplyScalar(4);
734
- camera.position.add(delta);
735
- controls.target.add(delta);
736
- }
737
- }
808
+ // ── Navigation help (from the binding table) ──
809
+ const keyName = (k) => k.startsWith('Arrow') ? k.slice(5) : k.replace(/^Key/, '').replace(/(Left|Right)$/, '');
810
+ document.getElementById('nav-keys').innerHTML =
811
+ 'Left drag pans, right drag rotates, wheel zooms.<br>' +
812
+ nav.bindings.filter((b) => b.keys.length)
813
+ .map((b) => `<b>${[...new Set(b.keys.map(keyName))].join('/')}</b> ${b.label.toLowerCase()}`)
814
+ .join(', ') +
815
+ '.<br>A gamepad moves with the left stick and looks with the right.';
738
816
 
739
817
  // ── Resize + Render Loop ──
740
818
  window.addEventListener('resize', () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); });
741
- function animate() { requestAnimationFrame(animate); applyWASD(); controls.update(); renderer.render(scene, camera); }
819
+ const clock = new THREE.Clock();
820
+ function animate() { requestAnimationFrame(animate); nav.update(clock.getDelta()); renderer.render(scene, camera); }
742
821
  animate();
743
822
  populateDatasets();
744
823
  let qualityGroup = null;