Skip to content

Commit

Permalink
handle null values for toTime with wms getMap
Browse files Browse the repository at this point in the history
  • Loading branch information
guss84 committed Apr 16, 2024
1 parent 10ee53a commit df1d47c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/layer/wms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ export function wmsWmtMsGetMapUrl(
queryParams.bbox = `${bbox.minX},${bbox.minY},${bbox.maxX},${bbox.maxY}`;
queryParams.srs = bbox.crs.authId;

if (!params.fromTime) {
queryParams.time = moment.utc(params.toTime).format('YYYY-MM-DD');
} else {
// time is an optional param, and sentinelhub will atleast return the latest image if time=none https://docs.sentinel-hub.com/api/latest/api/ogc/wms/
// set time range with fromTime and toTime
if (params.fromTime !== null && params.toTime !== null) {
queryParams.time = `${moment.utc(params.fromTime).format('YYYY-MM-DDTHH:mm:ss') + 'Z'}/${moment
.utc(params.toTime)
.format('YYYY-MM-DDTHH:mm:ss') + 'Z'}`;
}
// only toTime available
if (params.fromTime === null && params.toTime !== null) {
queryParams.time = moment.utc(params.toTime).format('YYYY-MM-DD');
}

if (params.width && params.height) {
queryParams.width = Math.round(params.width);
Expand Down

0 comments on commit df1d47c

Please sign in to comment.