feat: add slope layer type for DEM-based slope visualization#7098
Open
eddy-geek wants to merge 1 commit intomaplibre:mainfrom
Open
feat: add slope layer type for DEM-based slope visualization#7098eddy-geek wants to merge 1 commit intomaplibre:mainfrom
eddy-geek wants to merge 1 commit intomaplibre:mainfrom
Conversation
Implements a new 'slope' layer type that computes slope angle from raster-dem sources using the Horn (1981) algorithm and maps the result to a user-defined color ramp. New files: - src/shaders/slope.fragment.glsl — Horn algorithm slope computation with proper meters-per-pixel cell size conversion - src/shaders/slope.vertex.glsl — vertex shader (based on color-relief) - src/style/style_layer/slope_style_layer.ts — style layer class with slope color ramp and texture management - src/render/draw_slope.ts — render function - src/render/program/slope_program.ts — uniform definitions Paint properties: - slope-opacity: number [0-1], default 1 - slope-color: color ramp expression (interpolate over elevation), values represent slope in degrees [0-90] Registered in: painter.ts, shaders.ts, program_uniforms.ts, create_style_layer.ts Includes render tests (slope/rainbow, slope/opacity) and a demo HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a new 'slope' layer type that computes slope angle from raster-dem sources using the Horn (1981) algorithm and maps the result to a user-defined color ramp.
Slopes are important for mountain activities like ski-touring.
Example sites: https://www.openslopemap.org/karte/ ; https://snowmap.fr/ ; https://gpx.studio/
All sites today rely on dedicated raster layers which means:
Related style update: maplibre/maplibre-style-spec#1497
Example, using the awesome mapterhorn:

I only needed slope and initially missed #6711 , so I understand we may want to handle this in a more generic way.
Also,
multiplyblending as per #13583 would improve readability a lot for this use-case too.New files:
Paint properties:
Registered in: painter.ts, shaders.ts, program_uniforms.ts, create_style_layer.ts
Includes render tests (slope/rainbow, slope/opacity) and a demo HTML.
Note: AI-assisted (Claude), all code reviewed by me
Launch Checklist
CHANGELOG.mdunder the## mainsection.