26 QString QgsWriteVectorTilesBaseAlgorithm::group()
const
28 return QObject::tr(
"Vector tiles" );
31 QString QgsWriteVectorTilesBaseAlgorithm::groupId()
const
33 return QStringLiteral(
"vectortiles" );
36 QString 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." );
41 void 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 );
93 QString QgsWriteVectorTilesXyzAlgorithm::name()
const
95 return QStringLiteral(
"writevectortiles_xyz" );
98 QString QgsWriteVectorTilesXyzAlgorithm::displayName()
const
100 return QObject::tr(
"Write Vector Tiles (XYZ)" );
105 return new QgsWriteVectorTilesXyzAlgorithm();
108 void 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 );
134 QString QgsWriteVectorTilesMbtilesAlgorithm::name()
const
136 return QStringLiteral(
"writevectortiles_mbtiles" );
139 QString QgsWriteVectorTilesMbtilesAlgorithm::displayName()
const
141 return QObject::tr(
"Write Vector Tiles (MBTiles)" );
146 return new QgsWriteVectorTilesMbtilesAlgorithm();
149 void 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( {{
162 QStringLiteral(
"widget_wrapper" ), QVariantMap(
163 {{QStringLiteral(
"value_hints" ), QStringList() << QStringLiteral(
"overlay" ) << QStringLiteral(
"baselayer" ) }}
167 addParameter( metaTypeParam.release() );
168 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_CENTER" ), QObject::tr(
"Metadata: Center" ), QVariant(),
false,
true ) );
173 const QString outputFile = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
175 dsUri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"mbtiles" ) );
176 dsUri.
setParam( QStringLiteral(
"url" ), outputFile );
181 const QString metaName = parameterAsString( parameters, QStringLiteral(
"META_NAME" ), context );
182 const QString metaDesciption = parameterAsString( parameters, QStringLiteral(
"META_DESCRIPTION" ), context );
183 const QString metaAttribution = parameterAsString( parameters, QStringLiteral(
"META_ATTRIBUTION" ), context );
184 const QString metaVersion = parameterAsString( parameters, QStringLiteral(
"META_VERSION" ), context );
185 const QString metaType = parameterAsString( parameters, QStringLiteral(
"META_TYPE" ), context );
186 const QString metaCenter = parameterAsString( parameters, QStringLiteral(
"META_CENTER" ), context );
189 if ( !metaName.isEmpty() )
190 meta[
"name"] = metaName;
191 if ( !metaDesciption.isEmpty() )
192 meta[
"description"] = metaDesciption;
193 if ( !metaAttribution.isEmpty() )
194 meta[
"attribution"] = metaAttribution;
195 if ( !metaVersion.isEmpty() )
196 meta[
"version"] = metaVersion;
197 if ( !metaType.isEmpty() )
198 meta[
"type"] = metaType;
199 if ( !metaCenter.isEmpty() )
200 meta[
"center"] = metaCenter;
204 outputs.insert( QStringLiteral(
"OUTPUT" ), outputFile );