Skip to content

Commit

Permalink
Merge pull request #221 from KNMI/fix-log-legend
Browse files Browse the repository at this point in the history
2.7.6 Fix: Legend with a logaritmic scale do work again.
  • Loading branch information
ernstdevreede authored Jul 12, 2022
2 parents 0cf3ee9 + 7de2ac0 commit 95e7d11
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USER root
LABEL maintainer="[email protected]"

# Version should be same as in Definitions.h
LABEL version="2.7.5"
LABEL version="2.7.6"

######### First stage (build) ############

Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**Version 2.7.6 2022-07-12**

- Fix: Legend with a logaritmic scale do work again.

**Version 2.7.5 2022-07-11**

- Implemented quantize for time on ingest too (for rounding product times up/down to values spaced with fixed intervals)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "CDataReader.h"
#include "CImageDataWriter.h"
#include <algorithm>
int CCreateLegend::renderContinuousLegend(CDataSource *dataSource, CDrawImage *legendImage, CStyleConfiguration *styleConfiguration, bool, bool estimateMinMax) {
int CCreateLegend::renderContinuousLegend(CDataSource *dataSource, CDrawImage *legendImage, CStyleConfiguration *styleConfiguration, bool, bool ) {
#ifdef CIMAGEDATAWRITER_DEBUG
CDBDebug("legendtype continous");
#endif
Expand Down Expand Up @@ -146,7 +146,8 @@ int CCreateLegend::renderContinuousLegend(CDataSource *dataSource, CDrawImage *l
v = pow(styleConfiguration->legendLog, v);
}
{
legendImage->line(((int)cbW - 1) * scaling + pLeft, (int)c + 6 + dH + pTop, ((int)cbW + 6) * scaling + pLeft, (int)c + 6 + dH + pTop, lineWidth, 248);
int labelY = (int)c + 6 + dH + pTop;
legendImage->line(((int)cbW - 1) * scaling + pLeft, labelY, ((int)cbW + 6) * scaling + pLeft, (int)c + 6 + dH + pTop, lineWidth, 248);
if (textformatting.empty() == false) {
CT::string textFormat;
textFormat.print("%s", textformatting.c_str());
Expand All @@ -158,8 +159,11 @@ int CCreateLegend::renderContinuousLegend(CDataSource *dataSource, CDrawImage *l
floatToString(szTemp, 255, tickRound, v);
}
}

if (!fontLocation.empty()) {
legendImage->drawText(((int)cbW + 12 + pLeft) * scaling, (pTop) - ((fontSize * scaling) / 4) + 3, fontLocation.c_str(), fontSize * scaling, 0, szTemp, 248);
int textX = ((int)cbW + 12 + pLeft) * scaling;
int textY = labelY + 4;
legendImage->drawText(textX, textY, fontLocation.c_str(), fontSize * scaling, 0, szTemp, 248);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion adagucserverEC/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef Definitions_H
#define Definitions_H

#define ADAGUCSERVER_VERSION "2.7.5" // Please also update in the Dockerfile to the same version
#define ADAGUCSERVER_VERSION "2.7.6" // Please also update in the Dockerfile to the same version

// CConfigReaderLayerType
#define CConfigReaderLayerTypeUnknown 0
Expand Down
10 changes: 9 additions & 1 deletion data/config/datasets/adaguc.tests.invertedlegend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@
<RenderMethod>nearest</RenderMethod>
</Style>

<Style name="testdatalog10">
<Legend fixedclasses="true" tickinterval="5" tickround=".01">no2</Legend>
<Min>0.1</Min>
<Max>30.0</Max>
<Log>10</Log>
<RenderMethod>nearest</RenderMethod>
</Style>


<!-- Layers -->
<Layer type="database">

<FilePath filter="">{ADAGUC_PATH}data/datasets/testdata.nc</FilePath>
<Variable>testdata</Variable>
<Styles>testdatainverted</Styles>
<Styles>testdatainverted,testdatalog10</Styles>
</Layer>

</Configuration>
Expand Down
19 changes: 19 additions & 0 deletions tests/AdagucTests/TestWMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,25 @@ def test_WMSGetLegendGraphic_inverted_min_max(self):
self.assertEqual(status, 0)
self.assertEqual(data.getvalue(), AdagucTestTools(
).readfromfile(self.expectedoutputsspath + filename))

def test_WMSGetLegendGraphic_log10(self):
AdagucTestTools().cleanTempDir()
ADAGUC_PATH = os.environ['ADAGUC_PATH']
config = ADAGUC_PATH + '/data/config/adaguc.tests.dataset.xml,' + \
ADAGUC_PATH + '/data/config/datasets/adaguc.tests.invertedlegend.xml'
env = {'ADAGUC_CONFIG': config}

status, data, headers = AdagucTestTools().runADAGUCServer(
args=['--updatedb', '--config', config], env=self.env, isCGI=False)
self.assertEqual(status, 0)

filename = "test_WMSGetLegendGraphic_log10.png"
status, data, headers = AdagucTestTools().runADAGUCServer(
"DATASET=adaguc.tests.invertedlegend&SERVICE=WMS&&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=testdata&format=image/png&STYLE=testdatalog10/nearest&layers=testdata&&&transparent=false", env=env)
AdagucTestTools().writetofile(self.testresultspath + filename, data.getvalue())
self.assertEqual(status, 0)
self.assertEqual(data.getvalue(), AdagucTestTools(
).readfromfile(self.expectedoutputsspath + filename))

def test_WMSGetMapQuantizeLow(self):
AdagucTestTools().cleanTempDir()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 95e7d11

Please sign in to comment.