mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
Loading...
Searching...
No Matches
mod_tile.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 MOD_TILE_H
19#define MOD_TILE_H
20
21#include "protocol.h"
22#include "store.h"
23#include <apr_tables.h>
24#include <netinet/in.h>
25
27#define DELAY_HASHTABLE_SIZE 100057
29#define DELAY_HASHTABLE_WHITELIST_SIZE 13
31#define AVAILABLE_TILE_BUCKET_SIZE 5000
33#define AVAILABLE_RENDER_BUCKET_SIZE 65
40#define RENDER_TOPUP_RATE 5000000l
47#define TILE_TOPUP_RATE 1000000l
48
50#define INILINE_MAX 256
51
53#define MAX_ZOOM_SERVER 30
54
56#define FRESH 1
58#define OLD 2
60#define FRESH_RENDER 3
62#define OLD_RENDER 4
64#define VERYOLD_RENDER 5
66#define VERYOLD 6
67
69#define CAMPOUT 10
71#define MAXCAMP 10
72
74#define DEFAULT_ATTRIBUTION "&copy;<a href='http://www.openstreetmap.org/'>OpenStreetMap</a> and <a href='http://wiki.openstreetmap.org/wiki/Contributors'>contributors</a>, <a href='http://opendatacommons.org/licenses/odbl/'>(ODbL)</a>"
75
91
103
119
123typedef struct stats_data {
125 apr_uint64_t noResp200;
127 apr_uint64_t noResp304;
129 apr_uint64_t noResp404;
131 apr_uint64_t noResp503;
133 apr_uint64_t noResp5XX;
135 apr_uint64_t noRespOther;
137 apr_uint64_t noFreshCache;
139 apr_uint64_t noFreshRender;
141 apr_uint64_t noOldCache;
143 apr_uint64_t noOldRender;
145 apr_uint64_t noVeryOldCache;
147 apr_uint64_t noVeryOldRender;
149 apr_uint64_t noRespZoom[MAX_ZOOM_SERVER + 1];
158
160 apr_uint64_t *noResp200Layer;
162 apr_uint64_t *noResp404Layer;
163
165
169typedef struct {
171 char **hostnames;
173 const char *attribution;
175 const char *baseuri;
177 const char *cors;
179 const char *description;
181 const char *fileExtension;
183 const char *mimeType;
185 const char *store;
187 const char *xmlname;
201
267
281
282#endif /* MOD_TILE_H */
tileState
Freshness and existence classification of a requested tile in the storage backend.
Definition mod_tile.h:79
@ tileCurrent
Tile exists in storage and is up-to-date.
Definition mod_tile.h:89
@ tileOld
Tile exists in storage but its modification time predates the planet import timestamp.
Definition mod_tile.h:85
@ tileVeryOld
Tile exists in storage and its age exceeds very_old_threshold.
Definition mod_tile.h:87
@ tileMissing
Tile does not exist in storage (stat_info.size < 0).
Definition mod_tile.h:83
@ tileUnknown
Initial state before storage metadata has been queried.
Definition mod_tile.h:81
#define DELAY_HASHTABLE_WHITELIST_SIZE
Maximum number of whitelisted IPv4 addresses exempt from delaypool throttling.
Definition mod_tile.h:29
#define DELAY_HASHTABLE_SIZE
Prime bucket count of the per-client IP delaypool hash table.
Definition mod_tile.h:27
#define MAX_ZOOM_SERVER
Upper bound on zoom levels tracked in server-side Apache statistics and cache-control arrays.
Definition mod_tile.h:53
Per-client IP token bucket entry in the shared-memory rate-limiting delaypool.
Definition mod_tile.h:95
int available_tiles
Remaining cached-tile request tokens available to this client.
Definition mod_tile.h:99
int available_render_req
Remaining on-demand render request tokens available to this client.
Definition mod_tile.h:101
struct in6_addr ip_addr
Client IPv6 address (or IPv4-mapped IPv6 address) occupying this hash slot.
Definition mod_tile.h:97
Shared-memory rate-limiting state tracking per-IP token buckets and whitelisted prefixes.
Definition mod_tile.h:107
apr_time_t last_render_fillup
Timestamp of the last global render token refill pass.
Definition mod_tile.h:115
in_addr_t whitelist[13]
Array of whitelisted IPv4 addresses exempt from delaypool rate limits.
Definition mod_tile.h:111
int locked
Atomic spinlock flag (0 unlocked, 1 locked) serializing shared-memory updates.
Definition mod_tile.h:117
apr_time_t last_tile_fillup
Timestamp of the last global tile token refill pass.
Definition mod_tile.h:113
delaypool_entry users[100057]
Fixed-size hash table of per-client IP token buckets.
Definition mod_tile.h:109
Version 3 wire protocol message packet (PROTO_VER == 3).
Definition protocol.h:89
Shared-memory HTTP response, cache hit/miss, and latency counters exposed via /mod_tile.
Definition mod_tile.h:123
apr_uint64_t * noResp404Layer
Per-layer array of HTTP 404 response counters indexed by layer index.
Definition mod_tile.h:162
apr_uint64_t noResp503
Total HTTP 503 (Service Unavailable) responses returned due to load or throttling.
Definition mod_tile.h:131
apr_uint64_t noResp304
Total HTTP 304 (Not Modified) conditional responses served.
Definition mod_tile.h:127
apr_uint64_t noOldCache
Expired tiles served stale from cache without re-rendering (OLD).
Definition mod_tile.h:141
apr_uint64_t * noResp200Layer
Per-layer array of HTTP 200 response counters indexed by layer index.
Definition mod_tile.h:160
apr_uint64_t noFreshRender
Missing tiles newly rendered on demand (FRESH_RENDER).
Definition mod_tile.h:139
apr_uint64_t noResp404
Total HTTP 404 (Not Found) responses returned.
Definition mod_tile.h:129
apr_uint64_t totalBufferRetrievalTime
Cumulative tile retrieval and render wait time in microseconds across all zooms.
Definition mod_tile.h:151
apr_uint64_t noVeryOldCache
Heavily expired tiles served stale from cache without re-rendering (VERYOLD).
Definition mod_tile.h:145
apr_uint64_t noVeryOldRender
Heavily expired tiles re-rendered on demand (VERYOLD_RENDER).
Definition mod_tile.h:147
apr_uint64_t noTotalBufferRetrieval
Total number of tile retrievals recorded in totalBufferRetrievalTime.
Definition mod_tile.h:153
apr_uint64_t noRespOther
Total HTTP responses with other status codes.
Definition mod_tile.h:135
apr_uint64_t noZoomBufferRetrieval[30+1]
Per-zoom count of tile retrievals recorded in zoomBufferRetrievalTime.
Definition mod_tile.h:157
apr_uint64_t zoomBufferRetrievalTime[30+1]
Per-zoom cumulative tile retrieval and render wait time in microseconds.
Definition mod_tile.h:155
apr_uint64_t noRespZoom[30+1]
Per-zoom count of served tile responses (0 through MAX_ZOOM_SERVER).
Definition mod_tile.h:149
apr_uint64_t noFreshCache
Tiles served directly from cache while fresh (FRESH).
Definition mod_tile.h:137
apr_uint64_t noResp200
Total HTTP 200 (OK) tile responses served.
Definition mod_tile.h:125
apr_uint64_t noResp5XX
Total HTTP 5xx server error responses returned.
Definition mod_tile.h:133
apr_uint64_t noOldRender
Expired tiles re-rendered on demand (OLD_RENDER).
Definition mod_tile.h:143
Virtual dispatch table and context handle for a pluggable tile/metatile storage backend.
Definition store.h:48
Per-map-layer configuration record populated from Apache directives or renderd.conf.
Definition mod_tile.h:169
int noHostnames
Number of hostnames stored in the hostnames array.
Definition mod_tile.h:199
const char * mimeType
HTTP Content-Type MIME type returned for tiles in this layer (e.g., "image/png").
Definition mod_tile.h:183
int aspect_x
Horizontal projection aspect ratio multiplier (default 1).
Definition mod_tile.h:189
int enableOptions
Non-zero if dynamic style parameterization options are enabled in tile URLs.
Definition mod_tile.h:193
const char * attribution
Attribution string advertised in TileJSON responses for this layer.
Definition mod_tile.h:173
const char * store
Storage backend URI or filesystem path configured for this layer.
Definition mod_tile.h:185
const char * xmlname
Target map style identifier (xmlname) sent in IPC requests to renderd.
Definition mod_tile.h:187
const char * cors
Cross-Origin Resource Sharing (Access-Control-Allow-Origin) header value.
Definition mod_tile.h:177
int maxzoom
Maximum zoom level permitted for this layer.
Definition mod_tile.h:195
const char * fileExtension
File extension of rendered tiles without leading dot (e.g., "png").
Definition mod_tile.h:181
int minzoom
Minimum zoom level permitted for this layer.
Definition mod_tile.h:197
int aspect_y
Vertical projection aspect ratio multiplier (default 1).
Definition mod_tile.h:191
char ** hostnames
Array of virtual host names (ServerName / ServerAlias) matched for this layer.
Definition mod_tile.h:171
const char * description
Human-readable description advertised in TileJSON responses for this layer.
Definition mod_tile.h:179
const char * baseuri
Base URL path prefix routed to this layer (e.g., "/osm/").
Definition mod_tile.h:175
Per-HTTP-request context stored in Apache's r->request_config across translate_name and handler phase...
Definition mod_tile.h:271
struct protocol * cmd
Parsed wire protocol request identifying the target (xmlname, x, y, z, options).
Definition mod_tile.h:273
struct storage_backend * store
Active storage backend instance serving the matched map layer.
Definition mod_tile.h:275
int layerNumber
Zero-based index of the matched tile_config_rec layer in tile_server_conf.configs.
Definition mod_tile.h:277
enum tileState tileState
Freshness state of the requested tile (tileMissing, tileOld, tileVeryOld, tileCurrent).
Definition mod_tile.h:279
Per-virtual-host Apache server configuration for mod_tile.
Definition mod_tile.h:205
int delaypool_tile_size
Maximum tile token bucket size per IP (ModTileThrottlingTiles).
Definition mod_tile.h:237
const char * cache_extended_hostname
Hostname for which extended Cache-Control max-age headers are emitted (ModTileCacheExtendedHost).
Definition mod_tile.h:211
double cache_duration_last_modified_factor
Multiplier applied to tile age since last modification when computing Cache-Control max-age.
Definition mod_tile.h:217
apr_time_t very_old_threshold
Age threshold in microseconds beyond which an expired tile is classified as tileVeryOld.
Definition mod_tile.h:209
int request_timeout
Timeout in seconds to wait for low/normal-priority tile rendering (ModTileRequestTimeout).
Definition mod_tile.h:259
int enable_tile_throttling_xforward
Non-zero (1 first, 2 last) to extract client IP from X-Forwarded-For headers.
Definition mod_tile.h:249
int max_load_missing
System 1-minute load average threshold above which missing tiles return HTTP 404.
Definition mod_tile.h:251
int renderd_socket_port
TCP port number used to connect to renderd when renderd_socket_name is a host (0 for UNIX socket).
Definition mod_tile.h:257
int cache_duration_medium_zoom
Cache-Control max-age in seconds applied to zoom levels up to cache_level_medium_zoom.
Definition mod_tile.h:225
const char * renderd_socket_name
UNIX domain socket path or TCP hostname used to connect to renderd.
Definition mod_tile.h:213
int max_load_old
System 1-minute load average threshold above which expired tiles are served stale.
Definition mod_tile.h:253
int enable_tile_throttling
Non-zero to enable per-client IP delaypool rate limiting (ModTileEnableTileThrottling).
Definition mod_tile.h:247
const char * tile_dir
Default root directory or storage backend URI for cached tiles.
Definition mod_tile.h:215
long delaypool_render_rate
Microseconds per render token refill (ModTileThrottlingRenders).
Definition mod_tile.h:263
int enable_dirty_url
Non-zero to enable /dirty URL suffix handling for manual tile invalidation.
Definition mod_tile.h:241
apr_array_header_t * configs
Array of tile_config_rec entries configured on this virtual host.
Definition mod_tile.h:207
int cache_level_low_zoom
Maximum zoom level treated as low-zoom for cache_duration_low_zoom.
Definition mod_tile.h:231
int enable_global_stats
Non-zero to aggregate statistics globally across all virtual hosts rather than per-vhost.
Definition mod_tile.h:243
int cache_extended_duration
Extended Cache-Control max-age in seconds served to cache_extended_hostname.
Definition mod_tile.h:229
int enable_status_url
Non-zero to enable /status URL suffix handling returning tile freshness metadata.
Definition mod_tile.h:245
int cache_duration_low_zoom
Cache-Control max-age in seconds applied to zoom levels up to cache_level_low_zoom.
Definition mod_tile.h:221
int request_timeout_priority
Timeout in seconds to wait for high-priority missing tile rendering (ModTileMissingRequestTimeout).
Definition mod_tile.h:261
int enable_bulk_mode
Non-zero to submit missing tile renders with cmdRenderBulk instead of cmdRenderPrio.
Definition mod_tile.h:239
int cache_level_medium_zoom
Maximum zoom level treated as medium-zoom for cache_duration_medium_zoom.
Definition mod_tile.h:233
int mincachetime[30+1]
Per-zoom minimum cache age overrides in seconds (0 through MAX_ZOOM_SERVER).
Definition mod_tile.h:255
int delaypool_render_size
Maximum render token bucket size per IP (ModTileThrottlingRenders).
Definition mod_tile.h:235
int cache_duration_minimum
Lower bound in seconds on computed HTTP Cache-Control max-age.
Definition mod_tile.h:227
long delaypool_tile_rate
Microseconds per tile token refill (ModTileThrottlingTiles).
Definition mod_tile.h:265
int cache_duration_dirty
Cache-Control max-age in seconds returned for dirty/expired tiles that could not be re-rendered.
Definition mod_tile.h:219
int cache_duration_max
Upper bound in seconds on computed HTTP Cache-Control max-age.
Definition mod_tile.h:223