QGIS API Documentation 4.3.0-Master (0ff9723465c)
Loading...
Searching...
No Matches
qgsmbtiles.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmbtiles.h
3 --------------------------------------
4 Date : January 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 QGSMBTILES_H
17#define QGSMBTILES_H
18
19#include <sqlite3.h>
20
21#include "qgis_core.h"
22#include "qgssqliteutils.h"
23
24#define SIP_NO_FILE
25
26class QImage;
27class QgsRectangle;
28
38class CORE_EXPORT QgsMbTiles
39{
40 public:
42 explicit QgsMbTiles( const QString &filename );
43
45 bool open();
46
48 bool isOpen() const;
49
57 bool finalize();
58
69 bool create( bool deferIndexCreation = false );
70
72 QString metadataValue( const QString &key ) const;
73
78 void setMetadataValue( const QString &key, const QString &value ) const;
79
81 QgsRectangle extent() const;
82
84 QByteArray tileData( int z, int x, int y ) const;
85
87 QImage tileDataAsImage( int z, int x, int y ) const;
88
93 void setTileData( int z, int x, int y, const QByteArray &data ) const;
94
99 struct TileData
100 {
101 int z = 0;
102 int x = 0;
103 int y = 0;
104 QByteArray data;
105 };
106
112 void setTileData( const QList<TileData> &tiles ) const;
113
119 QString lastError() const { return mLastError; }
120
121 private:
122 QString mFilename;
124 bool mDeferredIndexCreation = false;
125 mutable QString mLastError;
126};
127
128
129#endif // QGSMBTILES_H
QgsMbTiles(const QString &filename)
Constructs MBTiles reader (but it does not open the file yet).
QString metadataValue(const QString &key) const
Requests metadata value for the given key.
bool open()
Tries to open the file, returns true on success.
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).
bool finalize()
Finalizes the database after writing all tiles.
QByteArray tileData(int z, int x, int y) const
Returns raw tile data for given tile.
void setMetadataValue(const QString &key, const QString &value) const
Sets metadata value for the given key.
bool isOpen() const
Returns whether the MBTiles file is currently opened.
void setTileData(int z, int x, int y, const QByteArray &data) const
Adds tile data for the given tile coordinates.
QString lastError() const
Returns the latest error message obtained from the database.
Definition qgsmbtiles.h:119
bool create(bool deferIndexCreation=false)
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).
A rectangle specified with double values.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
Struct representing a raw image tile.
Definition qgsmbtiles.h:100