|
mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
|
#include <errno.h>#include <glib.h>#include <limits.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <time.h>#include "g_logger.h"#include "render_config.h"#include "store_file_utils.h"Functions | |
| time_t | get_planet_time (const char *tile_dir, const char *xmlname) |
| Retrieve the planet database import timestamp used to determine tile expiry. | |
| int | mkdirp (const char *path) |
| Recursively create all parent directories required for a target file path. | |
| static int | check_xyz (int x, int y, int z) |
| Check whether tile coordinates (x, y, z) are out of valid bounds. | |
| int | path_to_xyz (const char *tilepath, const char *path, char *xmlconfig, int *px, int *py, int *pz) |
| Parse a metatile or tile filesystem path back into (xmlconfig, px, py, pz). | |
| int | xyzo_to_meta (char *path, size_t len, const char *tile_dir, const char *xmlconfig, const char *options, int x, int y, int z) |
| Compute the .meta file path and sub-tile index for (xmlconfig, options, x, y, z). | |
| int | xyz_to_meta (char *path, size_t len, const char *tile_dir, const char *xmlconfig, int x, int y, int z) |
| Compute the .meta file path and sub-tile index for unparameterized (xmlconfig, x, y, z). | |
|
static |
Check whether tile coordinates (x, y, z) are out of valid bounds.
Note: Unlike gen_tile.cpp's check_xyz(), this helper returns 1 (non-zero) when coordinates are invalid / out of bounds and 0 when valid, matching standard C error-code convention for path_to_xyz().
| x | Tile X coordinate. |
| y | Tile Y coordinate. |
| z | Tile zoom level. |
| time_t get_planet_time | ( | const char * | tile_dir, |
| const char * | xmlname ) |
Retrieve the planet database import timestamp used to determine tile expiry.
Checks for a PLANET_TIMESTAMP marker file in the following order:
| tile_dir | Base tile storage directory path. |
| xmlname | Logical map style name (may be NULL or empty to skip the map-specific check). |
| int mkdirp | ( | const char * | path | ) |
Recursively create all parent directories required for a target file path.
Strips the basename after the final '/' (so mkdirp("/a/b/foo.meta") behaves like mkdir -p /a/b) and creates any missing intermediate directories with mode 0777 (modified by the process umask). Tolerates EEXIST races from concurrent threads.
| path | Full filesystem path to a target file whose parent directories should exist. |
| int path_to_xyz | ( | const char * | tilepath, |
| const char * | path, | ||
| char * | xmlconfig, | ||
| int * | px, | ||
| int * | py, | ||
| int * | pz ) |
Parse a metatile or tile filesystem path back into (xmlconfig, px, py, pz).
Strips the base directory prefix (tilepath, or TILE_PATH when compiled without DIRECTORY_HASH and TILE_PATH is non-empty), then parses either:
| tilepath | Expected base tile directory prefix. |
| path | Full filesystem path to parse. |
| xmlconfig | Output buffer (at least 41 bytes) receiving the parsed map style name. |
| px | Output pointer receiving the parsed tile X coordinate. |
| py | Output pointer receiving the parsed tile Y coordinate. |
| pz | Output pointer receiving the parsed tile zoom level. |
| int xyz_to_meta | ( | char * | path, |
| size_t | len, | ||
| const char * | tile_dir, | ||
| const char * | xmlconfig, | ||
| int | x, | ||
| int | y, | ||
| int | z ) |
Compute the .meta file path and sub-tile index for unparameterized (xmlconfig, x, y, z).
Convenience wrapper around xyzo_to_meta() with an empty options string ("").
| path | Output buffer receiving the formatted .meta filesystem path. |
| len | Capacity of path in bytes. |
| tile_dir | Base tile storage directory path. |
| xmlconfig | Logical map style name. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| int xyzo_to_meta | ( | char * | path, |
| size_t | len, | ||
| const char * | tile_dir, | ||
| const char * | xmlconfig, | ||
| const char * | options, | ||
| int | x, | ||
| int | y, | ||
| int | z ) |
Compute the .meta file path and sub-tile index for (xmlconfig, options, x, y, z).
Aligns (x, y) down to the top-left (0, 0) corner of its METATILE x METATILE block (x &= ~mask, y &= ~mask) and computes the sub-tile's linear index within the metatile header table. Formats path using either:
| path | Output buffer receiving the formatted .meta filesystem path. |
| len | Capacity of path in bytes. |
| tile_dir | Base tile storage directory path. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string (omitted from filename if empty). |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |