QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
54 QStringList fieldsSorted = qgis::setToList( flds );
55 std::sort( fieldsSorted.begin(), fieldsSorted.end() );
56 for (
const QString &fieldName : qgis::as_const( fieldsSorted ) )
65 double s0 = 559082264.0287178;
66 double tileZoom2 = log( s0 / mapScale ) / log( 2 );
73 int tileZoom =
static_cast<int>( floor(
scaleToZoom( mapScale ) ) );
75 if ( tileZoom < sourceMinZoom )
76 tileZoom = sourceMinZoom;
77 if ( tileZoom > sourceMaxZoom )
78 tileZoom = sourceMaxZoom;
87 QSet<QString> fieldNames = qgis::listToSet( decoder.
layerFieldNames( layerName ) );
88 fieldNames << QStringLiteral(
"_geom_type" );
89 QMap<QString, QgsFields> perLayerFields;
91 perLayerFields[layerName] = fields;
96 for (
int i = 0; i < featuresList.count(); ++i )
103 for (
int k = 0; k < ggc->numGeometries(); ++k )
128 turl.replace( QLatin1String(
"{x}" ), QString::number( tile.
column() ), Qt::CaseInsensitive );
129 if ( turl.contains( QLatin1String(
"{-y}" ) ) )
131 turl.replace( QLatin1String(
"{-y}" ), QString::number( tileMatrix.
matrixHeight() - tile.
row() - 1 ), Qt::CaseInsensitive );
135 turl.replace( QLatin1String(
"{y}" ), QString::number( tile.
row() ), Qt::CaseInsensitive );
137 turl.replace( QLatin1String(
"{z}" ), QString::number( tile.
zoomLevel() ), Qt::CaseInsensitive );
143 return url.contains( QStringLiteral(
"{x}" ) ) &&
144 ( url.contains( QStringLiteral(
"{y}" ) ) || url.contains( QStringLiteral(
"{-y}" ) ) ) &&
145 url.contains( QStringLiteral(
"{z}" ) );
154 QPointF p1( req1.
column() + 0.5, req1.
row() + 0.5 );
155 QPointF p2( req2.
column() + 0.5, req2.
row() + 0.5 );
157 double d1 = std::max( std::fabs(
center.x() - p1.x() ), std::fabs(
center.y() - p1.y() ) );
158 double d2 = std::max( std::fabs(
center.x() - p2.x() ), std::fabs(
center.y() - p2.y() ) );
165 QVector<QgsTileXYZ> tiles;
166 for (
int tileRow = range.
startRow(); tileRow <= range.
endRow(); ++tileRow )
170 tiles.append(
QgsTileXYZ( tileColumn, tileRow, zoomLevel ) );
180 std::sort( tiles.begin(), tiles.end(), cmp );
Implements a map layer that is dedicated to rendering of vector tiles.
virtual void updateExtents(bool force=false)
Update the extents for the layer.
Stores coordinates of a tile in a tile matrix set.
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider,...
static QgsFields makeQgisFields(QSet< QString > flds)
Returns QgsFields instance based on the set of field names.
Range of tiles in a tile matrix to be rendered.
#define QgsDebugMsgLevel(str, level)
static double scaleToZoom(double mapScale)
Finds zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator.
QgsRectangle tileExtent(QgsTileXYZ id) const
Returns extent of the given tile in this matrix.
Container of fields for a vector layer.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
QPointF toQPointF() const
Converts a point to a QPointF.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
A rectangle specified with double values.
This class is responsible for decoding raw tile data written with Mapbox Vector Tiles encoding.
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
QgsVectorTileFeatures layerFeatures(const QMap< QString, QgsFields > &perLayerFields, const QgsCoordinateTransform &ct, const QSet< QString > *layerSubset=nullptr) const
Returns decoded features grouped by sub-layers.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
int endRow() const
Returns index of the last row in the range.
static QVector< QgsTileXYZ > tilesInRange(const QgsTileRange &range, int zoomLevel)
Returns a list of tiles in the given tile range.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width * height) and map...
static bool checkXYZUrlTemplate(const QString &url)
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)
QStringList layerFieldNames(const QString &layerName) const
Returns a list of all field names in a tile. It can only be called after a successful decode()
bool operator()(const QgsTileXYZ &req1, const QgsTileXYZ &req2)
QPointF center
Center in tile matrix (!) coordinates.
int matrixHeight() const
Returns number of rows of the tile matrix.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static void sortTilesByDistanceFromCenter(QVector< QgsTileXYZ > &tiles, const QPointF ¢er)
Orders tile requests according to the distance from view center (given in tile matrix coords)
QList< QgsFeature > QgsFeatureList
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
int endColumn() const
Returns index of the last column in the range.
int zoomLevel() const
Returns tile's zoom level (Z)
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
Abstract base class for all geometries.
static int scaleToZoomLevel(double mapScale, int sourceMinZoom, int sourceMaxZoom)
Finds best fitting zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator ...
A class to represent a 2D point.
int startRow() const
Returns index of the first row in the range.
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.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
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} for TM...
int row() const
Returns tile's row index (Y)
A geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
Represents a vector layer which manages a vector based data sets.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
a helper class for ordering tile requests according to the distance from view center
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes to the provider.
QByteArray getRawTile(QgsTileXYZ tileID)
Fetches raw tile data for the give tile coordinates.
QMap< QString, QVector< QgsFeature > > QgsVectorTileFeatures
Features of a vector tile, grouped by sub-layer names (key of the map)
bool decode(QgsTileXYZ tileID, const QByteArray &rawTileData)
Tries to decode raw tile data, returns true on success.
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.
int startColumn() const
Returns index of the first column in the range.
int column() const
Returns tile's column index (X)
Encapsulate a field in an attribute table or data source.