Skip to content

Commit

Permalink
Merge pull request #417 from KNMI/config_interval_liveupdate
Browse files Browse the repository at this point in the history
Interval can now be used to configure the advertised time resolution for liveupdate
  • Loading branch information
maartenplieger authored Nov 18, 2024
2 parents 943e377 + 58bb74d commit 1f0dd89
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
16 changes: 12 additions & 4 deletions adagucserverEC/LayerTypeLiveUpdate/LayerTypeLiveUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,24 @@ int layerTypeLiveUpdateConfigureWMSLayerForGetCapabilities(MetadataLayer *metada
metadataLayer->layerMetadata.title.copy(metadataLayer->dataSource->cfgLayer->Name[0]->value.c_str());
}
CTime timeInstance;

CT::string timeResolution = "PT10M";

for (auto dim : metadataLayer->layer->Dimension) {
if (dim->value.equals("time") && !dim->attr.interval.empty()) {
timeResolution = dim->attr.interval;
}
}

timeInstance.init("seconds since 1970", "standard");
double epochTime = timeInstance.getEpochTimeFromDateString(CTime::currentDateTime());
// CTime::Date cdate = timeInstance.getDate(epochTime);
double startTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime - 3600 * 24 * 365, "PT10M", "low");
double stopTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime, "PT10M", "low");
double startTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime - 3600 * 24 * 365, timeResolution.c_str(), "low");
double stopTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime, timeResolution.c_str(), "low");
CT::string startTime = timeInstance.dateToISOString(timeInstance.offsetToDate(startTimeOffset));
CT::string stopTime = timeInstance.dateToISOString(timeInstance.offsetToDate(stopTimeOffset));
CT::string resTime = "PT10M";
LayerMetadataDim dim = {
.serviceName = "time", .cdfName = "time", .units = "ISO8601", .values = startTime + "/" + stopTime + "/" + resTime, .defaultValue = stopTime, .hasMultipleValues = true, .hidden = false};
.serviceName = "time", .cdfName = "time", .units = "ISO8601", .values = startTime + "/" + stopTime + "/" + timeResolution, .defaultValue = stopTime, .hasMultipleValues = true, .hidden = false};
metadataLayer->layerMetadata.dimList.push_back(dim);

return 0;
Expand Down
17 changes: 7 additions & 10 deletions adagucserverEC/utils/LayerMetadataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <json_adaguc.h>
#include <CDBFactory.h>
#include "XMLGenUtils.h"
#include <LayerTypeLiveUpdate/LayerTypeLiveUpdate.h>

int getDimensionListAsJson(MetadataLayer *metadataLayer, json &dimListJson) {
try {
Expand Down Expand Up @@ -107,14 +108,6 @@ int storemetadataLayerIntoMetadataDb(MetadataLayer *metadataLayer) {
return 0;
}

int loadmetadataLayerFromMetadataDb(MetadataLayer *metadataLayer) {
loadLayerMetadataStructFromMetadataDb(metadataLayer);
loadLayerDimensionListFromMetadataDb(metadataLayer);
loadLayerProjectionAndExtentListFromMetadataDb(metadataLayer);
loadLayerStyleListFromMetadataDb(metadataLayer);
return 0;
}

CT::string getLayerMetadataFromDb(MetadataLayer *metadataLayer, CT::string metadataKey) {
CT::string layerName = metadataLayer->dataSource->getLayerName();
CT::string datasetName = metadataLayer->dataSource->srvParams->datasetLocation;
Expand Down Expand Up @@ -172,6 +165,10 @@ int storeLayerMetadataStructIntoMetadataDb(MetadataLayer *metadataLayer) {
}

int loadLayerMetadataStructFromMetadataDb(MetadataLayer *metadataLayer) {
if (metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeCascaded || (metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeLiveUpdate)) {
layerTypeLiveUpdateConfigureWMSLayerForGetCapabilities(metadataLayer);
return 0;
}
if (!metadataLayer->readFromDb) {
return 1;
}
Expand Down Expand Up @@ -289,10 +286,10 @@ int storeLayerStyleListIntoMetadataDb(MetadataLayer *metadataLayer) {
}

int loadLayerStyleListFromMetadataDb(MetadataLayer *metadataLayer) {
if (metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeCascaded ||
(metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeLiveUpdate) && metadataLayer->dataSource->cfgLayer->DataPostProc.empty()) {
if (metadataLayer->dataSource->dLayerType == CConfigReaderLayerTypeCascaded) {
return 0;
}

if (!metadataLayer->readFromDb) {
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions data/config/datasets/adaguc.tests.solarterminator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<DataPostProc algorithm="solarterminator"/>
<Variable>solarterminator</Variable>
<Styles>soltstyle</Styles>
<Dimension interval="PT10M">time</Dimension>
</Layer>


Expand Down
1 change: 1 addition & 0 deletions doc/configuration/Dimension.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ This will convert the following inputs to internal dates:
- 2015-01-21T15:18:36Z --> 2015-01-21T15:20:00Z
- 2015-01-21T15:21:01Z --> 2015-01-21T15:20:00Z


4 changes: 4 additions & 0 deletions doc/configuration/Layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ This layer type displays a GetMap image with the current time per second for the
-->
<Layer type="liveupdate">
<Name>liveupdate</Name>
<Dimension interval="PT1S">time</Dimension>
</Layer>
</Configuration>
```

Note, default interval is PT10M for the liveupdate, you can overide this with the interval attribute in the dimension.

<img src='2024-02-14-liveupdate-layer.png' />

If you configure the ```solarterminator``` data postprocessor, the liveupdate layer will display a GetMap image showing the areas where it is day, night, and different twilight levels (values from 0 to 4). The solar terminator algorithm is based on the calculations presented in the book *Astronomical Algorithms* (1991) by Jean Meeus.
Expand Down Expand Up @@ -102,6 +105,7 @@ More information on how to configure this type of layer can be found [here](../t
<DataPostProc algorithm="solarterminator"/>
<Variable>solarterminator</Variable>
<Styles>soltstyle</Styles>
<Dimension interval="PT10M">time</Dimension>
</Layer>
</Configuration>
```
Expand Down
1 change: 1 addition & 0 deletions doc/tutorials/Configure_solar_terminator.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Create the following file at the filepath `$ADAGUC_DATASET_DIR/solt.xml`
<DataPostProc algorithm="solarterminator"/>
<Variable>solarterminator</Variable>
<Styles>soltstyle</Styles>
<Dimension interval="PT10M">time</Dimension>
</Layer>


Expand Down

0 comments on commit 1f0dd89

Please sign in to comment.