mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
Loading...
Searching...
No Matches
metatile.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 - 2026 by mod_tile contributors (see AUTHORS file)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; If not, see http://www.gnu.org/licenses/.
16 */
17
18#ifndef METATILE_H
19#define METATILE_H
20
21#include <stdlib.h>
22
23#include "config.h"
24#include "render_config.h"
25
26#ifdef __cplusplus
27#include <sstream>
28extern "C" {
29#endif
30
32#define META_MAGIC "META"
34#define META_MAGIC_COMPRESSED "METZ"
35
39 struct entry {
41 int offset;
43 int size;
44 };
45
52 struct meta_layout {
54 char magic[4];
56 int count;
58 int x, y, z;
60 struct entry index[];
61 };
62
63#ifdef __cplusplus
64}
65#endif
66
67#ifdef __cplusplus
76{
77 public:
78 metaTile(const std::string &xmlconfig, const std::string &options, int x, int y, int z);
79 void clear();
80 void set(int x, int y, const std::string &data);
81 const std::string get(int x, int y);
82 int xyz_to_meta_offset(int x, int y, int z);
83 void save(struct storage_backend *store);
84 void expire_tiles(int sock, const char *host, const char *uri);
85
86 private:
88 int x_, y_, z_;
90 std::string xmlconfig_;
92 std::string options_;
94 std::string tile[METATILE][METATILE];
96 static const int header_size = sizeof(struct meta_layout) + (sizeof(struct entry) * (METATILE * METATILE));
97};
98#endif
99
100#endif /* METATILE_H */
void expire_tiles(int sock, const char *host, const char *uri)
Send HTCP cache purge requests for every individual tile covered by this metatile.
Definition metatile.cpp:188
void clear()
Reset all sub-tile image payloads in the METATILE x METATILE grid to empty strings.
Definition metatile.cpp:50
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).
Definition metatile.cpp:93
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.
Definition metatile.cpp:42
const std::string get(int x, int y)
Retrieve the encoded image data for a single sub-tile within the metatile grid.
Definition metatile.cpp:77
void save(struct storage_backend *store)
Serialize the metatile header, index table, and tile payloads, and write to storage.
Definition metatile.cpp:113
void set(int x, int y, const std::string &data)
Store encoded image data for a single sub-tile within the metatile grid.
Definition metatile.cpp:65
#define METATILE
Width and height in tiles of a single rendered metatile (METATILE x METATILE tiles).
Definition render_config.h:140
Index table record locating a single sub-tile payload within a .meta archive.
Definition metatile.h:39
int size
Byte length of the encoded sub-tile payload (0 if empty).
Definition metatile.h:43
int offset
Byte offset of the sub-tile payload measured from the start of the .meta archive.
Definition metatile.h:41
Binary on-disk and wire header layout for a serialized METATILE x METATILE archive.
Definition metatile.h:52
int y
Definition metatile.h:58
int z
Definition metatile.h:58
struct entry index[]
Flexible array of count sub-tile offset/size descriptors.
Definition metatile.h:60
char magic[4]
4-byte magic identifier (META_MAGIC or META_MAGIC_COMPRESSED).
Definition metatile.h:54
int x
Lowest (top-left) tile X and Y coordinates of this metatile, plus zoom level Z.
Definition metatile.h:58
int count
Total number of sub-tile slots in index[] (always METATILE * METATILE).
Definition metatile.h:56
Virtual dispatch table and context handle for a pluggable tile/metatile storage backend.
Definition store.h:48