Skip to content

Commit

Permalink
#581 COGs through TiTiler
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Sep 10, 2024
1 parent 529747a commit 6b84c16
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 46 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ See the [configuration documentation](https://nasa-ammos.github.io/MMGIS/configu

1. Go back to the root `/` directory

1. Run `python -m pip install -r python-requirements.txt`

1. If using adjacent-servers (titiler, stac, ...) make `.env` files from the samples within the `/adjacent-servers/{servers}/` directory.

1. Run `npm run start:prod`

1. Setup the admin account:
Expand Down
2 changes: 1 addition & 1 deletion adjacent-servers/stac/start-stac.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:: ###############################################################################
:: STAC
dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port %1
python -m dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port %1
2 changes: 1 addition & 1 deletion adjacent-servers/stac/start-stac.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
###############################################################################
# STAC
dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port $1
python -m dotenv run python -m uvicorn stac_fastapi.pgstac.app:app --port $1
2 changes: 1 addition & 1 deletion adjacent-servers/tipg/start-tipg.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
: ###############################################################################
:: tipg
dotenv run python -m uvicorn tipg.main:app --port %1
python -m dotenv run python -m uvicorn tipg.main:app --port %1
2 changes: 1 addition & 1 deletion adjacent-servers/tipg/start-tipg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
###############################################################################
# tipg
dotenv run python -m uvicorn tipg.main:app --port $1
python -m dotenv run python -m uvicorn tipg.main:app --port $1
2 changes: 1 addition & 1 deletion adjacent-servers/titiler-pgstac/start-titiler-pgstac.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:: ###############################################################################
:: TiTiler-pgSTAC
dotenv run python -m uvicorn titiler.pgstac.main:app --port %1
python -m dotenv run python -m uvicorn titiler.pgstac.main:app --port %1

2 changes: 1 addition & 1 deletion adjacent-servers/titiler-pgstac/start-titiler-pgstac.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
###############################################################################
# TiTiler-pgSTAC
dotenv run python -m uvicorn titiler.pgstac.main:app --port $1
python -m dotenv run python -m uvicorn titiler.pgstac.main:app --port $1
2 changes: 1 addition & 1 deletion adjacent-servers/titiler/start-titiler.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:: ###############################################################################
:: TiTiler
dotenv run python -m uvicorn titiler.application.main:app --port %1
python -m dotenv run python -m uvicorn titiler.application.main:app --port %1
2 changes: 1 addition & 1 deletion adjacent-servers/titiler/start-titiler.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
###############################################################################
# TiTiler
dotenv run python -m uvicorn titiler.application.main:app --port $1
python -m dotenv run python -m uvicorn titiler.application.main:app --port $1
10 changes: 9 additions & 1 deletion configure/src/metaconfigs/layer-tile-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@
"name": "Tile Format",
"description": "",
"type": "dropdown",
"width": 4,
"width": 2,
"options": ["tms", "wmts", "wms"]
},
{
"field": "throughTileServer",
"name": "Use TiTiler",
"description": "Uses the TiTiler service to serve tiles if URL is a Cloud-Optimized GeoTiff (COG). TiTiler must be configured via the .env.",
"type": "switch",
"width": 2,
"defaultChecked": false
},
{
"field": "controlled",
"name": "Controlled",
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/Setup/Installation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ See the [configuration documentation](https://nasa-ammos.github.io/MMGIS/configu

1. Go back to the root `/` directory

1. Run `python -m pip install -r python-requirements.txt`

1. If using adjacent-servers (titiler, stac, ...) make `.env` files from the samples within the `/adjacent-servers/{servers}/` directory.

1. Run `npm run start:prod`

1. Setup the admin account:
Expand Down
14 changes: 7 additions & 7 deletions python-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
numpy==1.26.4
spiceypy==5.1.2
pymap3d==3.0.1
python-dotenv[cli]=1.0.1
uvicorn=0.30.6
psycopg[binary,pool]=3.2.1
stac-fastapi-pgstac=3.0.0
tipg=0.7.2
titiler.application=0.18.6
titiler-pgstac=1.3.1
python-dotenv[cli]==1.0.1
uvicorn==0.30.6
psycopg[binary,pool]==3.2.1
stac-fastapi-pgstac==3.0.0
tipg==0.7.2
titiler.application==0.18.6
titiler-pgstac==1.3.1
26 changes: 20 additions & 6 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ const L_ = {
if (L_._onSpecificLayerToggleSubscriptions[fid] != null)
delete L_._onSpecificLayerToggleSubscriptions[fid]
},
getUrl: function (type, url, layerData) {
let nextUrl = url
if (type === 'tile') {
if (!F_.isUrlAbsolute(nextUrl)) {
nextUrl = L_.missionPath + nextUrl
if (layerData && layerData.throughTileServer === true)
nextUrl = `../../${nextUrl}`
}
if (layerData && layerData.throughTileServer === true)
nextUrl = `${window.location.origin}/titiler/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.webp?url=${nextUrl}`
}
return nextUrl
},
//Takes in config layer obj
//Toggles a layer on and off and accounts for sublayers
//Takes in a config layer object
Expand Down Expand Up @@ -425,13 +438,10 @@ const L_ = {
L_._layersOrdered.indexOf(s.name)
)
}

if (s.type === 'tile') {
let layerUrl = s.url
if (!F_.isUrlAbsolute(layerUrl))
layerUrl = L_.missionPath + layerUrl
let demUrl = s.demtileurl
if (!F_.isUrlAbsolute(demUrl))
demUrl = L_.missionPath + demUrl
let layerUrl = L_.getUrl(s.type, s.url, s)
let demUrl = L_.getUrl(s.type, s.demtileurl, s)
if (s.demtileurl == undefined || s.demtileurl.length == 0)
demUrl = undefined
L_.Globe_.litho.addLayer('tile', {
Expand Down Expand Up @@ -3563,6 +3573,10 @@ function parseConfig(configData, urlOnLayers) {
if (d[i].time == null) {
d[i].time = { enabled: false }
}

if (d[i].type === 'tile' && d[i].throughTileServer === true) {
d[i].tileformat = 'wmts'
}
}

//Create parsed layers data
Expand Down
9 changes: 3 additions & 6 deletions src/essence/Basics/Map_/Map_.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,7 @@ async function makeVectorLayer(
}

async function makeTileLayer(layerObj) {
let layerUrl = layerObj.url
if (!F_.isUrlAbsolute(layerUrl)) layerUrl = L_.missionPath + layerUrl
let layerUrl = L_.getUrl(layerObj.type, layerObj.url, layerObj)
let bb = null
if (layerObj.hasOwnProperty('boundingBox')) {
bb = L.latLngBounds(
Expand Down Expand Up @@ -917,8 +916,7 @@ async function makeTileLayer(layerObj) {
}

function makeVectorTileLayer(layerObj) {
var layerUrl = layerObj.url
if (!F_.isUrlAbsolute(layerUrl)) layerUrl = L_.missionPath + layerUrl
let layerUrl = L_.getUrl(layerObj.type, layerObj.url, layerObj)

let urlSplit = layerObj.url.split(':')

Expand Down Expand Up @@ -1100,8 +1098,7 @@ function makeModelLayer(layerObj) {
}

function makeDataLayer(layerObj) {
let layerUrl = layerObj.demtileurl
if (!F_.isUrlAbsolute(layerUrl)) layerUrl = L_.missionPath + layerUrl
let layerUrl = L_.getUrl(layerObj.type, layerObj.demtileurl, layerObj)

let bb = null
if (layerObj.hasOwnProperty('boundingBox')) {
Expand Down
7 changes: 5 additions & 2 deletions src/essence/Tools/Identifier/IdentifierTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ var IdentifierTool = {
if (L_.layers.on[n] == true) {
//We only want the tile layers
if (L_.layers.data[n].type == 'tile') {
var url = L_.layers.data[n].url
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
let url = L_.getUrl(
L_.layers.data[n].type,
L_.layers.data[n].url,
L_.layers.data[n]
)
IdentifierTool.activeLayerURLs.push(url)
IdentifierTool.activeLayerNames.push(n)
IdentifierTool.zoomLevels.push(
Expand Down
27 changes: 15 additions & 12 deletions src/essence/Tools/Layers/LayersTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,20 +304,22 @@ function interfaceWithMMGIS(fromInit) {
case 'tile':
layerExport = ''
// Add download URL for raster layers
if(node[i].hasOwnProperty('variables')) {
if(node[i].variables.hasOwnProperty('downloadURL')) {
if (node[i].hasOwnProperty('variables')) {
if (node[i].variables.hasOwnProperty('downloadURL')) {
layerExport = [
'<ul>',
'<li>',
'<div class="layersToolExportSourceGeoJSON">',
`<div><a href="` + node[i].variables.downloadURL + `" target="_blank">Download Data</a></div>`,
'</div>',
'</li>',
'<li>',
'<div class="layersToolExportSourceGeoJSON">',
`<div><a href="` +
node[i].variables.downloadURL +
`" target="_blank">Download Data</a></div>`,
'</div>',
'</li>',
'</ul>',
].join('\n')
}
}
break
break
default:
layerExport = ''
}
Expand Down Expand Up @@ -967,10 +969,11 @@ function interfaceWithMMGIS(fromInit) {
}
)
} else {
let layerUrl = layerData.url

if (!F_.isUrlAbsolute(layerUrl))
layerUrl = L_.missionPath + layerUrl
let layerUrl = L_.getUrl(
layerData.type,
layerData.url,
layerData
)
$.getJSON(layerUrl, function (data) {
if (data.hasOwnProperty('Features')) {
data.features = data.Features
Expand Down
7 changes: 5 additions & 2 deletions src/essence/Tools/Shade/ShadeTool_Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,11 @@ let ShadeTool_Manager = {
this.data[shadeId].dataSource = source
},
queryDesiredTiles: function (shadeId, progcb, cb) {
let url = this.data[shadeId].dataLayer.demtileurl
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
let url = L_.getUrl(
this.data[shadeId].dataLayer.type,
this.data[shadeId].dataLayer.demtileurl,
this.data[shadeId].dataLayer
)

let totalTiles = this.data[shadeId].desiredTiles.length
let tilesLoaded = 0
Expand Down
7 changes: 5 additions & 2 deletions src/essence/Tools/Viewshed/ViewshedTool_Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ let ViewshedTool_Manager = {
.floor()
},
queryDesiredTiles: function (viewshedId, progcb, cb) {
let url = this.data[viewshedId].dataLayer.demtileurl
if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url
let url = L_.getUrl(
this.data[viewshedId].dataLayer.type,
this.data[viewshedId].dataLayer.demtileurl,
this.data[viewshedId].dataLayer
)

let totalTiles = this.data[viewshedId].desiredTiles.length
let tilesLoaded = 0
Expand Down

0 comments on commit 6b84c16

Please sign in to comment.