QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsMbTiles Class Reference

Utility class for reading and writing MBTiles files (which are SQLite3 databases). More...

#include <qgsmbtiles.h>

Public Member Functions

 QgsMbTiles (const QString &filename)
 Constructs MBTiles reader (but it does not open the file yet)
 
bool create ()
 Creates a new MBTiles file and initializes it with metadata and tiles tables.
 
QgsRectangle extent () const
 Returns bounding box from metadata, given in WGS 84 (if available)
 
bool isOpen () const
 Returns whether the MBTiles file is currently opened.
 
QString metadataValue (const QString &key) const
 Requests metadata value for the given key.
 
bool open ()
 Tries to open the file, returns true on success.
 
void setMetadataValue (const QString &key, const QString &value) const
 Sets metadata value for the given key.
 
void setTileData (int z, int x, int y, const QByteArray &data) const
 Adds tile data for the given tile coordinates.
 
QByteArray tileData (int z, int x, int y) const
 Returns raw tile data for given tile.
 
QImage tileDataAsImage (int z, int x, int y) const
 Returns tile decoded as a raster image (if stored in a known format like JPG or PNG)
 

Detailed Description

Utility class for reading and writing MBTiles files (which are SQLite3 databases).

See the specification for more details: https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md

Since
QGIS 3.14

Definition at line 38 of file qgsmbtiles.h.

Constructor & Destructor Documentation

◆ QgsMbTiles()

QgsMbTiles::QgsMbTiles ( const QString &  filename)
explicit

Constructs MBTiles reader (but it does not open the file yet)

Definition at line 24 of file qgsmbtiles.cpp.

Member Function Documentation

◆ create()

bool QgsMbTiles::create ( )

Creates a new MBTiles file and initializes it with metadata and tiles tables.

It is up to the caller to set appropriate metadata entries and add tiles afterwards. Returns true on success. If the file exists already, returns false.

Definition at line 52 of file qgsmbtiles.cpp.

◆ extent()

QgsRectangle QgsMbTiles::extent ( ) const

Returns bounding box from metadata, given in WGS 84 (if available)

Definition at line 133 of file qgsmbtiles.cpp.

◆ isOpen()

bool QgsMbTiles::isOpen ( ) const

Returns whether the MBTiles file is currently opened.

Definition at line 47 of file qgsmbtiles.cpp.

◆ metadataValue()

QString QgsMbTiles::metadataValue ( const QString &  key) const

Requests metadata value for the given key.

Definition at line 83 of file qgsmbtiles.cpp.

◆ open()

bool QgsMbTiles::open ( )

Tries to open the file, returns true on success.

Definition at line 29 of file qgsmbtiles.cpp.

◆ setMetadataValue()

void QgsMbTiles::setMetadataValue ( const QString &  key,
const QString &  value 
) const

Sets metadata value for the given key.

Does not overwrite existing entries.

Note
the database has to be opened in read-write mode (currently only when opened with create()

Definition at line 109 of file qgsmbtiles.cpp.

◆ setTileData()

void QgsMbTiles::setTileData ( int  z,
int  x,
int  y,
const QByteArray &  data 
) const

Adds tile data for the given tile coordinates.

Does not overwrite existing entries.

Note
the database has to be opened in read-write mode (currently only when opened with create()

Definition at line 185 of file qgsmbtiles.cpp.

◆ tileData()

QByteArray QgsMbTiles::tileData ( int  z,
int  x,
int  y 
) const

Returns raw tile data for given tile.

Definition at line 146 of file qgsmbtiles.cpp.

◆ tileDataAsImage()

QImage QgsMbTiles::tileDataAsImage ( int  z,
int  x,
int  y 
) const

Returns tile decoded as a raster image (if stored in a known format like JPG or PNG)

Definition at line 173 of file qgsmbtiles.cpp.


The documentation for this class was generated from the following files: