mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[Bugfix][Server] QGIS Server removes empty string in style parameter even if it describes default style
In OGC WMS standard, the empty string represents the default style. QGIS Server when it parses the parameters, QGIS Server when it parses parameters it removes empty parts. When all requested styles are default ones it's equal to an empty parameter STYLE, as defined in the standard. When only one layer is requested, there is no issue with custom or default style. When multiple layers are requested and some with custom styles, because QGIS Server does not retain empty strings, it loses the layer / style match. To fix it, keeps empty parts for not empty styles parameters.
This commit is contained in:
parent
870337871a
commit
98235eb46b
@ -49,11 +49,12 @@ Converts the parameter into a string. If ``defaultValue`` is true
|
||||
and current value is empty, then the default value is returned.
|
||||
%End
|
||||
|
||||
QStringList toStringList( char delimiter = ',' ) const;
|
||||
QStringList toStringList( char delimiter = ',', bool skipEmptyParts = true ) const;
|
||||
%Docstring
|
||||
Converts the parameter into a list of strings.
|
||||
Converts the parameter into a list of strings
|
||||
|
||||
:param delimiter: The character used for delimiting
|
||||
:param skipEmptyParts: To use QString.SkipEmptyParts for splitting
|
||||
|
||||
:return: A list of strings
|
||||
%End
|
||||
|
@ -72,9 +72,21 @@ QString QgsServerParameterDefinition::toString( const bool defaultValue ) const
|
||||
return value;
|
||||
}
|
||||
|
||||
QStringList QgsServerParameterDefinition::toStringList( const char delimiter ) const
|
||||
QStringList QgsServerParameterDefinition::toStringList( const char delimiter, const bool skipEmptyParts ) const
|
||||
{
|
||||
return toString().split( delimiter, QString::SkipEmptyParts );
|
||||
if ( skipEmptyParts )
|
||||
{
|
||||
return toString().split( delimiter, QString::SkipEmptyParts );
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList list;
|
||||
if ( !toString().isEmpty() )
|
||||
{
|
||||
list = toString().split( delimiter, QString::KeepEmptyParts );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QgsGeometry> QgsServerParameterDefinition::toGeomList( bool &ok, const char delimiter ) const
|
||||
|
@ -65,11 +65,12 @@ class SERVER_EXPORT QgsServerParameterDefinition
|
||||
QString toString( bool defaultValue = false ) const;
|
||||
|
||||
/**
|
||||
* Converts the parameter into a list of strings.
|
||||
* Converts the parameter into a list of strings
|
||||
* \param delimiter The character used for delimiting
|
||||
* \param skipEmptyParts To use QString::SkipEmptyParts for splitting
|
||||
* \returns A list of strings
|
||||
*/
|
||||
QStringList toStringList( char delimiter = ',' ) const;
|
||||
QStringList toStringList( char delimiter = ',', bool skipEmptyParts = true ) const;
|
||||
|
||||
/**
|
||||
* Converts the parameter into a list of integers.
|
||||
|
@ -46,6 +46,11 @@ namespace QgsWms
|
||||
QgsServerParameterDefinition::raiseError( msg );
|
||||
}
|
||||
|
||||
QStringList QgsWmsParameter::toStyleList( const char delimiter ) const
|
||||
{
|
||||
return QgsServerParameterDefinition::toStringList( delimiter, false );
|
||||
}
|
||||
|
||||
QList<QgsGeometry> QgsWmsParameter::toGeomList( const char delimiter ) const
|
||||
{
|
||||
bool ok = true;
|
||||
@ -1368,8 +1373,8 @@ namespace QgsWms
|
||||
|
||||
QStringList QgsWmsParameters::allStyles() const
|
||||
{
|
||||
QStringList style = mWmsParameters[ QgsWmsParameter::STYLE ].toStringList();
|
||||
const QStringList styles = mWmsParameters[ QgsWmsParameter::STYLES ].toStringList();
|
||||
QStringList style = mWmsParameters[ QgsWmsParameter::STYLE ].toStyleList();
|
||||
const QStringList styles = mWmsParameters[ QgsWmsParameter::STYLES ].toStyleList();
|
||||
return style << styles;
|
||||
}
|
||||
|
||||
@ -1673,7 +1678,7 @@ namespace QgsWms
|
||||
wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
|
||||
if ( wmsParam.isValid() )
|
||||
{
|
||||
styles = wmsParam.toStringList();
|
||||
styles = wmsParam.toStyleList();
|
||||
}
|
||||
|
||||
QList<QgsWmsParametersLayer> lParams;
|
||||
|
@ -201,6 +201,15 @@ namespace QgsWms
|
||||
*/
|
||||
bool isValid() const override;
|
||||
|
||||
/**
|
||||
* Converts the parameter into a list of strings and keeps empty parts
|
||||
* Default style value is an empty string
|
||||
* \param delimiter The character used for delimiting
|
||||
* \returns A list of strings
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
QStringList toStyleList( const char delimiter = ',' ) const;
|
||||
|
||||
/**
|
||||
* Converts the parameter into a list of geometries.
|
||||
* \param delimiter The character delimiting string geometries
|
||||
|
@ -742,6 +742,58 @@ class TestQgsServerWMSGetMap(QgsServerTestBase):
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_StyleCustom")
|
||||
|
||||
# mixed custom and default style with STYLES parameter
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
"MAP": urllib.parse.quote(self.projectPath),
|
||||
"SERVICE": "WMS",
|
||||
"VERSION": "1.1.1",
|
||||
"REQUEST": "GetMap",
|
||||
"LAYERS": "Country_Labels,Hello",
|
||||
"STYLES": "custom,",
|
||||
"FORMAT": "image/png",
|
||||
"BBOX": "-16817707,-4710778,5696513,14587125",
|
||||
"HEIGHT": "500",
|
||||
"WIDTH": "500",
|
||||
"CRS": "EPSG:3857"
|
||||
}.items())])
|
||||
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_StyleMixed")
|
||||
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
"MAP": urllib.parse.quote(self.projectPath),
|
||||
"SERVICE": "WMS",
|
||||
"VERSION": "1.1.1",
|
||||
"REQUEST": "GetMap",
|
||||
"LAYERS": "Hello,Country_Labels",
|
||||
"STYLES": "default,custom",
|
||||
"FORMAT": "image/png",
|
||||
"BBOX": "-16817707,-4710778,5696513,14587125",
|
||||
"HEIGHT": "500",
|
||||
"WIDTH": "500",
|
||||
"CRS": "EPSG:3857"
|
||||
}.items())])
|
||||
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_StyleMixed_LayerOrder")
|
||||
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
"MAP": urllib.parse.quote(self.projectPath),
|
||||
"SERVICE": "WMS",
|
||||
"VERSION": "1.1.1",
|
||||
"REQUEST": "GetMap",
|
||||
"LAYERS": "Hello,Country_Labels",
|
||||
"STYLES": ",custom",
|
||||
"FORMAT": "image/png",
|
||||
"BBOX": "-16817707,-4710778,5696513,14587125",
|
||||
"HEIGHT": "500",
|
||||
"WIDTH": "500",
|
||||
"CRS": "EPSG:3857"
|
||||
}.items())])
|
||||
|
||||
r, h = self._result(self._execute_request(qs))
|
||||
self._img_diff_error(r, h, "WMS_GetMap_StyleMixed_LayerOrder")
|
||||
|
||||
def test_wms_getmap_filter(self):
|
||||
qs = "?" + "&".join(["%s=%s" % i for i in list({
|
||||
"MAP": urllib.parse.quote(self.projectPath),
|
||||
|
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_StyleMixed/WMS_GetMap_StyleMixed.png
vendored
Normal file
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_StyleMixed/WMS_GetMap_StyleMixed.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_StyleMixed/WMS_GetMap_StyleMixed_mask.png
vendored
Normal file
BIN
tests/testdata/control_images/qgis_server/WMS_GetMap_StyleMixed/WMS_GetMap_StyleMixed_mask.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Loading…
x
Reference in New Issue
Block a user