Enroute Flight Navigation
A navigation app for VFR pilots
GeoMaps::TileServer Class Reference

HTTP server for mapbox' MBTiles files. More...

#include <TileServer.h>

Public Slots

void addMbtilesFileSet (const QString &baseName, const QVector< QSharedPointer< FileFormats::MBTILES > > &MBTilesFiles)
 Add a new set of tile files.
 
void removeMbtilesFileSet (const QString &baseName)
 Removes a set of tile files.
 
void removeMbtilesFileSets ()
 Removes a set of tile files.
 

Signals

void serverUrlChanged ()
 Notification signal for the property with the same name.
 

Public Member Functions

 TileServer (QObject *parent=nullptr)
 Create a new tile server.
 
QString serverUrl ()
 Getter function for the property with the same name.
 

Properties

QString serverUrl
 URL under which this server is presently reachable.
 

Detailed Description

HTTP server for mapbox' MBTiles files.

This class features a simple HTTP server that serve the following files to http://127.0.0.1:xxxx/path.

  • If path is a file name, the server checks if the file is available in the resource system of the app and serves that file.
  • If path equals "aviationData.geojson", the server returns a GeoJSON document that contains the full aviation data, as provided by GlobalObject::geoMapProvider()->geoJSON().
  • If path equals the base name of an MBTilesFileSet, then the server returns a JSON document describing the MBTiles.
  • If path equals "baseName/z/x/y.XXX", then the server returns an individual tile from the tile set.

This server is able to handle several sets of MBTiles files. Each set is available under a single URL, and the MBTile files in each set are expected to contain identical metadata. To serve a tile request, the server goes through the MBTiles files in random order and serves the first tile it can find. Tiles contained in more than one file need thus to be identical. A typical use case would be a server that contains to sets of files, one set with vector tiles containing openstreetmap data and one set with raster data used for hillshading. Each set contains two MBTiles files, one for Africa and one for Europe.

Definition at line 58 of file TileServer.h.

Constructor & Destructor Documentation

◆ TileServer()

GeoMaps::TileServer::TileServer ( QObject * parent = nullptr)
explicit

Create a new tile server.

The tile server will find a free port and listen to 127.0.0.1:port. The method serverUrl() returns the precise Url where the server will be available.

Parameters
parentThe standard QObject parent

Member Function Documentation

◆ addMbtilesFileSet

void GeoMaps::TileServer::addMbtilesFileSet ( const QString & baseName,
const QVector< QSharedPointer< FileFormats::MBTILES > > & MBTilesFiles )
slot

Add a new set of tile files.

This method adds a new set of tile files, that will be available under serverUrl()+"/baseName" (typically, this is a URL of the form 'http://localhost:8080/basename').

Parameters
baseNameThe path under which the tiles will be available.
MBTilesFilesThe name of one or more mbtile files on the disk, which are expected to conform to the MBTiles Specification 1.3 (https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md). These files must exist until the file set is removed or the sever is destructed, or else replies to tile requests will yield undefined results. The tile files are expected to agree in their metadata, and the metadata (attribution, description, format, name, minzoom, maxzoom) is read only from one of the files (a random one, in fact). If a tile is contained in more than one of the files, the data is expected to be identical in each of the files.

◆ removeMbtilesFileSet

void GeoMaps::TileServer::removeMbtilesFileSet ( const QString & baseName)
inlineslot

Removes a set of tile files.

Parameters
baseNamePath of tiles to remove

Definition at line 129 of file TileServer.h.

◆ removeMbtilesFileSets

void GeoMaps::TileServer::removeMbtilesFileSets ( )
inlineslot

Removes a set of tile files.

Parameters
baseNamePath of tiles to remove

Definition at line 135 of file TileServer.h.

◆ serverUrl()

QString GeoMaps::TileServer::serverUrl ( )
nodiscard

Getter function for the property with the same name.

Returns
Property serverUrl

Property Documentation

◆ serverUrl

QString GeoMaps::TileServer::serverUrl
read

URL under which this server is presently reachable.

The property holds returns the Url where the server is listening to incoming connections. This is typically string of the form "http://127.0.0.1:3470". If the server is not listening to incoming connections, the string is empty.

Definition at line 88 of file TileServer.h.


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