Skip to content

Commit

Permalink
rendertextforvectors can now be used to enable / disable text in vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenplieger committed Oct 11, 2024
1 parent bc5b529 commit bea2089
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**Version 2.28.1 2024-10-11**
- Windbarbs on modelfields now display the windspeed in kts as text.
- Windbarbs on modelfields can now display the windspeed in kts as text when rendertextforvectors in RenderSettings is set to true.

**Version 2.28.0 2024-09-11**
- Metadata for layer items like variables, projections, dimensions and styles are now stored in a database table called `layermetadata`. This can be disabled via the `enablemetadatacache` property in [Settings](doc/configuration/Settings.md).
Expand Down
9 changes: 6 additions & 3 deletions adagucserverEC/CImgWarpBilinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

const char *CImgWarpBilinear::className = "CImgWarpBilinear";
void CImgWarpBilinear::render(CImageWarper *warper, CDataSource *sourceImage, CDrawImage *drawImage) {
CStyleConfiguration *styleConfiguration = sourceImage->getStyle();
#ifdef CImgWarpBilinear_DEBUG
CDBDebug("Render");
#endif
Expand Down Expand Up @@ -409,11 +410,13 @@ void CImgWarpBilinear::render(CImageWarper *warper, CDataSource *sourceImage, CD
}
}
if (enableBarb) {
CalculatedWindVector wv;

bool rendertextforvectors = styleConfiguration != nullptr && styleConfiguration->styleConfig != nullptr && styleConfiguration->styleConfig->RenderSettings.size() > 0 &&
styleConfiguration->styleConfig->RenderSettings[0]->attr.rendertextforvectors.equals("true");
for (size_t sz = 0; sz < windVectors.size(); sz++) {
wv = windVectors[sz];
CalculatedWindVector wv = windVectors[sz];
float outlineWidth = 0;
drawImage->drawBarb(wv.x, wv.y, wv.dir, wv.strength, CColor(0, 0, 255, 255), outlineWidth, wv.convertToKnots, wv.flip, true);
drawImage->drawBarb(wv.x, wv.y, wv.dir, wv.strength, CColor(0, 0, 255, 255), outlineWidth, wv.convertToKnots, wv.flip, rendertextforvectors);
}
}

Expand Down
5 changes: 4 additions & 1 deletion adagucserverEC/CServerConfig_CPPXSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ class CServerConfig : public CXMLSerializerInterface {
public:
class Cattr {
public:
CT::string settings, striding, renderer, scalewidth, scalecontours, renderhint, randomizefeatures, featuresoverlap;
CT::string settings, striding, renderer, scalewidth, scalecontours, renderhint, randomizefeatures, featuresoverlap, rendertextforvectors;
} attr;
void addAttribute(const char *name, const char *value) {
if (equals("settings", name)) {
Expand All @@ -833,6 +833,9 @@ class CServerConfig : public CXMLSerializerInterface {
} else if (equals("featuresoverlap", name)) {
attr.featuresoverlap.copy(value);
return;
} else if (equals("rendertextforvectors", name)) {
attr.rendertextforvectors.copy(value);
return;
}
}
};
Expand Down
11 changes: 10 additions & 1 deletion data/config/datasets/adaguc.tests.harm_windbarbs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<NameMapping name="thinbarb" title="Wind barbs (thinned)" abstract="Rendered with thinned barbs"/>
</Style>

<Style name="Windbarbwithnumbers">
<Scale>1</Scale>
<Offset>0</Offset>
<RenderMethod>barb</RenderMethod>
<RenderSettings rendertextforvectors="true" />
<NameMapping name="barb" title="Wind barbs" abstract="Rendered with barbs and text"/>
<NameMapping name="thinbarb" title="Wind barbs (thinned)" abstract="Rendered with thinned barbs and text"/>
</Style>

<Layer type="database">
<Name>wind__at_10m</Name>
<Title>Wind 10m flags</Title>
Expand All @@ -18,7 +27,7 @@
<DataPostProc algorithm="ax+b" a="1" b="0" units="m/s"/>
<Dimension name="time" units="ISO8601" default="min">time</Dimension>
<Dimension name="forecast_reference_time" units="ISO8601">reference_time</Dimension>
<Styles>Windbarbs</Styles>
<Styles>Windbarbs,Windbarbwithnumbers</Styles>
</Layer>

<!-- End of configuration /-->
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Configuration
with custom image
- [Stippling](Stippling.md) (distancex, distancey, discradius)
Configuration of stippling renderer.
- [RenderSettings](RenderSettings.md) (settings, striding, renderer, scalewidth, scalecontours, renderhint) Configuration of
- [RenderSettings](RenderSettings.md) (settings, striding, renderer, scalewidth, scalecontours, renderhint, rendertextforvectors) Configuration of
renderers

<!-- -->
Expand Down
10 changes: 9 additions & 1 deletion doc/configuration/RenderSettings.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RenderSettings (settings, striding, renderer, scalewidth, scalecontours, renderhint)
RenderSettings (settings, striding, renderer, scalewidth, scalecontours, renderhint, rendertextforvectors)
=============================================

Back to [Configuration](./Configuration.md)
Expand All @@ -19,6 +19,14 @@ Controls behaviour of nearestneighbour rendering
<RenderSettings settings="precise"/>
```

# rendertextforvectors

```xml
<RenderSettings rendertextforvectors="true" />
```

When set to true, it will render text with windbarbs.

# striding

Controls how many grid cells are skipped. E.g. if set to 2, every other
Expand Down
31 changes: 31 additions & 0 deletions tests/AdagucTests/TestWMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,37 @@ def test_WMSGetMapWithHarmWindBarbs(self):
0.1,
)
)

def test_WMSGetMapWithHarmWindBarbsWithText(self):
AdagucTestTools().cleanTempDir()
filename = "test_WMSGetMapWithHarmWindBarbs_without_outline_with_text.png"
config = ADAGUC_PATH + "data/config/adaguc.tests.dataset.xml"
# pylint: disable=unused-variable
status, data, headers = AdagucTestTools().runADAGUCServer(
args=[
"--updatedb",
"--config",
config + ",adaguc.tests.harm_windbarbs.xml",
],
env=self.env,
isCGI=False,
)
self.assertEqual(status, 0)

status, data, headers = AdagucTestTools().runADAGUCServer(
"DATASET=adaguc.tests.harm_windbarbs&SERVICE=WMS&SERVICE=WMS&=&=&VERSION=1.3.0&REQUEST=GetMap&LAYERS=wind__at_10m&WIDTH=914&HEIGHT=966&CRS=EPSG:3857&BBOX=10144.960912989336,6256275.017522922,1229386.3384520854,7544882.425294002&STYLES=Windbarbwithnumbers/barb&FORMAT=image/png&TRANSPARENT=FALSE&time=2023-09-30T06:00:00Z&DIM_reference_time=2023-09-28T06:00:00Z&BGCOLOR=0x000000&",
{"ADAGUC_CONFIG": ADAGUC_PATH + "data/config/adaguc.tests.dataset.xml"},
)
AdagucTestTools().writetofile(self.testresultspath + filename, data.getvalue())
self.assertEqual(status, 0)
self.assertTrue(
AdagucTestTools().compareImage(
self.expectedoutputsspath + filename,
self.testresultspath + filename,
3,
0.1,
)
)

def test_WMSGetMap_EPSG3067(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.
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 bea2089

Please sign in to comment.