Skip to content

Commit

Permalink
Minor Clean Up of includes and gen_tile.cpp (#402)
Browse files Browse the repository at this point in the history
_Also_:
* Use `mapnik::freetype_engine::register_fonts` in `gen_tile.cpp` rather than recursing manually
  * Available since `Mapnik` v2 which is no longer supported
  • Loading branch information
hummeltech committed Mar 7, 2024
1 parent 5014494 commit dd90553
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 213 deletions.
5 changes: 2 additions & 3 deletions includes/cache_expire.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ extern "C" {
#define HTCP_EXPIRE_CACHE 1
#define HTCP_EXPIRE_CACHE_PORT "4827"


void cache_expire(int sock, char * host, char * uri, int x, int y, int z);
int init_cache_expire(char * htcphost);
void cache_expire(int sock, const char *host, const char *uri, int x, int y, int z);
int init_cache_expire(const char *htcphost);

#ifdef __cplusplus
}
Expand Down
14 changes: 10 additions & 4 deletions includes/gen_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
extern "C" {
#endif


enum queueEnum {queueRequest, queueRequestPrio, queueRequestBulk, queueDirty, queueRender, queueDuplicate, queueRequestLow};
enum queueEnum { queueRequest,
queueRequestPrio,
queueRequestBulk,
queueDirty,
queueRender,
queueDuplicate,
queueRequestLow
};

struct item {
struct item *next;
Expand All @@ -38,11 +44,11 @@ struct item {
enum queueEnum originatedQueue;
};

//int render(Map &m, int x, int y, int z, const char *filename);
// int render(Map &m, int x, int y, int z, const char *filename);
void *render_thread(void *);
struct item *fetch_request(void);
void delete_request(struct item *item);
void render_init(const char *plugins_dir, const char* font_dir, int font_recurse);
void render_init(const char *plugins_dir, const char *font_dir, int font_recurse);

#ifdef __cplusplus
}
Expand Down
15 changes: 7 additions & 8 deletions includes/metatile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#ifndef METATILE_H
#define METATILE_H

#include "config.h"
#include <stdlib.h>

#include "config.h"
#include "render_config.h"

#ifdef __cplusplus
Expand All @@ -37,14 +38,13 @@ struct entry {

struct meta_layout {
char magic[4];
int count; // METATILE ^ 2
int x, y, z; // lowest x,y of this metatile, plus z
int count; // METATILE ^ 2
int x, y, z; // lowest x,y of this metatile, plus z
struct entry index[]; // count entries
// Followed by the tile data
// The index offsets are measured from the start of the file
};


#ifdef __cplusplus
}

Expand All @@ -56,17 +56,16 @@ class metaTile
void set(int x, int y, const std::string &data);
const std::string get(int x, int y);
int xyz_to_meta_offset(int x, int y, int z);
void save(struct storage_backend * store);
void expire_tiles(int sock, char * host, char * uri);
void save(struct storage_backend *store);
void expire_tiles(int sock, const char *host, const char *uri);

private:
int x_, y_, z_;
std::string xmlconfig_;
std::string options_;
std::string tile[METATILE][METATILE];
static const int header_size = sizeof(struct meta_layout) + (sizeof(struct entry) * (METATILE * METATILE));

};

#endif
#endif

22 changes: 12 additions & 10 deletions includes/mod_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#define VERYOLD_RENDER 5
#define VERYOLD 6


/* Number of microseconds to camp out on the mutex */
#define CAMPOUT 10
/* Maximum number of times we camp out before giving up */
Expand Down Expand Up @@ -93,14 +92,14 @@ typedef struct stats_data {
} stats_data;

typedef struct {
const char * store;
const char *store;
char xmlname[XMLCONFIG_MAX];
char baseuri[PATH_MAX];
char fileExtension[PATH_MAX];
char mimeType[PATH_MAX];
const char * description;
const char * attribution;
const char * cors;
const char *description;
const char *attribution;
const char *cors;
char **hostnames;
int noHostnames;
int minzoom;
Expand Down Expand Up @@ -129,7 +128,7 @@ typedef struct {
int renderd_socket_port;
char tile_dir[PATH_MAX];
char cache_extended_hostname[PATH_MAX];
int cache_extended_duration;
int cache_extended_duration;
int mincachetime[MAX_ZOOM_SERVER + 1];
int enableGlobalStats;
int enableTileThrottling;
Expand All @@ -144,12 +143,15 @@ typedef struct {
} tile_server_conf;

typedef struct tile_request_data {
struct protocol * cmd;
struct storage_backend * store;
struct protocol *cmd;
struct storage_backend *store;
int layerNumber;
} tile_request_data;

enum tileState { tileMissing, tileOld, tileVeryOld, tileCurrent };

enum tileState { tileMissing,
tileOld,
tileVeryOld,
tileCurrent
};

#endif
10 changes: 9 additions & 1 deletion includes/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ extern "C" {
#endif
#define XMLCONFIG_MAX 41

enum protoCmd { cmdIgnore, cmdRender, cmdDirty, cmdDone, cmdNotDone, cmdRenderPrio, cmdRenderBulk, cmdRenderLow };
enum protoCmd { cmdIgnore,
cmdRender,
cmdDirty,
cmdDone,
cmdNotDone,
cmdRenderPrio,
cmdRenderBulk,
cmdRenderLow
};

struct protocol {
int ver;
Expand Down
5 changes: 2 additions & 3 deletions includes/protocol_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ extern "C" {

#include "protocol.h"

int send_cmd(struct protocol * cmd, int fd);
int recv_cmd(struct protocol * cmd, int fd, int block);

int send_cmd(struct protocol *cmd, int fd);
int recv_cmd(struct protocol *cmd, int fd, int block);

#ifdef __cplusplus
}
Expand Down
18 changes: 9 additions & 9 deletions includes/render_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// TILE_PATH is where Openlayers with try to fetch the "z/x/y.png" tiles from
// this is now only used if DIRECTORY_HASH is undefined
//#define TILE_PATH "/var/www/html/osm_tiles2"
// #define TILE_PATH "/var/www/html/osm_tiles2"

// MAX_LOAD_OLD: if tile is out of date, don't re-render it if past this load threshold (users gets old tile)
// (This is the default value. Can be overwritten in Apache config with ModTileMaxLoadOld.)
Expand All @@ -44,8 +44,8 @@
// MAX_LOAD_ANY: give up serving any data if beyond this load (user gets 404 error)
#define MAX_LOAD_ANY 100

//VERYOLD_THRESHOLD: defines how old a tile needs to be (in microseconds) to get rendering priority rather than renderingLow priority
//1000000*3600*24*365 = 31536000000000
// VERYOLD_THRESHOLD: defines how old a tile needs to be (in microseconds) to get rendering priority rather than renderingLow priority
// 1000000*3600*24*365 = 31536000000000
#define VERYOLD_THRESHOLD 31536000000000

// Location of osm.xml file
Expand Down Expand Up @@ -90,11 +90,11 @@
#define FD_INVALID (-1)

#ifndef MIN
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif

#ifndef MAX
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif

#define MAX_CONNECTIONS (2048)
Expand All @@ -105,11 +105,11 @@
// Use this to enable meta-tiles which will render NxN tiles at once
// Note: This should be a power of 2 (2, 4, 8, 16 ...)
#define METATILE (8)
//#undef METATILE
// #undef METATILE

//Fallback to standard tiles if meta tile doesn't exist
//Legacy - not needed on new installs
//#undef METATILEFALLBACK
// Fallback to standard tiles if meta tile doesn't exist
// Legacy - not needed on new installs
// #undef METATILEFALLBACK

// Metatiles are much larger in size so we don't need big queues to handle large areas
#ifdef METATILE
Expand Down
1 change: 0 additions & 1 deletion includes/render_submit_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
extern "C" {
#endif


void enqueue(const char *xmlname, int x, int y, int z);
void spawn_workers(int num, const char *socketpath, int maxLoad);
void wait_for_empty_queue(void);
Expand Down
20 changes: 8 additions & 12 deletions includes/request_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,26 @@ struct item_idx {
struct request_queue {
int hashidxSize;
struct item reqHead, reqPrioHead, reqLowHead, reqBulkHead, dirtyHead, renderHead;
struct item_idx * item_hashidx;
struct item_idx *item_hashidx;
int reqNum, reqPrioNum, reqLowNum, reqBulkNum, dirtyNum;
pthread_mutex_t qLock;
pthread_cond_t qCond;
stats_struct stats;
};


struct request_queue *request_queue_init();
void request_queue_close(struct request_queue * queue);

struct item *request_queue_fetch_request(struct request_queue * queue);
enum protoCmd request_queue_add_request(struct request_queue * queue, struct item * request);
void request_queue_close(struct request_queue *queue);

void request_queue_remove_request(struct request_queue * queue, struct item * request, int render_time);
void request_queue_clear_requests_by_fd(struct request_queue * queue, int fd);
struct item *request_queue_fetch_request(struct request_queue *queue);
enum protoCmd request_queue_add_request(struct request_queue *queue, struct item *request);

int request_queue_no_requests_queued(struct request_queue * queue, enum protoCmd);
void request_queue_copy_stats(struct request_queue * queue, stats_struct * stats);
void request_queue_remove_request(struct request_queue *queue, struct item *request, int render_time);
void request_queue_clear_requests_by_fd(struct request_queue *queue, int fd);

int request_queue_no_requests_queued(struct request_queue *queue, enum protoCmd);
void request_queue_copy_stats(struct request_queue *queue, stats_struct *stats);

#ifdef __cplusplus
}
#endif
#endif


30 changes: 15 additions & 15 deletions includes/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ extern "C" {
#include <sys/types.h>

struct stat_info {
off_t size; /* total size, in bytes */
time_t atime; /* time of last access */
time_t mtime; /* time of last modification */
time_t ctime; /* time of last status change */
int expired; /* has the tile expired */
off_t size; /* total size, in bytes */
time_t atime; /* time of last access */
time_t mtime; /* time of last modification */
time_t ctime; /* time of last status change */
int expired; /* has the tile expired */
};

struct storage_backend {
int (*tile_read)(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, char *buf, size_t sz, int * compressed, char * err_msg);
struct stat_info(*tile_stat)(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z);
int (*metatile_write)(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz);
int (*metatile_delete)(struct storage_backend * store, const char *xmlconfig, int x, int y, int z);
int (*metatile_expire)(struct storage_backend * store, const char *xmlconfig, int x, int y, int z);
char * (*tile_storage_id)(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, char * string);
int (*close_storage)(struct storage_backend * store);

void * storage_ctx;
int (*tile_read)(struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *buf, size_t sz, int *compressed, char *err_msg);
struct stat_info(*tile_stat)(struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z);
int (*metatile_write)(struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz);
int (*metatile_delete)(struct storage_backend *store, const char *xmlconfig, int x, int y, int z);
int (*metatile_expire)(struct storage_backend *store, const char *xmlconfig, int x, int y, int z);
char *(*tile_storage_id)(struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *string);
int (*close_storage)(struct storage_backend *store);

void *storage_ctx;
};

struct storage_backend * init_storage_backend(const char * options);
struct storage_backend *init_storage_backend(const char *options);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion includes/store_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_file(const char * tile_dir);
struct storage_backend *init_storage_file(const char *tile_dir);
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);

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion includes/store_file_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ void xyz_to_path(char *path, size_t len, const char *tile_dir, const char *xmlco
}
#endif


#endif
2 changes: 1 addition & 1 deletion includes/store_memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_memcached(const char * connection_string);
struct storage_backend *init_storage_memcached(const char *connection_string);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion includes/store_null.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_null();
struct storage_backend *init_storage_null();

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion includes/store_rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_rados(const char * connection_string);
struct storage_backend *init_storage_rados(const char *connection_string);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion includes/store_ro_composite.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_ro_composite(const char * connection_string);
struct storage_backend *init_storage_ro_composite(const char *connection_string);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion includes/store_ro_http_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

#include "store.h"

struct storage_backend * init_storage_ro_http_proxy(const char * connection_string);
struct storage_backend *init_storage_ro_http_proxy(const char *connection_string);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit dd90553

Please sign in to comment.