25 QString QgsWriteVectorTilesBaseAlgorithm::group()
const
27 return QObject::tr(
"Vector tiles" );
30 QString QgsWriteVectorTilesBaseAlgorithm::groupId()
const
32 return QStringLiteral(
"vectortiles" );
35 QString QgsWriteVectorTilesBaseAlgorithm::shortHelpString()
const
37 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." );
40 void QgsWriteVectorTilesBaseAlgorithm::addBaseParameters()
53 int minZoom = parameterAsInt( parameters, QStringLiteral(
"MIN_ZOOM" ), context );
54 int maxZoom = parameterAsInt( parameters, QStringLiteral(
"MAX_ZOOM" ), context );
56 QVariant layersVariant = parameters.value( parameterDefinition( QStringLiteral(
"LAYERS" ) )->name() );
67 prepareWriter( writer, parameters, context, outputs );
74 if ( parameters.contains( QStringLiteral(
"EXTENT" ) ) )
92 QString QgsWriteVectorTilesXyzAlgorithm::name()
const
94 return QStringLiteral(
"writevectortiles_xyz" );
97 QString QgsWriteVectorTilesXyzAlgorithm::displayName()
const
99 return QObject::tr(
"Write Vector Tiles (XYZ)" );
104 return new QgsWriteVectorTilesXyzAlgorithm();
107 void QgsWriteVectorTilesXyzAlgorithm::initAlgorithm(
const QVariantMap & )
110 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"XYZ_TEMPLATE" ), QObject::tr(
"File template" ), QStringLiteral(
"{z}/{x}/{y}.pbf" ) ) );
117 QString outputDir = parameterAsString( parameters, QStringLiteral(
"OUTPUT_DIRECTORY" ), context );
118 QString xyzTemplate = parameterAsString( parameters, QStringLiteral(
"XYZ_TEMPLATE" ), context );
120 dsUri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"xyz" ) );
121 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( outputDir +
"/" + xyzTemplate ).toString() );
126 outputs.insert( QStringLiteral(
"OUTPUT_DIRECTORY" ), outputDir );
133 QString QgsWriteVectorTilesMbtilesAlgorithm::name()
const
135 return QStringLiteral(
"writevectortiles_mbtiles" );
138 QString QgsWriteVectorTilesMbtilesAlgorithm::displayName()
const
140 return QObject::tr(
"Write Vector Tiles (MBTiles)" );
145 return new QgsWriteVectorTilesMbtilesAlgorithm();
148 void QgsWriteVectorTilesMbtilesAlgorithm::initAlgorithm(
const QVariantMap & )
155 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_NAME" ), QObject::tr(
"Metadata: Name" ), QVariant(),
false,
true ) );
156 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_DESCRIPTION" ), QObject::tr(
"Metadata: Description" ), QVariant(),
false,
true ) );
157 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_ATTRIBUTION" ), QObject::tr(
"Metadata: Attribution" ), QVariant(),
false,
true ) );
158 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_VERSION" ), QObject::tr(
"Metadata: Version" ), QVariant(),
false,
true ) );
159 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_TYPE" ), QObject::tr(
"Metadata: Type" ), QVariant(),
false,
true ) );
160 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"META_CENTER" ), QObject::tr(
"Metadata: Center" ), QVariant(),
false,
true ) );
165 QString outputFile = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
167 dsUri.
setParam( QStringLiteral(
"type" ), QStringLiteral(
"mbtiles" ) );
168 dsUri.
setParam( QStringLiteral(
"url" ), outputFile );
173 QString metaName = parameterAsString( parameters, QStringLiteral(
"META_NAME" ), context );
174 QString metaDesciption = parameterAsString( parameters, QStringLiteral(
"META_DESCRIPTION" ), context );
175 QString metaAttribution = parameterAsString( parameters, QStringLiteral(
"META_ATTRIBUTION" ), context );
176 QString metaVersion = parameterAsString( parameters, QStringLiteral(
"META_VERSION" ), context );
177 QString metaType = parameterAsString( parameters, QStringLiteral(
"META_TYPE" ), context );
178 QString metaCenter = parameterAsString( parameters, QStringLiteral(
"META_CENTER" ), context );
181 if ( !metaName.isEmpty() )
182 meta[
"name"] = metaName;
183 if ( !metaDesciption.isEmpty() )
184 meta[
"description"] = metaDesciption;
185 if ( !metaAttribution.isEmpty() )
186 meta[
"attribution"] = metaAttribution;
187 if ( !metaVersion.isEmpty() )
188 meta[
"version"] = metaVersion;
189 if ( !metaType.isEmpty() )
190 meta[
"type"] = metaType;
191 if ( !metaCenter.isEmpty() )
192 meta[
"center"] = metaCenter;
196 outputs.insert( QStringLiteral(
"OUTPUT" ), outputFile );