Skip to content

Feature/terrain 3d - #26

Open
acalcutt wants to merge 8 commits into
mainfrom
feature/terrain-3d
Open

Feature/terrain 3d#26
acalcutt wants to merge 8 commits into
mainfrom
feature/terrain-3d

Conversation

@acalcutt

Copy link
Copy Markdown
Collaborator

No description provided.

acalcutt and others added 4 commits July 15, 2026 21:24
Temporary: use the custom maplibre-native (WifiDB fork,
terrain-3d-color-relief) so the C ABI / MAUI apps can try the 3D terrain and
color-relief features before they land upstream. Swaps the submodule URL to the
fork and the pinned commit from v13.3.1 to the terrain branch tip. Revert to the
upstream URL/commit once the terrain work is merged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Terrain is a style root property, so it was only reachable by loading a whole
style JSON. Expose it directly for runtime on/off (like maplibre-gl-js
TerrainControl):

- C ABI: mbgl_style_set_terrain(source_id, exaggeration),
  mbgl_style_remove_terrain, mbgl_style_is_terrain_enabled, over
  Style::setTerrain/getTerrain.
- Binding: NativeMethods P/Invokes and MbglStyle.SetTerrain/RemoveTerrain/
  IsTerrainEnabled.
- Control: MapLibreMap.SetTerrain/RemoveTerrain/ToggleTerrain/IsTerrainEnabled,
  through the controller interface and the Windows/Android/MaciOS controllers.
  ToggleTerrain reads the live style state so it stays correct across reloads.

The raster-dem source is added the usual way (AddRasterDemSource) and may be
shared with a hillshade layer; sources and layers already had add/remove, so
only the terrain property was missing. Needs a native rebuild for the new
exports.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A "Terrain" tab whose style (OSM raster + hillshade over the Mapterhorn DEM,
pitched over Innsbruck via the style-spec root camera) starts flat; a button
calls MapLibreMap.ToggleTerrain to drape it over 3D terrain and back, updating
its label from IsTerrainEnabled. The style is plain maplibre-style-spec with no
terrain property - terrain is enabled through the API, not the JSON.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MlnMapImage gets SetTerrain/RemoveTerrain/ToggleTerrain/IsTerrainEnabled over
MbglStyle, matching the MAUI control. The WPF sample adds a "3D Terrain" preset
style (OSM raster + hillshade over the Mapterhorn DEM, pitched over Innsbruck,
plain style-spec with no terrain property) and a Toggle 3D Terrain button that
enables/disables terrain through the API.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
acalcutt and others added 4 commits July 16, 2026 09:39
Rework both samples so terrain is toggled on whatever style is loaded, using a
configurable raster-dem source, instead of a dedicated terrain style:

- MAUI Terrain page: a style picker + a terrain-source picker (preset Matterhorn
  or a custom tilejson/tiles URL). The toggle adds the picked raster-dem to the
  current style (once per style load) and calls ToggleTerrain.
- WPF sample: an editable "Terrain source" combo (preset or custom URL); the
  Toggle 3D Terrain button adds that raster-dem to the current style and toggles.

This mirrors how a consuming app would offer a terrain source setting, and lets
terrain drape over any base style. Needs the native rebuilt with the terrain
exports (a stale native was why enabling terrain crashed / showed only hillshade).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Terrain draping over a flat-coloured style is nearly invisible without
relief shading, so the WPF and MAUI sample terrain toggles now add a
hillshade layer from the DEM source when terrain is enabled and remove it
when disabled. Surface AddHillshadeLayer on MlnMapImage (WPF) and
MapLibreMap (MAUI), delegating to the existing style/controller binding.

Add a headless --terraintest harness and MlnMapImage.SnapshotBitmap to the
WPF sample that enable terrain over a style on the offscreen WGL backend
and snapshot the frame, used to verify terrain draping renders on the
Windows GL path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds an on-map terrain toggle button across all four backends (Windows,
Android, iOS, WPF), matching the existing navigation and GPS controls.
Clicking it toggles terrain on TerrainControlSourceId — enable if off,
disable if on — mirroring maplibre-gl-js's TerrainControl. The raster-dem
source must already exist in the style; the control does not add sources
or hillshade (styles usually include hillshade themselves).

New properties on MapLibreMap and MlnMapImage:
  ShowTerrainControl (default false), TerrainControlSourceId,
  TerrainControlExaggeration, TerrainControlPosition.

The default source id is app-specific ("mln-terrain-dem") rather than a
generic name like "terrain" so it won't collide with a real style source.
The button stacks above the navigation control in its corner.

Plumbed through the handler mapper, options sink and per-platform builders
like the other Show* controls. Samples enable the control and add the DEM
(+ a hillshade layer, so the relief is visible) on style load so the
button has a source to toggle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The experimental 3D-terrain work we were carrying on the WifiDB fork has
landed upstream (#4190, plus #4389 as 81d19a3bd2a0), so the submodule now
points at maplibre/maplibre-native feature/terrain-3d instead of the fork.

That branch also carries main's two renames: #4487 moved the C++ namespace
mbgl -> mln, and #4511 moved the mbgl/ header directories to mln/. Applied
both to native/ (includes, mln:: qualifiers, namespace blocks, and the
platform/default/src stub paths in CMakeLists). The mbgl_* C ABI export
names and the mbgl-core / mbgl-vendor-* CMake target names are unchanged
upstream, so they stay as they are.

Verified with a Windows OpenGL build of mln-cabi.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant