Skip to content

Commit

Permalink
add titiler
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Feb 6, 2024
1 parent 5f456a4 commit 6114fe7
Show file tree
Hide file tree
Showing 20 changed files with 1,765 additions and 177 deletions.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ services:
- "3000:3000"
profiles:
- dev

titiler:
build: ./titiler
ports:
- "5002:8080"
volumes:
- ./titiler/src:/app/src
environment:
- TITILER_API_ROOT_PATH=tiler
2 changes: 1 addition & 1 deletion nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server {
server_name localhost;
root /var/www;

location ~* ^/data/(.+)/(.+)$ {
location ~* ^/data/(.+) {
try_files $uri $uri/;
}

Expand Down
10 changes: 9 additions & 1 deletion nginx/dev.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ server {
root /var/www;
absolute_redirect off;

location ~* ^/data/(.+)/(.+)$ {
location ~* ^/data/(.+) {
try_files $uri $uri/;
}

location /tiler/ {
proxy_pass http://titiler:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}

location / {
proxy_pass http://vite:3000;
proxy_http_version 1.1;
Expand Down
6 changes: 3 additions & 3 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Generate data script

Upload the data in `data` folder. For example `layers` will contain all the `.tif` files.
Upload the data in `data` folder. For example `seabirds` will contain all the `.tif` files.

```bash
docker compose build
docker compose run cli /app/data/layers --output /app/data/layers
docker compose run cli /app/data/seabirds --output /app/data/seabirds --prefix /app/
```

This will convert all the rasters to cog, applying a colorscale based on `Reds`.
This will convert all the rasters to cog, applying a colorscale based on `Reds`. It will also create the required files (`metadata.json`, `style.json`) in the output directory. `prefix` allows to "remove" from the `cog` path the prefix that is served by nginx.
80 changes: 80 additions & 0 deletions scripts/create_layers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

set -exuo pipefail
shopt -s globstar

url="http://localhost:8080"
credentials="admin:geoserver"
workspace="marcis"
style="$workspace:seabirds"
geoserver_path="file:///opt/marcis"

for file in **/indexer.properties
do
path="$geoserver_path/$(dirname $file)"
layer="$(basename $path)"
curl -v -u "$credentials" --header "Content-Type: application/json" --data "$(
jq --null-input --arg workspace "$workspace" --arg url "$path" --arg layer "$layer" '
{
"coverageStore": {
"name": $layer,
"url": $url,
"type": "ImageMosaic",
"enabled": true,
"workspace": {
"name": $workspace
}
}
}
')" "$url/geoserver/rest/workspaces/$workspace/coveragestores"
curl -v -u "$credentials" --header "Content-Type: application/json" --data "$(
jq --null-input --arg workspace "$workspace" --arg layer "$layer" '
{
"coverage": {
"name": $layer,
"nativeName": $layer,
"namespace": {
"name": $workspace
},
"title": $layer,
"description": "Generated from ImageMosaic",
"keywords": {
"string": [
$layer,
"WCS",
"ImageMosaic"
]
},
"enabled": true,
"metadata": {
"entry": [
{
"@key": "time",
"dimensionInfo": {
"enabled": true,
"presentation": "LIST",
"units": "ISO8601",
"defaultValue": "",
"nearestMatchEnabled": false,
"rawNearestMatchEnabled": false
}
}
]
}
}
}
')" "$url/geoserver/rest/workspaces/$workspace/coveragestores/$layer/coverages"
curl -v -u "$credentials" --header "Content-Type: application/json" --data "$(
jq --null-input --arg workspace "$workspace" --arg layer "$layer" --arg style "$style" '
{
"layer": {
"name": $layer,
"type": "RASTER",
"defaultStyle": {
"name": $style,
"workspace": $workspace
}
}
}
')" -X PUT "$url/geoserver/rest/layers/$workspace:$layer"
done
2 changes: 1 addition & 1 deletion scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ services:
cli:
build: .
volumes:
- ../data:/app/data
- ../data:/data
- ./src:/app/src
Loading

0 comments on commit 6114fe7

Please sign in to comment.