mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
Loading...
Searching...
No Matches
metaTile Class Reference

In-memory builder and serializer for a METATILE x METATILE grid of rendered map tiles. More...

#include <metatile.h>

Public Member Functions

 metaTile (const std::string &xmlconfig, const std::string &options, int x, int y, int z)
 Construct a new metaTile container for the given map style and top-left tile coordinates.
void clear ()
 Reset all sub-tile image payloads in the METATILE x METATILE grid to empty strings.
void set (int x, int y, const std::string &data)
 Store encoded image data for a single sub-tile within the metatile grid.
const std::string get (int x, int y)
 Retrieve the encoded image data for a single sub-tile within the metatile grid.
int xyz_to_meta_offset (int x, int y, int z)
 Compute the linear index into a metatile's offset table for tile (x, y, z).
void save (struct storage_backend *store)
 Serialize the metatile header, index table, and tile payloads, and write to storage.
void expire_tiles (int sock, const char *host, const char *uri)
 Send HTCP cache purge requests for every individual tile covered by this metatile.

Detailed Description

In-memory builder and serializer for a METATILE x METATILE grid of rendered map tiles.

Collects individual rendered tile payloads (set()), serializes them with a meta_layout header and offset index table into a storage backend (save()), and dispatches HTCP cache invalidation requests for all constituent tiles (expire_tiles()).

Constructor & Destructor Documentation

◆ metaTile()

metaTile::metaTile ( const std::string & xmlconfig,
const std::string & options,
int x,
int y,
int z )

Construct a new metaTile container for the given map style and top-left tile coordinates.

Initializes all sub-tile image buffers to empty strings via clear().

Parameters
xmlconfigLogical map style name (e.g., "default").
optionsStyle parameterization options string (empty string if unused).
xTop-left tile X coordinate of the metatile (aligned to METATILE).
yTop-left tile Y coordinate of the metatile (aligned to METATILE).
zTile zoom level.

Member Function Documentation

◆ clear()

void metaTile::clear ( )

Reset all sub-tile image payloads in the METATILE x METATILE grid to empty strings.

◆ expire_tiles()

void metaTile::expire_tiles ( int sock,
const char * host,
const char * uri )

Send HTCP cache purge requests for every individual tile covered by this metatile.

Clamps the iteration range to min(2^z, METATILE) so non-existent coordinates are not purged at very low zoom levels (e.g., z = 0..2).

Parameters
sockConnected UDP socket descriptor to the HTCP cache server (no-op if < 0).
hostPublic HTTP hostname used in the purged tile URLs.
uriBase URI path prefix for the tileset.

◆ get()

const std::string metaTile::get ( int x,
int y )

Retrieve the encoded image data for a single sub-tile within the metatile grid.

Parameters
xSub-tile X offset within the metatile (0 <= x < METATILE).
ySub-tile Y offset within the metatile (0 <= y < METATILE).
Returns
Copy of the binary image payload string (empty if unset).

◆ save()

void metaTile::save ( struct storage_backend * store)

Serialize the metatile header, index table, and tile payloads, and write to storage.

Assembles the binary metatile blob in memory:

  1. struct meta_layout: Magic header (META_MAGIC), tile count, and base (x, y, z).
  2. struct entry[METATILE * METATILE]: Byte offset and byte size for each sub-tile.
  3. Concatenated raw image payloads for all sub-tiles.

Writes the resulting buffer via store->metatile_write() and logs a warning if memory allocation or storage persistence fails.

Parameters
storeStorage backend instance responsible for persisting the metatile.

◆ set()

void metaTile::set ( int x,
int y,
const std::string & data )

Store encoded image data for a single sub-tile within the metatile grid.

Parameters
xSub-tile X offset within the metatile (0 <= x < METATILE).
ySub-tile Y offset within the metatile (0 <= y < METATILE).
dataBinary image payload (e.g., PNG/JPEG/WebP bytes).

◆ xyz_to_meta_offset()

int metaTile::xyz_to_meta_offset ( int x,
int y,
int z )

Compute the linear index into a metatile's offset table for tile (x, y, z).

Masks the lower bits of x and y against METATILE - 1 (assuming METATILE is a power of two) and arranges entries in column-major order (dx * METATILE + dy).

Parameters
xGlobal tile X coordinate.
yGlobal tile Y coordinate.
zTile zoom level (unused; kept for signature consistency).
Returns
Zero-based index in [0, METATILE * METATILE - 1].

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