Skip to content

Commit c1ee950

Browse files
committed
#372 transformCog support for COG:
1 parent be43049 commit c1ee950

File tree

4 files changed

+52
-29
lines changed

4 files changed

+52
-29
lines changed

src/essence/Basics/Layers_/Layers_.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,6 @@ const L_ = {
271271
nextUrl = `/${nextUrl}`
272272
}
273273
}
274-
if (layerData && layerData.throughTileServer === true) {
275-
let bandsParam = ''
276-
if (layerData.cogBands) {
277-
layerData.cogBands.forEach((band) => {
278-
if (band != null) bandsParam += `&bidx=${band}`
279-
})
280-
}
281-
let resamplingParam = ''
282-
if (layerData.cogResampling) {
283-
resamplingParam = `&resampling=${layerData.cogResampling}`
284-
}
285-
286-
nextUrl = `${window.location.origin}${(
287-
window.location.pathname || ''
288-
).replace(/\/$/g, '')}/titiler/cog/tiles/${
289-
layerData.tileMatrixSet || 'WebMercatorQuad'
290-
}/{z}/{x}/{y}.webp?url=${nextUrl}${bandsParam}${resamplingParam}`
291-
}
292274
return nextUrl
293275
},
294276
//Takes in config layer obj
@@ -587,8 +569,12 @@ const L_ = {
587569
}
588570

589571
if (s.type === 'image') {
590-
if (L_.layers.layer[s.name].options.pixelValuesToColorFn
591-
&& L_.layers.layer[s.name].options.pixelValuesToColorFn !== null) {
572+
if (
573+
L_.layers.layer[s.name].options
574+
.pixelValuesToColorFn &&
575+
L_.layers.layer[s.name].options
576+
.pixelValuesToColorFn !== null
577+
) {
592578
L_.layers.layer[s.name].clearCache()
593579
L_.layers.layer[s.name].updateColors(
594580
L_.layers.layer[s.name].options

src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ var colorFilterExtension = {
2020
getTileUrl: function (coords) {
2121
let url = L.TileLayer.prototype.getTileUrl.call(this, coords)
2222

23-
if (this.options.splitColonType === 'stac-collection') {
23+
if (
24+
this.options.splitColonType === 'stac-collection' ||
25+
this.options.splitColonType === 'COG'
26+
) {
2427
let datetime
2528
if (this.options.endtime != null) {
2629
if (this.options.starttime != null) {
@@ -32,11 +35,14 @@ var colorFilterExtension = {
3235
if (datetime != null)
3336
url += `${
3437
url.indexOf('?') === -1 ? '?' : '&'
35-
}datetime=${datetime}&exitwhenfull=false&skipcovered=false`
36-
else
38+
}datetime=${datetime}`
39+
40+
if (this.options.splitColonType === 'stac-collection') {
3741
url += `${
3842
url.indexOf('?') === -1 ? '?' : '&'
3943
}exitwhenfull=false&skipcovered=false`
44+
}
45+
4046
if (this.options.cogMin != null && this.options.cogMax != null) {
4147
url += `${url.indexOf('?') === -1 ? '?' : '&'}rescale=[${
4248
this.options.currentCogMin != null

src/essence/Basics/Map_/Map_.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,23 +1083,27 @@ async function makeTileLayer(layerObj) {
10831083

10841084
let splitColonType
10851085
const splitColonLayerUrl = layerObj.url.split(':')
1086-
if (splitColonLayerUrl[1] != null)
1086+
if (splitColonLayerUrl[1] != null) {
1087+
let bandsParam = ''
1088+
let b
1089+
let resamplingParam = ''
1090+
10871091
switch (splitColonLayerUrl[0]) {
10881092
case 'stac-collection':
10891093
splitColonType = splitColonLayerUrl[0]
10901094
const splitParams = splitColonLayerUrl[1].split('?')
10911095

10921096
// Bands
1093-
let bandsParam = ''
1094-
let b = layerObj.cogBands
1097+
bandsParam = ''
1098+
b = layerObj.cogBands
10951099
if (b != null) {
10961100
b.forEach((band) => {
10971101
if (band != null) bandsParam += `&bidx=${band}`
10981102
})
10991103
}
11001104

11011105
// Resampling
1102-
let resamplingParam = ''
1106+
resamplingParam = ''
11031107
if (layerObj.cogResampling) {
11041108
resamplingParam = `&resampling=${layerObj.cogResampling}`
11051109
}
@@ -1113,9 +1117,32 @@ async function makeTileLayer(layerObj) {
11131117
}/{z}/{x}/{y}?assets=asset${bandsParam}${resamplingParam}`
11141118
layerObj.tileformat = 'wmts'
11151119
break
1120+
case 'COG':
1121+
splitColonType = splitColonLayerUrl[0]
1122+
// Bands
1123+
bandsParam = ''
1124+
b = layerObj.cogBands
1125+
if (b != null) {
1126+
b.forEach((band) => {
1127+
if (band != null) bandsParam += `&bidx=${band}`
1128+
})
1129+
}
1130+
1131+
resamplingParam = ''
1132+
if (layerObj.cogResampling) {
1133+
resamplingParam = `&resampling=${layerObj.cogResampling}`
1134+
}
1135+
1136+
layerUrl = `${window.location.origin}${(
1137+
window.location.pathname || ''
1138+
).replace(/\/$/g, '')}/titiler/cog/tiles/${
1139+
layerObj.tileMatrixSet || 'WebMercatorQuad'
1140+
}/{z}/{x}/{y}.webp?url=${layerUrl}${bandsParam}${resamplingParam}`
1141+
11161142
default:
11171143
break
11181144
}
1145+
}
11191146

11201147
let bb = null
11211148
if (layerObj.hasOwnProperty('boundingBox')) {

src/essence/Tools/Layers/LayersTool.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,16 @@ var LayersTool = {
228228

229229
if (
230230
!layer.url.startsWith('stac-collection:') &&
231+
!layer.url.startsWith('COG:') &&
231232
layer.type !== 'image' &&
232233
layer.type !== 'velocity'
233234
)
234235
return
235236
if (
236237
layer.cogTransform !== true &&
237-
(layer.url.startsWith('stac-collection:') || layer.type === 'image')
238+
(layer.url.startsWith('stac-collection:') ||
239+
layer.url.startsWith('COG:') ||
240+
layer.type === 'image')
238241
)
239242
return
240243
if (
@@ -618,7 +621,8 @@ function interfaceWithMMGIS(fromInit) {
618621
if (
619622
node[i].cogTransform === true &&
620623
typeof node[i].url === 'string' &&
621-
node[i].url.split(':')[0] === 'stac-collection'
624+
(node[i].url.split(':')[0] === 'stac-collection' ||
625+
node[i].url.split(':')[0] === 'COG')
622626
) {
623627
if (window.mmgisglobal.WITH_TITILER === 'true') {
624628
// prettier-ignore

0 commit comments

Comments
 (0)