make QgsVectorTilesUtils available to Python bindings (#58989)

This commit is contained in:
Denis Rouzaud 2024-10-07 18:07:48 +02:00 committed by GitHub
parent 2febb72730
commit 5f18ff84a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 237 additions and 3 deletions

View File

@ -0,0 +1,15 @@
# The following has been generated automatically from src/core/vectortile/qgsvectortileutils.h
try:
QgsVectorTileUtils.updateUriSources = staticmethod(QgsVectorTileUtils.updateUriSources)
QgsVectorTileUtils.sortTilesByDistanceFromCenter = staticmethod(QgsVectorTileUtils.sortTilesByDistanceFromCenter)
QgsVectorTileUtils.tilePolygon = staticmethod(QgsVectorTileUtils.tilePolygon)
QgsVectorTileUtils.makeQgisFields = staticmethod(QgsVectorTileUtils.makeQgisFields)
QgsVectorTileUtils.scaleToZoom = staticmethod(QgsVectorTileUtils.scaleToZoom)
QgsVectorTileUtils.scaleToZoomLevel = staticmethod(QgsVectorTileUtils.scaleToZoomLevel)
QgsVectorTileUtils.makeVectorLayerForTile = staticmethod(QgsVectorTileUtils.makeVectorLayerForTile)
QgsVectorTileUtils.formatXYZUrlTemplate = staticmethod(QgsVectorTileUtils.formatXYZUrlTemplate)
QgsVectorTileUtils.checkXYZUrlTemplate = staticmethod(QgsVectorTileUtils.checkXYZUrlTemplate)
QgsVectorTileUtils.loadSprites = staticmethod(QgsVectorTileUtils.loadSprites)
QgsVectorTileUtils.__group__ = ['vectortile']
except NameError:
pass

View File

@ -0,0 +1,102 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vectortile/qgsvectortileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsVectorTileUtils
{
%Docstring(signature="appended")
Random utility functions for working with vector tiles
.. versionadded:: 3.14
%End
%TypeHeaderCode
#include "qgsvectortileutils.h"
%End
public:
static void updateUriSources( QString &uri /In,Out/, bool forceUpdate = false );
%Docstring
Parses the style URL to update the source URLs in the ``uri``.
If ``forceUpdate`` is ``True``, any existing source will be updated.
.. versionadded:: 3.40
%End
static void sortTilesByDistanceFromCenter( QVector<QgsTileXYZ> &tiles, QPointF center );
%Docstring
Orders tile requests according to the distance from view center (given in tile matrix coords)
%End
static QPolygon tilePolygon( QgsTileXYZ id, const QgsCoordinateTransform &ct, const QgsTileMatrix &tm, const QgsMapToPixel &mtp );
%Docstring
Returns polygon (made by four corners of the tile) in screen coordinates
:raises QgsCsException:
%End
static QgsFields makeQgisFields( const QSet<QString> &flds );
%Docstring
Returns :py:class:`QgsFields` instance based on the set of field names
%End
static double scaleToZoom( double mapScale, double z0Scale = 559082264.0287178 );
%Docstring
Finds zoom level given map scale denominator.
The ``z0Scale`` argument gives the scale denominator at zoom level 0, where the default
value corresponds to GoogleCRS84Quad tile matrix set
.. versionadded:: 3.16
%End
static int scaleToZoomLevel( double mapScale, int sourceMinZoom, int sourceMaxZoom, double z0Scale = 559082264.0287178 );
%Docstring
Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.
The ``z0Scale`` argument gives the scale denominator at zoom level 0, where the default
value corresponds to GoogleCRS84Quad tile matrix set.
%End
static QgsVectorLayer *makeVectorLayerForTile( QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName );
%Docstring
Returns a temporary vector layer for given sub-layer of tile in vector tile layer
%End
static QString formatXYZUrlTemplate( const QString &url, QgsTileXYZ tile, const QgsTileMatrix &tileMatrix );
%Docstring
Returns formatted tile URL string replacing {x}, {y}, {z} placeholders (or {-y} instead of {y} for TMS convention)
%End
static bool checkXYZUrlTemplate( const QString &url );
%Docstring
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)
%End
static void loadSprites( const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl = QString() );
%Docstring
Downloads the sprite image and sets it to the conversion context
:param styleDefinition: the style definition map
:param context: the style conversion context
:param styleUrl: optional the style url
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vectortile/qgsvectortileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/

View File

@ -798,6 +798,7 @@
%Include auto_generated/vectortile/qgsvectortilelayer.sip
%Include auto_generated/vectortile/qgsvectortilematrixset.sip
%Include auto_generated/vectortile/qgsvectortilerenderer.sip
%Include auto_generated/vectortile/qgsvectortileutils.sip
%Include auto_generated/vectortile/qgsvectortilewriter.sip
%Include auto_generated/vectortile/qgsvtpktiles.sip
%Include auto_generated/gps/qgsqtlocationconnection.sip

View File

@ -0,0 +1,15 @@
# The following has been generated automatically from src/core/vectortile/qgsvectortileutils.h
try:
QgsVectorTileUtils.updateUriSources = staticmethod(QgsVectorTileUtils.updateUriSources)
QgsVectorTileUtils.sortTilesByDistanceFromCenter = staticmethod(QgsVectorTileUtils.sortTilesByDistanceFromCenter)
QgsVectorTileUtils.tilePolygon = staticmethod(QgsVectorTileUtils.tilePolygon)
QgsVectorTileUtils.makeQgisFields = staticmethod(QgsVectorTileUtils.makeQgisFields)
QgsVectorTileUtils.scaleToZoom = staticmethod(QgsVectorTileUtils.scaleToZoom)
QgsVectorTileUtils.scaleToZoomLevel = staticmethod(QgsVectorTileUtils.scaleToZoomLevel)
QgsVectorTileUtils.makeVectorLayerForTile = staticmethod(QgsVectorTileUtils.makeVectorLayerForTile)
QgsVectorTileUtils.formatXYZUrlTemplate = staticmethod(QgsVectorTileUtils.formatXYZUrlTemplate)
QgsVectorTileUtils.checkXYZUrlTemplate = staticmethod(QgsVectorTileUtils.checkXYZUrlTemplate)
QgsVectorTileUtils.loadSprites = staticmethod(QgsVectorTileUtils.loadSprites)
QgsVectorTileUtils.__group__ = ['vectortile']
except NameError:
pass

View File

@ -0,0 +1,102 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vectortile/qgsvectortileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsVectorTileUtils
{
%Docstring(signature="appended")
Random utility functions for working with vector tiles
.. versionadded:: 3.14
%End
%TypeHeaderCode
#include "qgsvectortileutils.h"
%End
public:
static void updateUriSources( QString &uri /In,Out/, bool forceUpdate = false );
%Docstring
Parses the style URL to update the source URLs in the ``uri``.
If ``forceUpdate`` is ``True``, any existing source will be updated.
.. versionadded:: 3.40
%End
static void sortTilesByDistanceFromCenter( QVector<QgsTileXYZ> &tiles, QPointF center );
%Docstring
Orders tile requests according to the distance from view center (given in tile matrix coords)
%End
static QPolygon tilePolygon( QgsTileXYZ id, const QgsCoordinateTransform &ct, const QgsTileMatrix &tm, const QgsMapToPixel &mtp );
%Docstring
Returns polygon (made by four corners of the tile) in screen coordinates
:raises QgsCsException:
%End
static QgsFields makeQgisFields( const QSet<QString> &flds );
%Docstring
Returns :py:class:`QgsFields` instance based on the set of field names
%End
static double scaleToZoom( double mapScale, double z0Scale = 559082264.0287178 );
%Docstring
Finds zoom level given map scale denominator.
The ``z0Scale`` argument gives the scale denominator at zoom level 0, where the default
value corresponds to GoogleCRS84Quad tile matrix set
.. versionadded:: 3.16
%End
static int scaleToZoomLevel( double mapScale, int sourceMinZoom, int sourceMaxZoom, double z0Scale = 559082264.0287178 );
%Docstring
Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.
The ``z0Scale`` argument gives the scale denominator at zoom level 0, where the default
value corresponds to GoogleCRS84Quad tile matrix set.
%End
static QgsVectorLayer *makeVectorLayerForTile( QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName );
%Docstring
Returns a temporary vector layer for given sub-layer of tile in vector tile layer
%End
static QString formatXYZUrlTemplate( const QString &url, QgsTileXYZ tile, const QgsTileMatrix &tileMatrix );
%Docstring
Returns formatted tile URL string replacing {x}, {y}, {z} placeholders (or {-y} instead of {y} for TMS convention)
%End
static bool checkXYZUrlTemplate( const QString &url );
%Docstring
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)
%End
static void loadSprites( const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl = QString() );
%Docstring
Downloads the sprite image and sets it to the conversion context
:param styleDefinition: the style definition map
:param context: the style conversion context
:param styleUrl: optional the style url
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vectortile/qgsvectortileutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/

View File

@ -798,6 +798,7 @@
%Include auto_generated/vectortile/qgsvectortilelayer.sip
%Include auto_generated/vectortile/qgsvectortilematrixset.sip
%Include auto_generated/vectortile/qgsvectortilerenderer.sip
%Include auto_generated/vectortile/qgsvectortileutils.sip
%Include auto_generated/vectortile/qgsvectortilewriter.sip
%Include auto_generated/vectortile/qgsvtpktiles.sip
%Include auto_generated/gps/qgsqtlocationconnection.sip

View File

@ -18,8 +18,6 @@
#include "qgis_core.h"
#define SIP_NO_FILE
#include <QSet>
#include <QVariantMap>
@ -56,7 +54,7 @@ class CORE_EXPORT QgsVectorTileUtils
* If \a forceUpdate is TRUE, any existing source will be updated.
* \since QGIS 3.40
*/
static void updateUriSources( QString &uri SIP_OUT, bool forceUpdate = false );
static void updateUriSources( QString &uri SIP_INOUT, bool forceUpdate = false );
//! Orders tile requests according to the distance from view center (given in tile matrix coords)
static void sortTilesByDistanceFromCenter( QVector<QgsTileXYZ> &tiles, QPointF center );