26QString QgsWriteVectorTilesBaseAlgorithm::group()
const
28 return QObject::tr(
"Vector tiles" );
31QString QgsWriteVectorTilesBaseAlgorithm::groupId()
const
33 return QStringLiteral(
"vectortiles" );
36QString QgsWriteVectorTilesBaseAlgorithm::shortHelpString()
const
38 return QObject::tr(
"This algorithm exports one or more vector layers to vector tiles - a data format optimized for fast map rendering and small data size." );
41void QgsWriteVectorTilesBaseAlgorithm::addBaseParameters()
54 const int minZoom = parameterAsInt( parameters, QStringLiteral(
"MIN_ZOOM" ), context );
55 const int maxZoom = parameterAsInt( parameters, QStringLiteral(
"MAX_ZOOM" ), context );
57 const QVariant layersVariant = parameters.value( parameterDefinition( QStringLiteral(
"LAYERS" ) )->name() );
68 prepareWriter( writer, parameters, context, outputs );
75 if ( parameters.contains( QStringLiteral(
"EXTENT" ) ) )
81 const bool res = writer.
writeTiles( feedback );
93QString QgsWriteVectorTilesXyzAlgorithm::name()
const
95 return QStringLiteral(
"writevectortiles_xyz" );
98QString QgsWriteVectorTilesXyzAlgorithm::displayName()
const
100 return QObject::tr(
"Write Vector Tiles (XYZ)" );
105 return new QgsWriteVectorTilesXyzAlgorithm();
108void QgsWriteVectorTilesXyzAlgorithm::initAlgorithm(
const QVariantMap & )
111 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"XYZ_TEMPLATE" ), QObject::tr(
"File template" ), QStringLiteral(
"{z}/{x}/{y}.pbf" ) ) );
118 const QString outputDir = parameterAsString( parameters, QStringLiteral(
"OUTPUT_DIRECTORY" ), context );
119 const QString xyzTemplate = parameterAsString( parameters, QStringLiteral(
"XYZ_TEMPLATE" ), context );
121 dsUri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"xyz" ) );
122 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( outputDir +
"/" + xyzTemplate ).toString() );
127 outputs.insert( QStringLiteral(
"OUTPUT_DIRECTORY" ), outputDir );
134QString QgsWriteVectorTilesMbtilesAlgorithm::name()
const
136 return QStringLiteral(
"writevectortiles_mbtiles" );
139QString QgsWriteVectorTilesMbtilesAlgorithm::displayName()
const
141 return QObject::tr(
"Write Vector Tiles (MBTiles)" );
146 return new QgsWriteVectorTilesMbtilesAlgorithm();
149void QgsWriteVectorTilesMbtilesAlgorithm::initAlgorithm(
const QVariantMap & )
156 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_NAME" ), QObject::tr(
"Metadata: Name" ), QVariant(),
false,
true ) );
157 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_DESCRIPTION" ), QObject::tr(
"Metadata: Description" ), QVariant(),
false,
true ) );
158 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_ATTRIBUTION" ), QObject::tr(
"Metadata: Attribution" ), QVariant(),
false,
true ) );
159 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_VERSION" ), QObject::tr(
"Metadata: Version" ), QVariant(),
false,
true ) );
160 std::unique_ptr<QgsProcessingParameterString> metaTypeParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral(
"META_TYPE" ), QObject::tr(
"Metadata: Type" ), QVariant(),
false,
true );
161 metaTypeParam->setMetadata( { { QStringLiteral(
"widget_wrapper" ), QVariantMap( { { QStringLiteral(
"value_hints" ), QStringList() << QStringLiteral(
"overlay" ) << QStringLiteral(
"baselayer" ) } } ) }
163 addParameter( metaTypeParam.release() );
164 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_CENTER" ), QObject::tr(
"Metadata: Center" ), QVariant(),
false,
true ) );
169 const QString outputFile = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
171 dsUri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"mbtiles" ) );
172 dsUri.
setParam( QStringLiteral(
"url" ), outputFile );
177 const QString metaName = parameterAsString( parameters, QStringLiteral(
"META_NAME" ), context );
178 const QString metaDescription = parameterAsString( parameters, QStringLiteral(
"META_DESCRIPTION" ), context );
179 const QString metaAttribution = parameterAsString( parameters, QStringLiteral(
"META_ATTRIBUTION" ), context );
180 const QString metaVersion = parameterAsString( parameters, QStringLiteral(
"META_VERSION" ), context );
181 const QString metaType = parameterAsString( parameters, QStringLiteral(
"META_TYPE" ), context );
182 const QString metaCenter = parameterAsString( parameters, QStringLiteral(
"META_CENTER" ), context );
185 if ( !metaName.isEmpty() )
186 meta[
"name"] = metaName;
187 if ( !metaDescription.isEmpty() )
188 meta[
"description"] = metaDescription;
189 if ( !metaAttribution.isEmpty() )
190 meta[
"attribution"] = metaAttribution;
191 if ( !metaVersion.isEmpty() )
192 meta[
"version"] = metaVersion;
193 if ( !metaType.isEmpty() )
194 meta[
"type"] = metaType;
195 if ( !metaCenter.isEmpty() )
196 meta[
"center"] = metaCenter;
200 outputs.insert( QStringLiteral(
"OUTPUT" ), outputFile );
This class represents a coordinate reference system (CRS).
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
A rectangular map extent parameter for processing algorithms.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
A numeric parameter for processing algorithms.
A string parameter for processing algorithms.
A vector tile layer destination parameter, for specifying the destination path for a vector tile laye...
A parameter for processing algorithms that need a list of input vector layers for writing of vector t...
static QList< QgsVectorTileWriter::Layer > parameterAsLayers(const QVariant &layersVariant, QgsProcessingContext &context)
Converts a QVariant value (a QVariantList) to a list of input layers.
A rectangle specified with double values.
Configuration of a single input vector layer to be included in the output.
Takes care of writing vector tiles.
QString errorMessage() const
Returns error message related to the previous call to writeTiles().
void setMaxZoom(int maxZoom)
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24].
void setDestinationUri(const QString &uri)
Sets where and how the vector tiles will be written.
void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets coordinate transform context for transforms between layers and tile matrix CRS.
void setExtent(const QgsRectangle &extent)
Sets extent of vector tile output.
bool writeTiles(QgsFeedback *feedback=nullptr)
Writes vector tiles according to the configuration.
void setLayers(const QList< QgsVectorTileWriter::Layer > &layers)
Sets vector layers and their configuration for output of vector tiles.
void setMinZoom(int minZoom)
Sets the minimum zoom level of tiles. Allowed values are in interval [0,24].
void setMetadata(const QVariantMap &metadata)
Sets that will be written to the output dataset. See class description for more on metadata support.