Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add contour line endpoint for terrain #1458

Draft
wants to merge 166 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
f60de38
add terrain preview and elevation link
Oct 13, 2024
619c7f3
add elevation api for terrain tiles
Oct 13, 2024
21a2559
add documentation for elevation api
Oct 13, 2024
c94bd22
applied lint:js:fix
Oct 13, 2024
ac8e038
Merge branch 'maptiler:master' into terrain-and-elevation
okimiko Dec 17, 2024
20ffc99
Add `test-docker` for test execution in docker build environment
okimiko Dec 19, 2024
24154d0
Fix too greedy router expression
okimiko Dec 19, 2024
0e87d45
Add pmtile support
okimiko Dec 21, 2024
239f107
add encoding param to pmtile section
Dec 21, 2024
484de1e
add map controls
okimiko Dec 22, 2024
2e92e57
remove not needed check
Dec 22, 2024
49fa9e1
fix possible float usage in thumbnail url
Dec 22, 2024
56eb295
update readme for encoding option
Dec 25, 2024
c124b5e
test 1 - not working
acalcutt Dec 21, 2024
77c4e31
test 2
acalcutt Dec 21, 2024
85ec258
test 3
acalcutt Dec 21, 2024
15a654f
Revert "test 3"
acalcutt Dec 21, 2024
7ed3ac4
formatting
acalcutt Dec 21, 2024
25af93c
remove unuded metadata variable
acalcutt Dec 21, 2024
978c8cd
fix data download
acalcutt Dec 21, 2024
616717d
partially working
acalcutt Dec 21, 2024
88b8554
test 4
acalcutt Dec 21, 2024
ba6054f
get sharp image generation working
acalcutt Dec 22, 2024
02ab2b4
add levels
acalcutt Dec 22, 2024
9477a4b
change levels
acalcutt Dec 22, 2024
a8d7295
remove unneeded pngjs
acalcutt Dec 22, 2024
12c9d12
rename functions
acalcutt Dec 22, 2024
e6a892d
update levels
acalcutt Dec 22, 2024
8dd927e
first attempt to upgrade express to v5
acalcutt Dec 29, 2024
b72f662
try to fix https://github.com/maptiler/tileserver-gl/issues/1411
acalcutt Dec 29, 2024
c7377e8
cleanup server.js
acalcutt Dec 29, 2024
2e74bc7
cleanup serve_font.js
acalcutt Dec 29, 2024
61e81e0
cleanup sever_rendered.js
acalcutt Dec 29, 2024
a0fb368
cleanup server_data.js
acalcutt Dec 29, 2024
b638208
cleanup serve_style
acalcutt Dec 29, 2024
d635d3c
Update serve_style.js
acalcutt Dec 29, 2024
c72d6f5
Move UV_THREADPOOL_SIZE to main thred
acalcutt Dec 29, 2024
70d6986
cleanup utils.js
acalcutt Dec 29, 2024
e1460fb
Use common app.get for images and static images
acalcutt Dec 30, 2024
8dc3809
add allowedTileSizes and option
acalcutt Dec 30, 2024
ab20e81
cleanup error responses
acalcutt Dec 30, 2024
9f3a7ce
fix /style/id.json with next('route')
acalcutt Dec 30, 2024
1f0ee0d
improve sprite path
acalcutt Dec 30, 2024
d255cdc
add parseFloadts around zxy
acalcutt Dec 30, 2024
c4adfa8
simplify server_data
acalcutt Dec 30, 2024
3aaab82
move tile fetch and add fix verbose logging
acalcutt Dec 30, 2024
848f7c5
add Handling request to verbose logging
acalcutt Dec 30, 2024
5a883d9
first attempt to upgrade express to v5
acalcutt Dec 29, 2024
c9bc1ec
try to fix https://github.com/maptiler/tileserver-gl/issues/1411
acalcutt Dec 29, 2024
12b818b
cleanup server.js
acalcutt Dec 29, 2024
b6537b5
cleanup serve_font.js
acalcutt Dec 29, 2024
d521546
cleanup sever_rendered.js
acalcutt Dec 29, 2024
279421c
cleanup server_data.js
acalcutt Dec 29, 2024
8ea4b50
cleanup serve_style
acalcutt Dec 29, 2024
7cbafe8
Update serve_style.js
acalcutt Dec 29, 2024
08e1d34
Move UV_THREADPOOL_SIZE to main thred
acalcutt Dec 29, 2024
c0e14bd
cleanup utils.js
acalcutt Dec 29, 2024
40ecf4c
Use common app.get for images and static images
acalcutt Dec 30, 2024
d98cc33
add allowedTileSizes and option
acalcutt Dec 30, 2024
4c6f379
cleanup error responses
acalcutt Dec 30, 2024
592e74c
fix /style/id.json with next('route')
acalcutt Dec 30, 2024
32fd488
improve sprite path
acalcutt Dec 30, 2024
576f02e
add parseFloadts around zxy
acalcutt Dec 30, 2024
d6f7f5e
simplify server_data
acalcutt Dec 30, 2024
99afa33
move tile fetch and add fix verbose logging
acalcutt Dec 30, 2024
d5d938b
add Handling request to verbose logging
acalcutt Dec 30, 2024
6fddbae
merge elevation changes
acalcutt Jan 2, 2025
8186aa1
lint format
acalcutt Jan 2, 2025
7133587
Merge branch 'express-5-v2' into express-5
acalcutt Jan 2, 2025
0d72d57
add verbose logging, improve headers
acalcutt Jan 3, 2025
468779b
try to fix codeql
acalcutt Jan 3, 2025
8bdd14a
test
acalcutt Jan 3, 2025
3260611
all tests passing
acalcutt Jan 3, 2025
ff4ab84
cleanup unneeded changes
acalcutt Jan 3, 2025
d0aad8e
cleanup
acalcutt Jan 3, 2025
4c58ebb
try to fix codeql error
acalcutt Jan 3, 2025
6ab84eb
font fixes
acalcutt Jan 3, 2025
a805302
fix tile size issue
acalcutt Jan 3, 2025
5f85802
try to improve scale + codeql
acalcutt Jan 4, 2025
b825c9a
codeql for sprite logging
acalcutt Jan 4, 2025
e1cae33
codeql serve fonts
acalcutt Jan 4, 2025
e6750dc
codeql fixes
acalcutt Jan 4, 2025
8420ef1
fix failing test with multiple fonts
acalcutt Jan 4, 2025
faf01d7
Update serve_font.js
acalcutt Jan 4, 2025
3517060
codeql
acalcutt Jan 4, 2025
d4aaa62
codeql
acalcutt Jan 4, 2025
afa5952
codeql
acalcutt Jan 4, 2025
2be472b
Update utils.js
acalcutt Jan 4, 2025
f6b24a5
codeql
acalcutt Jan 4, 2025
f187d32
codeql
acalcutt Jan 4, 2025
4abc616
codeql
acalcutt Jan 4, 2025
bc85d7a
codeql
acalcutt Jan 4, 2025
4fe9bda
codeql sanitize
acalcutt Jan 4, 2025
7a81e47
Update serve_font.js
acalcutt Jan 4, 2025
0dcf296
Update serve_font.js
acalcutt Jan 4, 2025
2505249
remove useless assignment
acalcutt Jan 4, 2025
4e2e46a
move isGzipped
acalcutt Jan 4, 2025
7e67f40
add if-modified-since and cache-control
acalcutt Jan 4, 2025
23f50d0
use consistent cache control
acalcutt Jan 4, 2025
f888286
reformat
acalcutt Jan 4, 2025
c2f95ab
codeql
acalcutt Jan 5, 2025
3def0d2
codeql
acalcutt Jan 5, 2025
1c5ee75
codeql
acalcutt Jan 5, 2025
59f4dcc
codeql
acalcutt Jan 5, 2025
aa936ea
codeql
acalcutt Jan 5, 2025
1c3baef
codeql
acalcutt Jan 5, 2025
d85226f
codeql
acalcutt Jan 5, 2025
9a98b38
Update serve_font.js
acalcutt Jan 5, 2025
e79e011
Update serve_font.js
acalcutt Jan 5, 2025
dce7732
Update serve_font.js
acalcutt Jan 5, 2025
0f3629c
Update serve_style.js
acalcutt Jan 5, 2025
b1e1d72
Update serve_style.js
acalcutt Jan 5, 2025
e0574b1
Update serve_style.js
acalcutt Jan 5, 2025
96b35a3
Revert "Update serve_style.js"
acalcutt Jan 5, 2025
54bc82c
Revert "Update serve_style.js"
acalcutt Jan 5, 2025
3fedd5b
Revert "Update serve_style.js"
acalcutt Jan 5, 2025
1f69300
Add readFile function
acalcutt Jan 5, 2025
340e5db
use readFile, add path.normalize
acalcutt Jan 5, 2025
7dddbf7
Update serve_rendered.js
acalcutt Jan 5, 2025
62a3212
simplify input checking
acalcutt Jan 5, 2025
5de617d
Update utils.js
acalcutt Jan 5, 2025
e18874f
codeql
acalcutt Jan 5, 2025
aceb306
Revert "codeql"
acalcutt Jan 5, 2025
ecfcaeb
Revert "Update utils.js"
acalcutt Jan 5, 2025
097c0e1
Revert "simplify input checking"
acalcutt Jan 5, 2025
941e283
move allowed functions to utils.js
acalcutt Jan 5, 2025
36cbcf7
use xy[0],xy[1],
acalcutt Jan 10, 2025
8f28789
uprade canvas per https://github.com/maptiler/tileserver-gl/issues/1433
acalcutt Jan 10, 2025
5315123
Merge remote-tracking branch 'upstream/master' into express-5
acalcutt Jan 10, 2025
930e571
make font regex less restrictive
acalcutt Jan 10, 2025
03b1c31
fix regex error
acalcutt Jan 10, 2025
8412c08
add terrain preview and elevation link
Oct 13, 2024
02210f0
add documentation for elevation api
Oct 13, 2024
4d33886
add map controls
okimiko Dec 22, 2024
1f1fe49
update readme for encoding option
Dec 25, 2024
a10555e
test 1 - not working
acalcutt Dec 21, 2024
b95a207
test 2
acalcutt Dec 21, 2024
cd4f162
test 3
acalcutt Dec 21, 2024
fb73f53
Revert "test 3"
acalcutt Dec 21, 2024
088a5e8
formatting
acalcutt Dec 21, 2024
b65ea05
remove unuded metadata variable
acalcutt Dec 21, 2024
5b753ca
partially working
acalcutt Dec 21, 2024
f7883a2
test 4
acalcutt Dec 21, 2024
d4c2ce1
get sharp image generation working
acalcutt Dec 22, 2024
2d90d8a
add levels
acalcutt Dec 22, 2024
1961c24
change levels
acalcutt Dec 22, 2024
07b6ccc
remove unneeded pngjs
acalcutt Dec 22, 2024
15a51ac
rename functions
acalcutt Dec 22, 2024
d9d606b
update levels
acalcutt Dec 22, 2024
43f86e9
add control for contour lines
Jan 3, 2025
1bfeac2
add contour-label
Jan 4, 2025
904f379
add elevation info
Jan 4, 2025
c9e7f10
disable debug log
Jan 7, 2025
56dbeb2
fix rebase issues and update contour router to express5
Jan 10, 2025
6ad99a3
remove base url, re-add encoding based background-color
Jan 10, 2025
450de42
fix further rebase issues
Jan 10, 2025
e1634d1
re-add baseurl, required bei maplibre-gl
Jan 10, 2025
63ff3fc
run lint:js:fix
Jan 10, 2025
eb6a11b
Merge branch 'master' into terrain-elevation-contour
Jan 11, 2025
32668ed
increase opacity of contour lines
Jan 11, 2025
f15d1df
Merge branch 'master' into terrain-elevation-contour
okimiko Feb 4, 2025
4b51f87
Merge remote-tracking branch 'okimiko/terrain-elevation-contour' into…
acalcutt Feb 5, 2025
fc0e36d
use public_url
acalcutt Feb 5, 2025
043c84b
fix mismatched bracket
acalcutt Feb 5, 2025
25702fb
Revert "fix mismatched bracket"
acalcutt Feb 5, 2025
6335abf
Revert "use public_url"
acalcutt Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"express": "5.0.1",
"handlebars": "4.7.8",
"http-shutdown": "1.2.2",
"maplibre-contour": "^0.1.0",
"morgan": "1.10.0",
"pbf": "4.0.1",
"pmtiles": "3.0.7",
Expand Down
65 changes: 65 additions & 0 deletions public/resources/contour-control.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class MaplibreContourControl {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused class MaplibreContourControl.
constructor(options) {
this.source = options["source"];
this.confLayers = options["layers"];
this.visibility = options["visibility"];
}

getDefaultPosition() {
const defaultPosition = "top-right";
return defaultPosition;
}

onAdd(map) {
this.map = map;
this.controlContainer = document.createElement("div");
this.controlContainer.classList.add("maplibregl-ctrl");
this.controlContainer.classList.add("maplibregl-ctrl-group");
this.contourButton = document.createElement("button");
this.contourButton.type = "button";
this.contourButton.textContent = "C";

this.map.on("style.load", () => {
this.confLayers.forEach(layer => {
this.map.setLayoutProperty(layer, "visibility", this.visibility ? "visible" : "none");
if (this.visibility) {
this.controlContainer.classList.add("maplibre-ctrl-contour-active");
this.contourButton.title = "Disable Contours";
} else {
this.contourButton.title = "Enable Contours";
}
});
});

this.contourButton.addEventListener("click", () => {
this.confLayers.forEach(layer => {
var visibility = this.map.getLayoutProperty(layer, "visibility");
if (visibility === "visible") {
this.map.setLayoutProperty(layer, "visibility", "none");
this.controlContainer.classList.remove("maplibre-ctrl-contour-active");
this.contourButton.title = "Disable Contours";
} else {
this.controlContainer.classList.add("maplibre-ctrl-contour-active");
this.map.setLayoutProperty(layer, "visibility", "visible");
this.contourButton.title = "Enable Contours";
}
});
});
this.controlContainer.appendChild(this.contourButton);
return this.controlContainer;
}

onRemove() {
if (
!this.controlContainer ||
!this.controlContainer.parentNode ||
!this.map ||
!this.contourButton
) {
return;
}
this.contourButton.removeEventListener("click");
this.controlContainer.parentNode.removeChild(this.controlContainer);
this.map = undefined;
}
};
44 changes: 44 additions & 0 deletions public/templates/data.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" type="text/css" href="{{public_url}}maplibre-gl-inspect.css{{&key_query}}" />
<script src="{{public_url}}maplibre-gl.js{{&key_query}}"></script>
<script src="{{public_url}}maplibre-gl-inspect.js{{&key_query}}"></script>
<script src="{{public_url}}contour-control.js{{&key_query}}"></script>
{{^is_light}}
<script src="{{public_url}}elevation-control.js{{&key_query}}"></script>
{{/is_light}}
Expand All @@ -23,6 +24,7 @@
h1 {position:absolute;top:5px;right:0;width:240px;margin:0;line-height:20px;font-size:20px;}
#layerList {position:absolute;top:35px;right:0;bottom:0;width:240px;overflow:auto;}
#layerList div div {width:15px;height:15px;display:inline-block;}
.maplibre-ctrl-contour-active button { color: #33b5e5; font-weight: bold; }
{{^is_light}}
.maplibre-ctrl-elevation { padding-left: 5px; padding-right: 5px; }
{{/is_light}}
Expand Down Expand Up @@ -76,6 +78,8 @@
{{/is_terrain}}
{{#is_terrain}}

let baseUrl = window.location.origin;

var style = {
version: 8,
sources: {
Expand All @@ -88,8 +92,13 @@
"type": "raster-dem",
"url": "{{public_url}}data/{{id}}.json",
"encoding": "{{terrain_encoding}}"
},
"contour": {
"type": "vector",
"tiles": [ baseUrl + "/data/{{id}}/contour/{z}/{x}/{y}" ],
Copy link
Collaborator Author

@acalcutt acalcutt Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I would like to do is make a json endpoint for the contour lines, so this does not need baseurl

I tried to use {{public_url}} here also, but "tiles" doesn't like the relative link it seemed.

}
},
"glyphs": "/fonts/{fontstack}/{range}.pbf",
"terrain": {
"source": "terrain"
},
Expand All @@ -114,6 +123,33 @@
"hillshade-illumination-direction": 315,
"hillshade-exaggeration": 0.8
}
},
{
"id": "contours",
"type": "line",
"source": "contour",
"source-layer": "contours",
"paint": {
"line-opacity": 1,
"line-width": ["match", ["get", "level"], 1, 1, 0.5]
}
},
{
"id": "contour-label",
"type": "symbol",
"source": "contour",
"source-layer": "contours",
"filter": [">", ["get", "ele"], 0 ],
"paint": {
"text-halo-color": "white",
"text-halo-width": 1
},
"layout": {
"symbol-placement": "line",
"text-size": 10,
"text-field": "{ele}",
"text-font": ["Noto Sans Bold"]
}
}
]
};
Expand All @@ -139,6 +175,14 @@
})
);

map.addControl(
new MaplibreContourControl({
source: "contour",
visibility: false,
layers: [ "contours", "contour-label" ]
})
);

{{^is_light}}
map.addControl(
new ElevationInfoControl({
Expand Down
Loading
Loading