Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information
nyalldawson committed Sep 6, 2020
1 parent 53c72bc commit 52c0a18fb597c806ee99455511351212b3a8b959
@@ -9,14 +9,48 @@



class QgsMapBoxGlStyleConversionContext
{
%Docstring
Context for a MapBox GL style conversion operation.

.. warning::

This is private API only, and may change in future QGIS versions

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsmapboxglstyleconverter.h"
%End
public:

void pushWarning( const QString &warning );
%Docstring
Pushes a ``warning`` message generated during the conversion.
%End

QStringList warnings() const;
%Docstring
Returns a list of warning messages generated during the conversion.
%End

void clearWarnings();
%Docstring
Clears the list of warning messages.
%End

};

class QgsMapBoxGlStyleConverter
{
%Docstring
Handles conversion of MapBox GL styles to QGIS vector tile renderers and labeling
settings.

Conversions are performed by calling :py:func:`~convert` with either a JSON map or JSON
string value, and then retrieving the results by calling :py:func:`~renderer` or :py:func:`~labeling`
Conversions are performed by calling :py:func:`~QgsMapBoxGlStyleConversionContext.convert` with either a JSON map or JSON
string value, and then retrieving the results by calling :py:func:`~QgsMapBoxGlStyleConversionContext.renderer` or :py:func:`~QgsMapBoxGlStyleConversionContext.labeling`
respectively.

.. versionadded:: 3.16
@@ -100,40 +134,6 @@ or ``None`` if the style could not be converted successfully.
Opacity,
};

class ConversionContext
{
%Docstring
Context for a MapBox GL style conversion operation.

.. warning::

This is private API only, and may change in future QGIS versions

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgsmapboxglstyleconverter.h"
%End
public:

void pushWarning( const QString &warning );
%Docstring
Pushes a ``warning`` message generated during the conversion.
%End

QStringList warnings() const;
%Docstring
Returns a list of warning messages generated during the conversion.
%End

void clearWarnings();
%Docstring
Clears the list of warning messages.
%End

};

void parseLayers( const QVariantList &layers );
%Docstring
Parse list of ``layers`` from JSON.
@@ -143,7 +143,7 @@ Parse list of ``layers`` from JSON.
This is private API only, and may change in future QGIS versions
%End

static bool parseFillLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style /Out/, ConversionContext &context );
static bool parseFillLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style /Out/, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Parses a fill layer.

@@ -158,7 +158,7 @@ Parses a fill layer.
- style: generated QGIS vector tile style
%End

static bool parseLineLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style /Out/, ConversionContext &context );
static bool parseLineLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style /Out/, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Parses a line layer.

@@ -177,7 +177,7 @@ Parses a line layer.
QgsVectorTileBasicRendererStyle &rendererStyle /Out/,
bool &hasRenderer /Out/,
QgsVectorTileBasicLabelingStyle &labelingStyle /Out/,
bool &hasLabeling /Out/, ConversionContext &context );
bool &hasLabeling /Out/, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Parses a symbol layer.

@@ -193,7 +193,7 @@ Parses a symbol layer.
%End


static QgsProperty parseInterpolateColorByZoom( const QVariantMap &json, ConversionContext &context, QColor *defaultColor = 0 );
static QgsProperty parseInterpolateColorByZoom( const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, QColor *defaultColor = 0 );
%Docstring
Parses a color value which is interpolated by zoom range.

@@ -202,7 +202,7 @@ Parses a color value which is interpolated by zoom range.
:param defaultColor: optional storage for a reasonable "default" color representing the overall property.
%End

static QgsProperty parseInterpolateByZoom( const QVariantMap &json, ConversionContext &context, double multiplier = 1 );
static QgsProperty parseInterpolateByZoom( const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, double multiplier = 1 );
%Docstring
Parses a numeric value which is interpolated by zoom range.

@@ -232,7 +232,7 @@ to interpolate alpha component of color.
This is private API only, and may change in future QGIS versions
%End

