|
23 | 23 | line-height: 1.6; |
24 | 24 | box-shadow: 3px 3px 3px grey, -3px -3px 3px #ddd; |
25 | 25 | "> |
| 26 | + <input type="radio" id="radio_hyps" name="rdreliefstyle" value="hyps" checked> |
| 27 | + <label for="radio_hyps">Relief - Hypsometric tints</label> <select id="hypscol"></select><br> |
| 28 | + <input type="radio" id="radio_joyplot" name="rdreliefstyle" value="joyplot"> |
| 29 | + <label for="radio_joyplot">Relief - Joyplot</label><br> |
26 | 30 | <label for="cbLabels"><input type="checkbox" id="cbLabels" checked>City names</label> |
27 | 31 | <br> |
28 | 32 | <label for="cbPopulation"><input type="checkbox" id="cbPopulation" checked>Population dots</label> |
|
32 | 36 | <label for="cbRoads"><input type="checkbox" id="cbRoads">Roads</label> |
33 | 37 | <br> |
34 | 38 | <label for="cbCLC"><input type="checkbox" id="cbCLC" checked>Land cover waters</label> |
35 | | - <br> |
36 | | - <label for="cbRelief"><input type="checkbox" id="cbRelief" checked>Relief hypsometric tints</label> <select |
37 | | - id="hypscol"></select> |
38 | 39 | <hr> |
39 | 40 | <label>Sea level rise: <span id="lbSeaLevel">-</span></label> |
40 | 41 | <br> |
41 | 42 | <input type="range" id="sSeaLevel" min="0" max="100" step="1" value="0" style="width:300px;"> |
42 | 43 | <br> |
43 | 44 | <label for="cbHypssea"><input type="checkbox" id="cbHypssea">Adjust hypsometric colors to sea level</label> |
44 | 45 | <hr> |
45 | | - <label for="cbTanaka"><input type="checkbox" id="cbTanaka">Relief tanaka style (slow)</label> |
46 | | - <br> |
47 | | - <label for="cbHillshading"><input type="checkbox" id="cbHillshading">Relief hillshading (slow)</label> |
48 | | - <br> |
49 | | - <label>Relief hypsometric tints number</label> |
50 | | - <input type="range" min="2" max="25" value="8" step="1" id="sReliefNb" style="width: 200px" /> |
51 | | - <br> |
52 | | - <label>Relief exageration</label> |
53 | | - <input type="range" min="-15" max="15" value="0" step="1" id="sReliefExageration" style="width: 200px" /> |
54 | | - <br> |
55 | | - <label>Relief smoothing (slow)</label> |
56 | | - <input type="range" min="0" max="10" value="0" step="0.25" id="sReliefSmoothing" style="width: 200px" /> |
57 | | - <hr> |
58 | | - <label for="cbHD"><input type="checkbox" id="cbHD">HD (very slow)</label> |
| 46 | + <div id="hyps_div"> |
| 47 | + <label for="cbTanaka"><input type="checkbox" id="cbTanaka">Relief tanaka style (slow)</label> |
| 48 | + <br> |
| 49 | + <label for="cbHillshading"><input type="checkbox" id="cbHillshading">Relief hillshading (slow)</label> |
| 50 | + <br> |
| 51 | + <label>Relief hypsometric tints number</label> |
| 52 | + <input type="range" min="2" max="25" value="8" step="1" id="sReliefNb" style="width: 200px" /> |
| 53 | + <br> |
| 54 | + <label>Relief exageration</label> |
| 55 | + <input type="range" min="-15" max="15" value="0" step="1" id="sReliefExageration" style="width: 200px" /> |
| 56 | + <br> |
| 57 | + <label>Relief smoothing (slow)</label> |
| 58 | + <input type="range" min="0" max="10" value="0" step="0.25" id="sReliefSmoothing" style="width: 200px" /> |
| 59 | + <hr> |
| 60 | + <label for="cbHD"><input type="checkbox" id="cbHD">HD (very slow)</label> |
| 61 | + </div> |
| 62 | + <div id="joyplot_div" style="display: none;">No option yet</div> |
59 | 63 | </div> |
60 | 64 |
|
61 | 65 | <script src="../../dist/gridviz.js"></script> |
|
196 | 200 |
|
197 | 201 | const cbTanaka = document.getElementById("cbTanaka"); |
198 | 202 | const cbHillshading = document.getElementById("cbHillshading"); |
199 | | - const cbRelief = document.getElementById("cbRelief"); |
200 | 203 | const sReliefSmoothing = document.getElementById('sReliefSmoothing'); |
201 | 204 | const sReliefNb = document.getElementById('sReliefNb'); |
202 | 205 | const sReliefExageration = document.getElementById('sReliefExageration'); |
|
214 | 217 | let scaleShadingCoeff = -2 |
215 | 218 | let shadingDiamond = false |
216 | 219 | let quantile = false |
217 | | - let joyplot = false |
218 | 220 |
|
219 | 221 | function update() { |
220 | 222 | const seaLevel = +sSeaLevel.value; |
221 | 223 | lbSeaLevel.textContent = seaLevel + ' m'; |
222 | 224 |
|
| 225 | + const rsty = document.querySelector('input[name="rdreliefstyle"]:checked').value; |
| 226 | + document.getElementById("hyps_div").style.display = rsty == "hyps" ? 'inline-block' : 'none' |
| 227 | + document.getElementById("joyplot_div").style.display = rsty == "joyplot" ? 'inline-block' : 'none' |
| 228 | + |
223 | 229 | let styleWater = new gridviz.SquareColorCategoryWebGLStyle({ |
224 | 230 | code: (c) => "a", |
225 | 231 | color: { 'a': seaColor }, |
|
307 | 313 | viewScale: cells => d3.extent(cells, c => c.v), |
308 | 314 | height: (c, r, z, [min, max]) => 15 * r * scaleRelief((c.v - min) / (max - min)), |
309 | 315 | lineColor: (y, ys, r, z) => "#b58500", |
310 | | - lineWidth: (y, ys, r, z) => z/1.5, |
| 316 | + lineWidth: (y, ys, r, z) => z / 1.5, |
311 | 317 | fillColor: (y, ys, r, z) => "#b5850022" |
312 | 318 | }) |
313 | 319 |
|
314 | 320 | // definition |
315 | 321 | const mppc = (cbHD.checked ? 0.7 : 1.4) * resolutionCoeff |
316 | | - const mppcRelief = joyplot ? 3 * resolutionCoeff : mppc |
317 | | - let reliefStyle = joyplot ? joyplotStyle : hypsoStyle |
| 322 | + const mppcRelief = rsty == "joyplot" ? 3 * resolutionCoeff : mppc |
| 323 | + let reliefStyle = rsty == "joyplot" ? joyplotStyle : hypsoStyle |
318 | 324 |
|
319 | 325 | // smoothing |
320 | 326 | const sr = +sReliefSmoothing.value |
|
355 | 361 |
|
356 | 362 | // set layers |
357 | 363 | const layers = [] |
358 | | - // relief |
359 | | - if (cbRelief.checked) layers.push(new gridviz.GridLayer(datasetRelief, [reliefStyle], { minPixelsPerCell: mppcRelief, cellInfoHTML: cellInfoHTMLRelief })) |
360 | | - // relief tanaka |
361 | | - if (cbTanaka.checked) layers.push(new gridviz.GridLayer(datasetRelief, [tanakaStyle], { minPixelsPerCell: mppc, cellInfoHTML: 'none' })) |
362 | | - //relief shading |
363 | | - if (cbHillshading.checked) layers.push(new gridviz.GridLayer(datasetRelief, [shadingStyle], { minPixelsPerCell: mppc, cellInfoHTML: 'none' })) |
| 364 | + |
| 365 | + //relief layer |
| 366 | + const reliefStyles = [] |
| 367 | + if (rsty == "joyplot") reliefStyles.push( |
| 368 | + new gridviz.SquareColorCategoryWebGLStyle({ |
| 369 | + code: (c) => "a", |
| 370 | + color: { 'a': "white" }, |
| 371 | + filter: (c) => c.v >=0, |
| 372 | + })) |
| 373 | + reliefStyles.push(reliefStyle) |
| 374 | + if (cbTanaka.checked && rsty == "hyps") reliefStyles.push(tanakaStyle) |
| 375 | + if (cbHillshading.checked && rsty == "hyps") reliefStyles.push(shadingStyle) |
| 376 | + layers.push(new gridviz.GridLayer(datasetRelief, reliefStyles, { minPixelsPerCell: mppcRelief, cellInfoHTML: cellInfoHTMLRelief })) |
| 377 | + |
364 | 378 | // CLC waters |
365 | 379 | if (cbCLC.checked) layers.push(new gridviz.GridLayer(datasetCLC, [styleCLCWater], { minPixelsPerCell: mppc, cellInfoHTML: 'none' })) |
366 | 380 | // population |
|
379 | 393 | } |
380 | 394 |
|
381 | 395 | //add event listeners |
| 396 | + document.getElementById("radio_hyps").addEventListener('input', update); |
| 397 | + document.getElementById("radio_joyplot").addEventListener('input', update); |
382 | 398 | sSeaLevel.addEventListener('input', update); |
383 | 399 | cbTanaka.addEventListener("change", update); |
384 | 400 | cbHillshading.addEventListener("change", update); |
385 | | - cbRelief.addEventListener("change", update); |
386 | 401 | sReliefSmoothing.addEventListener("input", update); |
387 | 402 | sReliefNb.addEventListener("input", update); |
388 | 403 | sReliefExageration.addEventListener("input", update); |
|
406 | 421 | } |
407 | 422 | //else if (e.key == "t") { tanaka = !tanaka; update() } |
408 | 423 | else if (e.key == "q") { quantile = !quantile; update() } |
409 | | - else if (e.key == "j") { |
410 | | - joyplot = !joyplot; |
411 | | - map.setBackgroundColor("white") |
412 | | - update() |
413 | | - } |
414 | 424 | else if (e.key == "d") { shadingDiamond = !shadingDiamond; update() } |
415 | 425 | else if (e.key == "w") { scaleShadingCoeff -= 0.25; console.log(scaleShadingCoeff); update() } |
416 | 426 | else if (e.key == "x") { scaleShadingCoeff += 0.25; console.log(scaleShadingCoeff); update() } |
|
0 commit comments