Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make QgsVectorTilesUtils available in Python bindings #58989

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions python/PyQt6/core/auto_additions/qgsvectortileutils.py
Original file line number Diff line number Diff line change
@@ -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
102 changes: 102 additions & 0 deletions python/PyQt6/core/auto_generated/vectortile/qgsvectortileutils.sip.in
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
1 change: 1 addition & 0 deletions python/PyQt6/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions python/core/auto_additions/qgsvectortileutils.py
Original file line number Diff line number Diff line change
@@ -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
102 changes: 102 additions & 0 deletions python/core/auto_generated/vectortile/qgsvectortileutils.sip.in
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/core/vectortile/qgsvectortileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

#include "qgis_core.h"

#define SIP_NO_FILE

#include <QSet>
#include <QVariantMap>

Expand Down Expand Up @@ -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 );
Expand Down
Loading