static QString parseStops( double base, const QVariantList &stops, double multiplier, ConversionContext &context );
static QString parseStops( double base, const QVariantList &stops, double multiplier, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Parses a list of interpolation stops

@@ -242,7 +242,7 @@ Parses a list of interpolation stops
:param context: conversion context
%End

static QgsProperty parseInterpolateListByZoom( const QVariantList &json, PropertyType type, ConversionContext &context, double multiplier = 1, QColor *defaultColor = 0 );
static QgsProperty parseInterpolateListByZoom( const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier = 1, QColor *defaultColor = 0 );
%Docstring
Interpolates a list which starts with the interpolate function.

@@ -251,7 +251,7 @@ Interpolates a list which starts with the interpolate function.
This is private API only, and may change in future QGIS versions
%End

static QColor parseColor( const QVariant &color, ConversionContext &context );
static QColor parseColor( const QVariant &color, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Parses a ``color`` in one of these supported formats:

@@ -309,7 +309,7 @@ Converts a value to Qt.PenJoinStyle enum from JSON value.
This is private API only, and may change in future QGIS versions
%End

static QString parseExpression( const QVariantList &expression, ConversionContext &context );
static QString parseExpression( const QVariantList &expression, QgsMapBoxGlStyleConversionContext &context );
%Docstring
Converts a MapBox GL expression to a QGIS expression.

@@ -62,7 +62,7 @@ QgsMapBoxGlStyleConverter::~QgsMapBoxGlStyleConverter() = default;

void QgsMapBoxGlStyleConverter::parseLayers( const QVariantList &layers )
{
ConversionContext context;
QgsMapBoxGlStyleConversionContext context;

QList<QgsVectorTileBasicRendererStyle> rendererStyles;
QList<QgsVectorTileBasicLabelingStyle> labelingStyles;
@@ -148,7 +148,7 @@ void QgsMapBoxGlStyleConverter::parseLayers( const QVariantList &layers )
labeling->setStyles( labelingStyles );
}

bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, ConversionContext &context )
bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context )
{
if ( !jsonLayer.contains( QStringLiteral( "paint" ) ) )
{
@@ -332,7 +332,7 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
return true;
}

bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, ConversionContext &context )
bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context )
{
if ( !jsonLayer.contains( QStringLiteral( "paint" ) ) )
{
@@ -524,7 +524,7 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg
return true;
}

void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &, bool &hasRenderer, QgsVectorTileBasicLabelingStyle &labelingStyle, bool &hasLabeling, ConversionContext &context )
void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &, bool &hasRenderer, QgsVectorTileBasicLabelingStyle &labelingStyle, bool &hasLabeling, QgsMapBoxGlStyleConversionContext &context )
{
hasLabeling = false;
hasRenderer = false;
@@ -809,7 +809,7 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
hasLabeling = true;
}

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateColorByZoom( const QVariantMap &json, ConversionContext &context, QColor *defaultColor )
QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateColorByZoom( const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, QColor *defaultColor )
{
const double base = json.value( QStringLiteral( "base" ), QStringLiteral( "1" ) ).toDouble();
const QVariantList stops = json.value( QStringLiteral( "stops" ) ).toList();
@@ -911,7 +911,7 @@ QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateColorByZoom( const QVaria
return QgsProperty::fromExpression( caseString );
}

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateByZoom( const QVariantMap &json, ConversionContext &context, double multiplier )
QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateByZoom( const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, double multiplier )
{
const double base = json.value( QStringLiteral( "base" ), QStringLiteral( "1" ) ).toDouble();
const QVariantList stops = json.value( QStringLiteral( "stops" ) ).toList();
@@ -1021,7 +1021,7 @@ QString QgsMapBoxGlStyleConverter::parseOpacityStops( double base, const QVarian
return caseString;
}

QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList &stops, double multiplier, ConversionContext &context )
QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList &stops, double multiplier, QgsMapBoxGlStyleConversionContext &context )
{
QString caseString = QStringLiteral( "CASE " );

@@ -1068,7 +1068,7 @@ QString QgsMapBoxGlStyleConverter::parseStops( double base, const QVariantList &
return caseString;
}

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateListByZoom( const QVariantList &json, PropertyType type, ConversionContext &context, double multiplier, QColor *defaultColor )
QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateListByZoom( const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier, QColor *defaultColor )
{
if ( json.value( 0 ).toString() != QLatin1String( "interpolate" ) )
{
@@ -1123,7 +1123,7 @@ QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateListByZoom( const QVarian
return QgsProperty();
}

QColor QgsMapBoxGlStyleConverter::parseColor( const QVariant &color, ConversionContext &context )
QColor QgsMapBoxGlStyleConverter::parseColor( const QVariant &color, QgsMapBoxGlStyleConversionContext &context )
{
if ( color.type() != QVariant::String )
{
@@ -1171,7 +1171,7 @@ Qt::PenJoinStyle QgsMapBoxGlStyleConverter::parseJoinStyle( const QString &style
return Qt::MiterJoin; // "miter" is default
}

QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expression, ConversionContext &context )
QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expression, QgsMapBoxGlStyleConversionContext &context )
{
QString op = expression.value( 0 ).toString();
if ( op == QLatin1String( "all" ) )
@@ -1307,7 +1307,7 @@ QString QgsMapBoxGlStyleConverter::parseExpression( const QVariantList &expressi
}
}

QString QgsMapBoxGlStyleConverter::parseValue( const QVariant &value, ConversionContext &context )
QString QgsMapBoxGlStyleConverter::parseValue( const QVariant &value, QgsMapBoxGlStyleConversionContext &context )
{
switch ( value.type() )
{
@@ -1354,9 +1354,9 @@ QgsVectorTileLabeling *QgsMapBoxGlStyleConverter::labeling() const
}

//
// ConversionContext
// QgsMapBoxGlStyleConversionContext
//
void QgsMapBoxGlStyleConverter::ConversionContext::pushWarning( const QString &warning )
void QgsMapBoxGlStyleConversionContext::pushWarning( const QString &warning )
{
QgsDebugMsg( warning );
mWarnings << warning;

0 comments on commit 52c0a18

Please sign in to comment.
You can’t perform that action at this time.