-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,033 additions
and
45 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'astro/config' | ||
import solid from '@astrojs/solid-js'; | ||
|
||
export default defineConfig({ | ||
site: "https://vis.fairicube.eu", | ||
integrations: [solid()], | ||
output: "static", | ||
publicDir: "static", | ||
outDir: "public", | ||
}) |
This file contains 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
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { createResource, createSignal } from "solid-js"; | ||
import { getAllSTACItems } from "../scripts/getAllItems"; | ||
import { showWholeCollection } from "./utils/ShowWholeCollection"; | ||
|
||
export default function STACTreeView(props) { | ||
|
||
|
||
//const [STACCatalogs, setSTACCatalogs] = createSignal(); | ||
const [dummySignal, setDummySignal] = createSignal(); | ||
|
||
const [STACCatalogs] = createResource(dummySignal, getAllSTACItems); | ||
|
||
|
||
setDummySignal(true); | ||
|
||
return <For each={STACCatalogs()} fallback={<div>Loading...</div>}> | ||
|
||
{(collection, collectionIdx) => { | ||
return <ViewCollection collection={collection} /> | ||
}} | ||
</For> | ||
} | ||
|
||
function ViewCollection({collection}) { | ||
|
||
|
||
return <div>{collection.title}: | ||
|
||
<button onClick={() => showWholeCollection(collection.links.filter(link => link.rel == "self")[0].href)}>Show whole collection</button> | ||
|
||
<ul> | ||
<For each={collection.items}> | ||
{(item, itemIdx) => { | ||
return <li>{item.id}<br/> | ||
<For each={Object.entries(item.assets)}> | ||
{(entry) => { | ||
const [key, val] = entry; | ||
// If val.rolesdoes not contain "data", skip | ||
if (!val.roles.includes("data")) return <>🔗</> | ||
return <div>🔎 {val?.description ?? val.id ?? key}: {val.href}</div> | ||
}} | ||
</For> | ||
|
||
</li> | ||
}} | ||
</For> | ||
</ul> | ||
</div> | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Map from 'ol/Map.js'; | ||
import OSM from 'ol/source/OSM.js'; | ||
import STAC from '../../ol/layer/STAC'; | ||
import TileLayer from 'ol/layer/WebGLTile.js'; | ||
import View from 'ol/View.js'; | ||
import proj4 from 'proj4'; | ||
import {getStacObjectsForEvent} from '../../ol/util.js'; | ||
import {register} from 'ol/proj/proj4.js'; | ||
|
||
register(proj4); // required to support source reprojection | ||
|
||
export function showWholeCollection(collectionUrl){ | ||
|
||
const layer = new STAC({ | ||
url: collectionUrl, | ||
displayPreview: true, | ||
collectionStyle: { | ||
color: 'red', | ||
}, | ||
assets: ['data'], | ||
|
||
}); | ||
|
||
const background = new TileLayer({source: new OSM()}); | ||
|
||
const map = new Map({ | ||
target: 'map-container', | ||
layers: [background, layer], | ||
view: new View({ | ||
center: [0, 0], | ||
zoom: 0, | ||
}), | ||
}); | ||
map.on('singleclick', async (event) => { | ||
const objects = await getStacObjectsForEvent(event); | ||
if (objects.length > 0) { | ||
objects.forEach((obj) => console.log(obj)); | ||
} | ||
}); | ||
|
||
layer.on('sourceready', () => { | ||
const view = map.getView(); | ||
view.fit(layer.getExtent()); | ||
}); | ||
|
||
return false; | ||
|
||
} |
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
async function getGeotiffMinmaxFromAuxXML(geotiffSourceURL){ | ||
try { | ||
|
||
const auxurl = geotiffSourceURL.replace('.tif','.tif.aux.xml'); | ||
const aux = await fetch(auxurl); | ||
const auxxml = await aux.text(); | ||
const auxdoc = new DOMParser().parseFromString(auxxml, 'text/xml'); | ||
const min = auxdoc.querySelector('[key="STATISTICS_MINIMUM"]').textContent; | ||
const max = auxdoc.querySelector('[key="STATISTICS_MAXIMUM"]').textContent; | ||
return [parseFloat(min), parseFloat(max)]; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
|
||
export default getGeotiffMinmaxFromAuxXML; | ||
|
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../.astro/types.d.ts" /> |
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// import d3 scalechromatic | ||
import * as d3 from 'd3'; | ||
/* | ||
import { palette } from '../components/App.js'; | ||
export function getInterpolateBand1AsColor() { | ||
const pal = palette(); | ||
if (pal.toLowerCase()=='rgb')return { color: ['array', ['band', 1], ['band', 2], ['band', 3], 1] }; | ||
let color = null; | ||
if (pal=='A') color = d3.scaleSequential(d3.interpolateRainbow); | ||
if (pal=='B') color = d3.scaleSequential(d3.interpolateViridis); | ||
if (pal=='C') color = d3.scaleSequential(d3.interpolateWarm); | ||
if (pal=='D') color = d3.scaleSequential(d3.interpolateGnBu); | ||
const clr_arr = [ | ||
'interpolate', | ||
['linear'], | ||
['band', 1], | ||
0, | ||
[255,0,0,0], | ||
0.001, | ||
color(0.001), | ||
0.1, | ||
color(0.1), | ||
0.1, | ||
color(0.1), | ||
0.2, | ||
color(0.2), | ||
0.4, | ||
color(0.4), | ||
0.6, | ||
color(0.6), | ||
1, | ||
color(1) | ||
]; | ||
interpolation_to_colorbar(clr_arr.slice(3)); | ||
return {color: clr_arr}; | ||
} | ||
// Given a MapLibre color interpolation array like [value, color, value, color, ...], create a | ||
// colorbar elelement with a CSS background gradient | ||
// that matches the color ramp | ||
function interpolation_to_colorbar(interp){ | ||
const colorbar = document.getElementById('colorbar'); | ||
colorbar.innerHTML = ''; | ||
for (let i = 0; i < interp.length; i+=2){ | ||
let div = document.createElement('div'); | ||
div.innerHTML = interp[i]; // Value | ||
colorbar.appendChild(div); | ||
} | ||
const maxValue = interp[interp.length-2]; | ||
let gradient = ''; | ||
for (let i = 0; i < interp.length; i+=2){ | ||
const value = interp[i]; | ||
const percent = (value/maxValue)*100; | ||
let clr = interp[i+1]; | ||
// If the color is an array, convert it to a string | ||
if (Array.isArray(clr)) clr = `rgba(${clr.join(',')})`; | ||
gradient += clr + ' ' + percent + '%, '; | ||
} | ||
gradient = gradient.slice(0, -2); | ||
colorbar.style.background = 'linear-gradient(to right, ' + gradient + ')'; | ||
} | ||
*/ |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
<div class="choosepalette"> | ||
<div> | ||
<label><input type="radio" name="palette" value="A" checked />Palette A</label> | ||
<label><input type="radio" name="palette" value="B" />Palette B</label> | ||
<label><input type="radio" name="palette" value="C" />Palette C</label> | ||
<label><input type="radio" name="palette" value="D" />Palette D</label> | ||
<label><input type="radio" name="palette" value="RGB" | ||
/>True Color</label> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
<script> | ||
|
||
|
||
// Change the palette | ||
document.querySelectorAll('input[name="palette"]').forEach( (radio : Element) => { | ||
// Trigger a "palette" event when the palette is changed | ||
if (radio) (radio as HTMLInputElement).onchange = () => document.dispatchEvent(new Event('newpalette')); | ||
}); | ||
|
||
|
||
|
||
// Listen for the "newsource" event. If localStorage.url ends with .tiff, then make the True Color option visible. | ||
document.addEventListener('newsource', () => { | ||
const url = localStorage.getItem('url'); | ||
const isTiff = url && url.endsWith('.tif'); | ||
const rgbLabel = document.querySelector('label[value="RGB"]') as HTMLLabelElement; | ||
if (rgbLabel) rgbLabel.style.display = isTiff ? 'initial' : 'none'; | ||
}); | ||
|
||
</script> | ||
|
||
<style> | ||
.choosepalette { | ||
display: flex; | ||
width: 100%; | ||
position: absolute; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-end; | ||
|
||
div { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: start; | ||
align-content: start; | ||
justify-items: start; | ||
justify-content: start; | ||
gap: 1rem; | ||
label { | ||
cursor: pointer; | ||
font-family: 'Inter', sans-serif; | ||
} | ||
} | ||
|
||
top:0; | ||
height: 100vh; | ||
right: 1rem; | ||
gap: 1rem; | ||
} | ||
</style> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<div id="colorbar"></div> | ||
|
||
<script> | ||
|
||
// Listen for the changes to palette or source | ||
document.addEventListener('newpalette', updateColorbar); | ||
document.addEventListener('newsource', updateColorbar); | ||
|
||
|
||
function updateColorbar() { | ||
console.log('newpalette - updating colorbar'); | ||
|
||
const el = document.getElementById('colorbar'); | ||
if (!el) return; | ||
|
||
const palette = localStorage.getItem('palette'); | ||
|
||
el.style.display = (palette=='rgb') ? 'none' : 'block'; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
</script> | ||
<style> | ||
|
||
#colorbar { | ||
position: absolute; | ||
bottom: 50px; | ||
right: 50px; | ||
width: 200px; | ||
height: 5px; | ||
background: none; | ||
border-radius: 5px; | ||
background-color: none; | ||
backdrop-filter: blur(5px); | ||
padding: 10px; | ||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
color: darkslategray; | ||
background-color: var(--nilu-dark-gray); | ||
font-size: 0.8em; | ||
border-radius: 5px; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
div { | ||
mix-blend-mode: plus-lighter; | ||
color: white; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.