QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsvectortileutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortileutils.h
3 --------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVECTORTILEUTILS_H
17#define QGSVECTORTILEUTILS_H
18
19#include "qgis_core.h"
20#include "qgshttpheaders.h"
21
22#include <QSet>
23#include <QVariantMap>
24
25class QPointF;
26class QPolygon;
27
29class QgsFields;
30class QgsMapToPixel;
31class QgsRectangle;
32class QgsVectorLayer;
33
34class QgsTileMatrix;
35class QgsTileRange;
36class QgsTileXYZ;
39
46class CORE_EXPORT QgsVectorTileUtils
47{
48 public:
49
55 static void updateUriSources( QString &uri SIP_INOUT, bool forceUpdate = false );
56
58 static void sortTilesByDistanceFromCenter( QVector<QgsTileXYZ> &tiles, QPointF center );
59
65 static QPolygon tilePolygon( QgsTileXYZ id, const QgsCoordinateTransform &ct, const QgsTileMatrix &tm, const QgsMapToPixel &mtp );
66
68 static QgsFields makeQgisFields( const QSet<QString> &flds );
69
78 static double scaleToZoom( double mapScale, double z0Scale = 559082264.0287178 );
79
86 static int scaleToZoomLevel( double mapScale, int sourceMinZoom, int sourceMaxZoom, double z0Scale = 559082264.0287178 );
88 static QgsVectorLayer *makeVectorLayerForTile( QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName );
90 static QString formatXYZUrlTemplate( const QString &url, QgsTileXYZ tile, const QgsTileMatrix &tileMatrix );
92 static bool checkXYZUrlTemplate( const QString &url );
93
100 static void loadSprites( const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl = QString() );
101
102 private:
104 static QMap<QString, QString> parseStyleSourceUrl( const QString &styleUrl, const QgsHttpHeaders &headers = QgsHttpHeaders(), const QString &authCfg = QString() );
105
107 static QVariantList parseStyleSourceContentUrl( const QString &sourceUrl, const QgsHttpHeaders &headers = QgsHttpHeaders(), const QString &authCfg = QString() );
108
110
111};
112
113#endif // QGSVECTORTILEUTILS_H
Handles coordinate transforms between two coordinate systems.
Container of fields for a vector layer.
Definition qgsfields.h:46
Implements simple HTTP header management.
Context for a MapBox GL style conversion operation.
Perform transforms between map coordinates and device coordinates.
A rectangle specified with double values.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition qgstiles.h:158
A range of tiles in a tile matrix.
Definition qgstiles.h:114
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:39
Represents a vector layer which manages a vector based dataset.
Implements a map layer that is dedicated to rendering of vector tiles.
Utility functions for working with vector tiles.
static QgsVectorLayer * makeVectorLayerForTile(QgsVectorTileLayer *mvt, QgsTileXYZ tileID, const QString &layerName)
Returns a temporary vector layer for given sub-layer of tile in vector tile layer.
static bool checkXYZUrlTemplate(const QString &url)
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders).
static QString formatXYZUrlTemplate(const QString &url, QgsTileXYZ tile, const QgsTileMatrix &tileMatrix)
Returns formatted tile URL string replacing {x}, {y}, {z} placeholders (or {-y} instead of {y}...
static void sortTilesByDistanceFromCenter(QVector< QgsTileXYZ > &tiles, QPointF center)
Orders tile requests according to the distance from view center (given in tile matrix coords).
friend class TestQgsVectorTileUtils
static QPolygon tilePolygon(QgsTileXYZ id, const QgsCoordinateTransform &ct, const QgsTileMatrix &tm, const QgsMapToPixel &mtp)
Returns polygon (made by four corners of the tile) in screen coordinates.
static double scaleToZoom(double mapScale, double z0Scale=559082264.0287178)
Finds zoom level given map scale denominator.
static int scaleToZoomLevel(double mapScale, int sourceMinZoom, int sourceMaxZoom, double z0Scale=559082264.0287178)
Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.
static void updateUriSources(QString &uri SIP_INOUT, bool forceUpdate=false)
Parses the style URL to update the source URLs in the uri.
static QgsFields makeQgisFields(const QSet< QString > &flds)
Returns QgsFields instance based on the set of field names.
static void loadSprites(const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl=QString())
Downloads the sprite image and sets it to the conversion context.
#define SIP_INOUT
Definition qgis_sip.h:79