Skip to content

Commit

Permalink
ts-518 Inject time tile params better
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Mar 27, 2024
1 parent 39b221a commit a22b5a1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/essence/Basics/Layers_/leaflet-tilelayer-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ var colorFilterExtension = {
.replace(/{starttime}/g, this.options.starttime)
.replace(/{endtime}/g, this.options.endtime)
if (this.options.time && this.options.tileFormat === 'tms') {
url += `?starttime=${this.options.starttime}&time=${this.options.endtime}`
if (this.options.compositeTile === true) url += `&composite=true`
let paramDelimiter = '?'
let urlParams = {}
if (url.indexOf('?') !== -1) {
urlParams = new URLSearchParams(url.split('?')[1])
paramDelimiter = '&'
}

if (!urlParams.has('starttime')) {
url += `${paramDelimiter}starttime=${this.options.starttime}`
paramDelimiter = '&'
}
if (!urlParams.has('time')) {
url += `${paramDelimiter}time=${this.options.endtime}`
paramDelimiter = '&'
}
if (!urlParams.has('composite')) {
if (this.options.compositeTile === true)
url += `&${paramDelimiter}omposite=true`

This comment has been minimized.

Copy link
@tamarmot

tamarmot Mar 27, 2024

this line looks like you have typos? composite or omposite.

}
}
return url
},
Expand Down

3 comments on commit a22b5a1

@tamarmot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we could simply replace {starttime} or {endtime} wherever we wanted them in any url. ie a/b?apple={starttime}&banana={endtime}

@tamarmot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our tile format is wms and not tms and MMGIS is replacing TIME={starttime} with the value TIME=endtime.

@tamarmot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the layer:
{
"name": "Sun",
"uuid": "f01ec035-d127-47d2-b691-5305960fe600",
"description": "",
"type": "tile",
"url": "../../../map/lunaserv?SERVICE=WMS&VERSION=1.1.1&LAYERS=luna_sun_2024&TIME={starttime}",
"demparser": "",
"controlled": false,
"visibility": false,
"initialOpacity": 1,
"togglesWithHeader": true,
"minZoom": 0,
"maxNativeZoom": 16,
"maxZoom": 18,
"variables": {},
"tags": [
"reloadStrategy:time__hours__2"
],
"tileformat": "wms",
"time": {
"enabled": true,
"type": "requery",
"isRelative": true,
"current": "",
"start": "2024-11-10T00:00:00",
"end": "2025-05-01T00:00:00",
"startProp": "",
"endProp": "",
"format": "%Y-%m-%dT%H:%M:%SZ",
"compositeTile": false,
"refresh": "1 hours",
"increment": "5 minutes"
}
},

Please sign in to comment.