-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from KNMI/liveupdate
Liveupdate layer
- Loading branch information
Showing
14 changed files
with
165 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
adagucserverEC/LayerTypeLiveUpdate/LayerTypeLiveUpdate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "LayerTypeLiveUpdate.h" | ||
|
||
int layerTypeLiveUpdateConfigureDimensionsInDataSource(CDataSource *dataSource) { | ||
// This layer has no dimensions, but we need to add one timestep with data in order to make the next code work. | ||
if (dataSource->requiredDims.size() < 1) { | ||
|
||
COGCDims *requiredDim = new COGCDims(); | ||
requiredDim->isATimeDimension = true; | ||
requiredDim->name = "time"; | ||
requiredDim->netCDFDimName = "time"; | ||
// The following values need to be filled in and are updated during XML GetCapabilities generation | ||
requiredDim->uniqueValues.push_back("2020-01-01T00:00:00Z"); | ||
requiredDim->uniqueValues.push_back("2020-01-02T00:00:00Z"); | ||
requiredDim->value = "2020-01-02T00:00:00Z"; | ||
dataSource->requiredDims.push_back(requiredDim); | ||
} | ||
dataSource->addStep("", NULL); | ||
dataSource->getCDFDims()->addDimension("none", "0", 0); | ||
return 0; | ||
} | ||
|
||
int layerTypeLiveUpdateRenderIntoDrawImage(CDrawImage *image, CServerParams *srvParam) { | ||
image->enableTransparency(true); | ||
image->setTrueColor(true); | ||
image->createImage(srvParam->Geo); | ||
image->create685Palette(); | ||
image->rectangle(0, 0, srvParam->Geo->dWidth, srvParam->Geo->dHeight, CColor(255, 255, 255, 0), CColor(255, 255, 255, 255)); | ||
const char *fontFile = image->getFontLocation(); | ||
CT::string timeValue = "No time dimension specified"; | ||
if (srvParam->requestDims.size() == 1) { | ||
timeValue = srvParam->requestDims[0]->value.c_str(); | ||
} | ||
int stepY = 100; | ||
for (int y = 0; y < image->getHeight(); y = y + stepY) { | ||
for (int x = 0; x < image->getWidth(); x = x + 300) { | ||
image->drawText(x + (((y % (stepY * 2)) / stepY) * 150), y, fontFile, 15, 0.1, timeValue.c_str(), CColor(0, 0, 0, 255)); | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int layerTypeLiveUpdateConfigureWMSLayerForGetCapabilities(WMSLayer *myWMSLayer) { | ||
if (myWMSLayer->dataSource->cfgLayer->Title.size() != 0) { | ||
myWMSLayer->title.copy(myWMSLayer->dataSource->cfgLayer->Title[0]->value.c_str()); | ||
} else { | ||
myWMSLayer->title.copy(myWMSLayer->dataSource->cfgLayer->Name[0]->value.c_str()); | ||
} | ||
CTime timeInstance; | ||
timeInstance.init("seconds since 1970", "standard"); | ||
double epochTime = timeInstance.getEpochTimeFromDateString(CTime::currentDateTime()); | ||
// CTime::Date cdate = timeInstance.getDate(epochTime); | ||
double startTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime - 3600, "PT1S", "low"); | ||
double stopTimeOffset = timeInstance.quantizeTimeToISO8601(epochTime, "PT1S", "low"); | ||
CT::string startTime = timeInstance.dateToISOString(timeInstance.offsetToDate(startTimeOffset)); | ||
CT::string stopTime = timeInstance.dateToISOString(timeInstance.offsetToDate(stopTimeOffset)); | ||
CT::string resTime = "PT1S"; | ||
WMSLayer::Dim *dim = new WMSLayer::Dim(); | ||
myWMSLayer->dimList.push_back(dim); | ||
dim->name.copy("time"); | ||
dim->units.copy("ISO8601"); | ||
dim->values.copy(startTime + "/" + stopTime + "/" + resTime); | ||
dim->defaultValue.copy(stopTime.c_str()); | ||
dim->hasMultipleValues = true; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "CDataSource.h" | ||
#include "CDrawImage.h" | ||
#include "CServerParams.h" | ||
#include "CServerParams.h" | ||
#include "CXMLGen.h" | ||
|
||
#ifndef LAYERTYPELIVEUPDATE_H | ||
|
||
/** | ||
* Configures a datasource with a fake time dimension | ||
*/ | ||
int layerTypeLiveUpdateConfigureDimensionsInDataSource(CDataSource *dataSource); | ||
|
||
/** | ||
* Renders time into an image the based on the time dimension in the GetMap request. | ||
*/ | ||
int layerTypeLiveUpdateRenderIntoDrawImage(CDrawImage *image, CServerParams *srvParam); | ||
|
||
/** | ||
* Configures an actual time range in a WMSLayer object. This is used for generating the Layer element in the WMS GetCapabilities file | ||
*/ | ||
int layerTypeLiveUpdateConfigureWMSLayerForGetCapabilities(WMSLayer *myWMSLayer); | ||
|
||
#endif // !LAYERTYPELIVEUPDATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Configuration> | ||
<!-- | ||
See https://dev.knmi.nl/projects/adagucserver/wiki/Dataset, for details | ||
This file can be included by using the adaguc.dataset.cgi?service=wms&DATASET=testdata& key value pair in the URL | ||
--> | ||
<Layer type="liveupdate"> | ||
<Name>liveupdate</Name> | ||
</Layer> | ||
</Configuration> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters