mirror of
https://github.com/openstreetmap/mod_tile.git
synced 2025-08-12 02:41:14 +00:00
Extend the storage backends to support options
This commit is contained in:
@ -33,7 +33,7 @@ extern "C" {
|
||||
|
||||
class metaTile {
|
||||
public:
|
||||
metaTile(const std::string &xmlconfig, int x, int y, int z);
|
||||
metaTile(const std::string &xmlconfig, const std::string &options, int x, int y, int z);
|
||||
void clear();
|
||||
void set(int x, int y, const std::string &data);
|
||||
const std::string get(int x, int y);
|
||||
@ -43,6 +43,7 @@ class metaTile {
|
||||
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));
|
||||
|
||||
|
@ -22,12 +22,12 @@ extern "C" {
|
||||
};
|
||||
|
||||
struct storage_backend {
|
||||
int (*tile_read)(struct storage_backend * store, const char *xmlconfig, 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, int x, int y, int z);
|
||||
int (*metatile_write)(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, const char *buf, int sz);
|
||||
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, int x, int y, int z, char * string);
|
||||
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;
|
||||
|
@ -385,13 +385,13 @@ void *render_thread(void * arg)
|
||||
if (maps[i].ok) {
|
||||
if (check_xyz(item->mx, item->my, req->z, &(maps[i]))) {
|
||||
|
||||
metaTile tiles(req->xmlname, item->mx, item->my, req->z);
|
||||
metaTile tiles(req->xmlname, req->options, item->mx, item->my, req->z);
|
||||
|
||||
timeval tim;
|
||||
gettimeofday(&tim, NULL);
|
||||
long t1=tim.tv_sec*1000+(tim.tv_usec/1000);
|
||||
|
||||
struct stat_info sinfo = maps[i].store->tile_stat(maps[i].store, req->xmlname, item->mx, item->my, req->z);
|
||||
struct stat_info sinfo = maps[i].store->tile_stat(maps[i].store, req->xmlname, req->options, item->mx, item->my, req->z);
|
||||
|
||||
if(sinfo.size > 0)
|
||||
syslog(LOG_DEBUG, "DEBUG: START TILE %s %d %d-%d %d-%d, age %.2f days",
|
||||
|
@ -56,8 +56,8 @@
|
||||
|
||||
|
||||
#define NO_QUEUE_REQUESTS 9
|
||||
#define NO_TEST_REPEATS 100
|
||||
#define NO_THREADS 100
|
||||
#define NO_TEST_REPEATS 10
|
||||
#define NO_THREADS 10
|
||||
|
||||
extern struct projectionconfig * get_projection(const char * srs);
|
||||
extern mapnik::box2d<double> tile2prjbounds(struct projectionconfig * prj, int x, int y, int z);
|
||||
@ -199,30 +199,35 @@ TEST_CASE( "renderd/queueing", "request queueing") {
|
||||
request_queue_add_request(queue, item);
|
||||
struct item *item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( item == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
free(item2);
|
||||
|
||||
item = init_render_request(cmdRenderPrio);
|
||||
request_queue_add_request(queue, item);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( item == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
free(item2);
|
||||
|
||||
item = init_render_request(cmdRenderLow);
|
||||
request_queue_add_request(queue, item);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( item == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
free(item2);
|
||||
|
||||
item = init_render_request(cmdRenderBulk);
|
||||
request_queue_add_request(queue, item);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( item == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
free(item2);
|
||||
|
||||
item = init_render_request(cmdDirty);
|
||||
request_queue_add_request(queue, item);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( item == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
free(item2);
|
||||
|
||||
request_queue_close(queue);
|
||||
@ -252,12 +257,16 @@ TEST_CASE( "renderd/queueing", "request queueing") {
|
||||
INFO("itemD: " << itemD);
|
||||
INFO("itemB: " << itemB);
|
||||
REQUIRE( itemRP == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( itemR == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( itemL == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( itemD == item2 );
|
||||
request_queue_remove_request(queue,item2, 0);
|
||||
item2 = request_queue_fetch_request(queue);
|
||||
REQUIRE( itemB == item2 );
|
||||
|
||||
@ -518,20 +527,26 @@ TEST_CASE( "renderd/queueing", "request queueing") {
|
||||
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == 1);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == FD_INVALID);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
free(item);
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == 3);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
free(item);
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == FD_INVALID);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
free(item);
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == 5);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
free(item);
|
||||
item = request_queue_fetch_request(queue);
|
||||
REQUIRE (item->fd == 6);
|
||||
request_queue_remove_request(queue,item, 0);
|
||||
free(item);
|
||||
|
||||
request_queue_close(queue);
|
||||
@ -609,7 +624,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
sinfo = store->tile_stat(store, "default", 0, 0, 0);
|
||||
sinfo = store->tile_stat(store, "default", "", 0, 0, 0);
|
||||
REQUIRE( sinfo.size < 0 );
|
||||
store->close_storage(store);
|
||||
|
||||
@ -625,7 +640,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
size = store->tile_read(store, "default", 0, 0, 0, buf, 10000, &compressed, err_msg);
|
||||
size = store->tile_read(store, "default", "", 0, 0, 0, buf, 10000, &compressed, err_msg);
|
||||
REQUIRE( size < 0 );
|
||||
|
||||
store->close_storage(store);
|
||||
@ -640,7 +655,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024, 1024, 10);
|
||||
metaTile tiles("default", "", 1024, 1024, 10);
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
std::string tile_data = "DEADBEAF";
|
||||
@ -661,7 +676,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024 + METATILE, 1024, 10);
|
||||
metaTile tiles("default", "", 1024 + METATILE, 1024, 10);
|
||||
time(&before_write);
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
@ -674,7 +689,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
sinfo = store->tile_stat(store, "default", 1024 + METATILE + yy, 1024 + xx, 10);
|
||||
sinfo = store->tile_stat(store, "default", "", 1024 + METATILE + yy, 1024 + xx, 10);
|
||||
REQUIRE( sinfo.size > 0 );
|
||||
REQUIRE( sinfo.expired == 0 );
|
||||
REQUIRE( sinfo.atime > 0 );
|
||||
@ -703,7 +718,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024 + METATILE, 1024, 10);
|
||||
metaTile tiles("default", "", 1024 + METATILE, 1024, 10);
|
||||
time(&before_write);
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
@ -717,7 +732,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
tile_size = store->tile_read(store, "default", 1024 + METATILE + xx, 1024 + yy, 10, buf, 8195, &compressed, msg);
|
||||
tile_size = store->tile_read(store, "default", "", 1024 + METATILE + xx, 1024 + yy, 10, buf, 8195, &compressed, msg);
|
||||
REQUIRE ( tile_size == 12 );
|
||||
sprintf(buf_tmp, "DEADBEAF %i %i", xx, yy);
|
||||
REQUIRE ( memcmp(buf_tmp, buf, 11) == 0 );
|
||||
@ -747,7 +762,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024 + 2*METATILE, 1024, 10);
|
||||
metaTile tiles("default", "", 1024 + 2*METATILE, 1024, 10);
|
||||
time(&before_write);
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < (METATILE >> 1); xx++) {
|
||||
@ -761,7 +776,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
tile_size = store->tile_read(store, "default", 1024 + 2*METATILE + xx, 1024 + yy, 10, buf, 8195, &compressed, msg);
|
||||
tile_size = store->tile_read(store, "default", "", 1024 + 2*METATILE + xx, 1024 + yy, 10, buf, 8195, &compressed, msg);
|
||||
if (xx >= (METATILE >> 1)) {
|
||||
REQUIRE ( tile_size == 0 );
|
||||
} else {
|
||||
@ -792,7 +807,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024 + 3*METATILE, 1024, 10);
|
||||
metaTile tiles("default", "", 1024 + 3*METATILE, 1024, 10);
|
||||
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
@ -803,13 +818,13 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
}
|
||||
tiles.save(store);
|
||||
|
||||
sinfo = store->tile_stat(store, "default", 1024 + 3*METATILE, 1024, 10);
|
||||
sinfo = store->tile_stat(store, "default", "", 1024 + 3*METATILE, 1024, 10);
|
||||
|
||||
REQUIRE ( sinfo.size > 0 );
|
||||
|
||||
store->metatile_delete(store, "default", 1024 + 3*METATILE, 1024, 10);
|
||||
|
||||
sinfo = store->tile_stat(store, "default", 1024 + 3*METATILE, 1024, 10);
|
||||
sinfo = store->tile_stat(store, "default", "", 1024 + 3*METATILE, 1024, 10);
|
||||
|
||||
REQUIRE ( sinfo.size < 0 );
|
||||
|
||||
@ -833,7 +848,7 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
store = init_storage_backend(tile_dir);
|
||||
REQUIRE( store != NULL );
|
||||
|
||||
metaTile tiles("default", 1024 + 4*METATILE, 1024, 10);
|
||||
metaTile tiles("default", "", 1024 + 4*METATILE, 1024, 10);
|
||||
|
||||
for (int yy = 0; yy < METATILE; yy++) {
|
||||
for (int xx = 0; xx < METATILE; xx++) {
|
||||
@ -844,13 +859,13 @@ TEST_CASE( "storage-backend", "Tile storage backend" ) {
|
||||
}
|
||||
tiles.save(store);
|
||||
|
||||
sinfo = store->tile_stat(store, "default", 1024 + 4*METATILE, 1024, 10);
|
||||
sinfo = store->tile_stat(store, "default", "", 1024 + 4*METATILE, 1024, 10);
|
||||
|
||||
REQUIRE ( sinfo.size > 0 );
|
||||
|
||||
store->metatile_expire(store, "default", 1024 + 4*METATILE, 1024, 10);
|
||||
|
||||
sinfo = store->tile_stat(store, "default", 1024 + 4*METATILE, 1024, 10);
|
||||
sinfo = store->tile_stat(store, "default", "", 1024 + 4*METATILE, 1024, 10);
|
||||
|
||||
REQUIRE ( sinfo.size > 0 );
|
||||
REQUIRE ( sinfo.expired > 0 );
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include "request_queue.h"
|
||||
|
||||
|
||||
metaTile::metaTile(const std::string &xmlconfig, int x, int y, int z):
|
||||
x_(x), y_(y), z_(z), xmlconfig_(xmlconfig) {
|
||||
metaTile::metaTile(const std::string &xmlconfig, const std::string &options, int x, int y, int z):
|
||||
x_(x), y_(y), z_(z), xmlconfig_(xmlconfig), options_(options) {
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -107,9 +107,9 @@ void metaTile::save(struct storage_backend * store) {
|
||||
}
|
||||
}
|
||||
|
||||
if (store->metatile_write(store, xmlconfig_.c_str(),x_,y_,z_,metatilebuffer, offset) != offset) {
|
||||
if (store->metatile_write(store, xmlconfig_.c_str(), options_.c_str(), x_,y_,z_, metatilebuffer, offset) != offset) {
|
||||
tmp = (char *)malloc(sizeof(char) * PATH_MAX);
|
||||
syslog(LOG_WARNING, "Failed to write metatile to %s", store->tile_storage_id(store, xmlconfig_.c_str(),x_,y_,z_, tmp));
|
||||
syslog(LOG_WARNING, "Failed to write metatile to %s", store->tile_storage_id(store, xmlconfig_.c_str(), options_.c_str(), x_,y_,z_, tmp));
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ static enum tileState tile_state(request_rec *r, struct protocol *cmd)
|
||||
struct stat_info stat;
|
||||
struct tile_request_data * rdata = (struct tile_request_data *)ap_get_module_config(r->request_config, &tile_module);
|
||||
|
||||
stat = rdata->store->tile_stat(rdata->store, cmd->xmlname, cmd->x, cmd->y, cmd->z);
|
||||
stat = rdata->store->tile_stat(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z);
|
||||
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "tile_state: determined state of %s %i %i %i on store %pp: Tile size: %li, expired: %i created: %li",
|
||||
cmd->xmlname, cmd->x, cmd->y, cmd->z, rdata->store, stat.size, stat.expired, stat.mtime);
|
||||
@ -986,7 +986,7 @@ static int tile_handler_status(request_rec *r)
|
||||
state = tile_state(r, cmd);
|
||||
if (state == tileMissing)
|
||||
return error_message(r, "No tile could not be found at storage location: %s\n",
|
||||
rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->x, cmd->y, cmd->z, storage_id));
|
||||
rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z, storage_id));
|
||||
apr_ctime(mtime_str, r->finfo.mtime);
|
||||
apr_ctime(atime_str, r->finfo.atime);
|
||||
|
||||
@ -994,7 +994,7 @@ static int tile_handler_status(request_rec *r)
|
||||
"(Dates might not be accurate. Rendering time might be reset to an old date for tile expiry."
|
||||
" Access times might not be updated on all file systems)\n",
|
||||
(state == tileOld) ? "due to be rendered" : "clean", mtime_str, atime_str,
|
||||
rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->x, cmd->y, cmd->z, storage_id));
|
||||
rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z, storage_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1201,9 +1201,9 @@ static int tile_handler_serve(request_rec *r)
|
||||
|
||||
err_msg[0] = 0;
|
||||
|
||||
len = rdata->store->tile_read(rdata->store, cmd->xmlname, cmd->x, cmd->y, cmd->z, buf, tile_max, &compressed, err_msg);
|
||||
len = rdata->store->tile_read(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z, buf, tile_max, &compressed, err_msg);
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
|
||||
"Read tile of length %i from %s: %s", len, rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->x, cmd->y, cmd->z, id), err_msg);
|
||||
"Read tile of length %i from %s: %s", len, rdata->store->tile_storage_id(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z, id), err_msg);
|
||||
if (len > 0) {
|
||||
if (compressed) {
|
||||
const char* accept_encoding = apr_table_get(r->headers_in,"Accept-Encoding");
|
||||
|
@ -342,7 +342,7 @@ int main(int argc, char **argv)
|
||||
//check_load();
|
||||
|
||||
num_all++;
|
||||
s = store->tile_stat(store, mapname, x, y, z);
|
||||
s = store->tile_stat(store, mapname, "", x, y, z);
|
||||
|
||||
if (s.size > 0) // Tile exists
|
||||
{
|
||||
@ -350,20 +350,20 @@ int main(int argc, char **argv)
|
||||
if (deleteFrom != -1 && z >= deleteFrom)
|
||||
{
|
||||
if (verbose)
|
||||
printf("deleting: %s\n", store->tile_storage_id(store, mapname, x, y, z, name));
|
||||
printf("deleting: %s\n", store->tile_storage_id(store, mapname, "", x, y, z, name));
|
||||
store->metatile_delete(store, mapname, x, y, z);
|
||||
num_unlink++;
|
||||
}
|
||||
else if (touchFrom != -1 && z >= touchFrom)
|
||||
{
|
||||
if (verbose)
|
||||
printf("touch: %s\n", store->tile_storage_id(store, mapname, x, y, z, name));
|
||||
printf("touch: %s\n", store->tile_storage_id(store, mapname, "", x, y, z, name));
|
||||
store->metatile_expire(store, mapname, x, y, z);
|
||||
num_touch++;
|
||||
}
|
||||
else if (doRender)
|
||||
{
|
||||
printf("render: %s\n", store->tile_storage_id(store, mapname, x, y, z, name));
|
||||
printf("render: %s\n", store->tile_storage_id(store, mapname, "", x, y, z, name));
|
||||
enqueue(mapname, x, y, z);
|
||||
num_render++;
|
||||
}
|
||||
@ -385,7 +385,7 @@ int main(int argc, char **argv)
|
||||
else
|
||||
{
|
||||
if (verbose)
|
||||
printf("not on disk: %s\n", store->tile_storage_id(store, mapname, x, y, z, name));
|
||||
printf("not on disk: %s\n", store->tile_storage_id(store, mapname, "", x, y, z, name));
|
||||
num_ignore++;
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ int main(int argc, char **argv)
|
||||
printf("Rendering all tiles for zoom %d from (%d, %d) to (%d, %d)\n", z, minX, minY, current_maxX, current_maxY);
|
||||
for (x=minX; x <= current_maxX; x+=METATILE) {
|
||||
for (y=minY; y <= current_maxY; y+=METATILE) {
|
||||
if (!force) s = store->tile_stat(store, mapname, x, y, z);
|
||||
if (!force) s = store->tile_stat(store, mapname, "", x, y, z);
|
||||
if (force || (s.size < 0) || (s.expired)) {
|
||||
enqueue(mapname, x, y, z);
|
||||
num_render++;
|
||||
@ -275,7 +275,7 @@ int main(int argc, char **argv)
|
||||
|
||||
num_all++;
|
||||
|
||||
if (!force) s = store->tile_stat(store, mapname, x, y, z);
|
||||
if (!force) s = store->tile_stat(store, mapname, "", x, y, z);
|
||||
if (force || (s.size < 0) || (s.expired)) {
|
||||
// missing or old, render it
|
||||
//ret = process_loop(fd, mapname, x, y, z);
|
||||
@ -294,7 +294,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
if (verbose)
|
||||
printf("Tile %s is clean, ignoring\n", store->tile_storage_id(store, mapname, x, y, z, name));
|
||||
printf("Tile %s is clean, ignoring\n", store->tile_storage_id(store, mapname, "", x, y, z, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ static time_t getPlanetTime(const char * tile_dir, const char * xmlname)
|
||||
return st_stat.st_mtime;
|
||||
}
|
||||
|
||||
static int file_tile_read(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char *buf, size_t sz, int * compressed, char * log_msg) {
|
||||
static int file_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 * log_msg) {
|
||||
|
||||
char path[PATH_MAX];
|
||||
int meta_offset, fd;
|
||||
@ -52,7 +52,7 @@ static int file_tile_read(struct storage_backend * store, const char *xmlconfig,
|
||||
struct meta_layout *m = (struct meta_layout *)malloc(header_len);
|
||||
size_t file_offset, tile_size;
|
||||
|
||||
meta_offset = xyz_to_meta(path, sizeof(path), store->storage_ctx, xmlconfig, x, y, z);
|
||||
meta_offset = xyzo_to_meta(path, sizeof(path), store->storage_ctx, xmlconfig, options, x, y, z);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
@ -137,12 +137,12 @@ static int file_tile_read(struct storage_backend * store, const char *xmlconfig,
|
||||
return pos;
|
||||
}
|
||||
|
||||
static struct stat_info file_tile_stat(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) {
|
||||
static struct stat_info file_tile_stat(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z) {
|
||||
struct stat_info tile_stat;
|
||||
struct stat st_stat;
|
||||
char meta_path[PATH_MAX];
|
||||
|
||||
xyz_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, x, y, z);
|
||||
xyzo_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, options, x, y, z);
|
||||
|
||||
if (stat(meta_path, &st_stat)) {
|
||||
tile_stat.size = -1;
|
||||
@ -165,22 +165,22 @@ static struct stat_info file_tile_stat(struct storage_backend * store, const cha
|
||||
return tile_stat;
|
||||
}
|
||||
|
||||
static char * file_tile_storage_id(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char * string) {
|
||||
static char * file_tile_storage_id(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, char * string) {
|
||||
char meta_path[PATH_MAX];
|
||||
|
||||
xyz_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, x, y, z);
|
||||
xyzo_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, options, x, y, z);
|
||||
snprintf(string, PATH_MAX - 1, "file://%s", meta_path);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
static int file_metatile_write(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, const char *buf, int sz) {
|
||||
static int file_metatile_write(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz) {
|
||||
int fd;
|
||||
char meta_path[PATH_MAX];
|
||||
char * tmp;
|
||||
int res;
|
||||
|
||||
xyz_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, x, y, z);
|
||||
xyzo_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, options, x, y, z);
|
||||
log_message(STORE_LOGLVL_DEBUG, "Creating and writing a metatile to %s\n", meta_path);
|
||||
|
||||
tmp = malloc(sizeof(char) * strlen(meta_path) + 24);
|
||||
@ -217,6 +217,7 @@ static int file_metatile_write(struct storage_backend * store, const char *xmlco
|
||||
static int file_metatile_delete(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) {
|
||||
char meta_path[PATH_MAX];
|
||||
|
||||
//TODO: deal with options
|
||||
xyz_to_meta(meta_path, sizeof(meta_path), (char *)(store->storage_ctx), xmlconfig, x, y, z);
|
||||
log_message(STORE_LOGLVL_DEBUG, "Deleting metatile from %s\n", meta_path);
|
||||
return unlink(meta_path);
|
||||
@ -229,6 +230,7 @@ static int file_metatile_expire(struct storage_backend * store, const char *xmlc
|
||||
static struct tm touchCalendar;
|
||||
struct utimbuf touchTime;
|
||||
|
||||
//TODO: deal with options
|
||||
xyz_to_meta(name, sizeof(name), store->storage_ctx, xmlconfig, x, y, z);
|
||||
|
||||
if (stat(name, &s) == 0) {// 0 is success
|
||||
|
@ -149,6 +149,12 @@ int path_to_xyz(const char *tilepath, const char *path, char *xmlconfig, int *px
|
||||
#ifdef METATILE
|
||||
// Returns the path to the meta-tile and the offset within the meta-tile
|
||||
int xyz_to_meta(char *path, size_t len, const char *tile_dir, const char *xmlconfig, int x, int y, int z)
|
||||
{
|
||||
return xyzo_to_meta(path, len, tile_dir, xmlconfig, "", x, y, z);
|
||||
}
|
||||
|
||||
// Returns the path to the meta-tile and the offset within the meta-tile
|
||||
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)
|
||||
{
|
||||
unsigned char i, hash[5], offset, mask;
|
||||
|
||||
@ -165,9 +171,17 @@ int xyz_to_meta(char *path, size_t len, const char *tile_dir, const char *xmlcon
|
||||
y >>= 4;
|
||||
}
|
||||
#ifdef DIRECTORY_HASH
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.meta", tile_dir, xmlconfig, z, hash[4], hash[3], hash[2], hash[1], hash[0]);
|
||||
if (strlen(options)) {
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.%s.meta", tile_dir, xmlconfig, z, hash[4], hash[3], hash[2], hash[1], hash[0], options);
|
||||
} else {
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u/%u/%u/%u.meta", tile_dir, xmlconfig, z, hash[4], hash[3], hash[2], hash[1], hash[0]);
|
||||
}
|
||||
#else
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u.meta", tile_dir, xmlconfig, z, x, y);
|
||||
if (strlen(options)) {
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u.%s.meta", tile_dir, xmlconfig, z, x, y, options);
|
||||
} else {
|
||||
snprintf(path, len, "%s/%s/%d/%u/%u.meta", tile_dir, xmlconfig, z, x, y);
|
||||
}
|
||||
#endif
|
||||
return offset;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
static 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) {
|
||||
@ -15,6 +16,7 @@ static int tile_read(struct storage_backend * store,
|
||||
|
||||
static struct stat_info tile_stat(struct storage_backend * store,
|
||||
const char *xmlconfig,
|
||||
const char *options,
|
||||
int x, int y, int z) {
|
||||
struct stat_info tile_stat;
|
||||
tile_stat.size = -1;
|
||||
@ -26,7 +28,8 @@ static struct stat_info tile_stat(struct storage_backend * store,
|
||||
}
|
||||
|
||||
static int metatile_write(struct storage_backend * store,
|
||||
const char *xmlconfig,
|
||||
const char *xmlconfig,
|
||||
const char *options,
|
||||
int x, int y, int z,
|
||||
const char *buf, int sz) {
|
||||
// fake like we actually wrote the tile, but we didn't...
|
||||
@ -47,6 +50,7 @@ static int metatile_expire(struct storage_backend * store,
|
||||
|
||||
static char * tile_storage_id(struct storage_backend * store,
|
||||
const char *xmlconfig,
|
||||
const char *options,
|
||||
int x, int y, int z,
|
||||
char * string) {
|
||||
snprintf(string, PATH_MAX - 1, "null://");
|
||||
|
@ -75,7 +75,7 @@ static cairo_status_t read_png_stream_from_byte_array (void *in_closure, unsigne
|
||||
}
|
||||
|
||||
|
||||
static int ro_composite_tile_read(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char *buf, size_t sz, int * compressed, char * log_msg) {
|
||||
static int ro_composite_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 * log_msg) {
|
||||
struct ro_composite_ctx * ctx = (struct ro_composite_ctx *)(store->storage_ctx);
|
||||
cairo_surface_t *imageA;
|
||||
cairo_surface_t *imageB;
|
||||
@ -83,7 +83,7 @@ static int ro_composite_tile_read(struct storage_backend * store, const char *xm
|
||||
cairo_t *cr;
|
||||
png_stream_to_byte_array_closure_t closure;
|
||||
|
||||
if(ctx->store_primary->tile_read(ctx->store_primary, ctx->xmlconfig_primary, x, y, z, buf, sz, compressed, log_msg) < 0) {
|
||||
if(ctx->store_primary->tile_read(ctx->store_primary, ctx->xmlconfig_primary, options, x, y, z, buf, sz, compressed, log_msg) < 0) {
|
||||
snprintf(log_msg,1024, "ro_composite_tile_read: Failed to read tile data of primary backend\n");
|
||||
return -1;
|
||||
}
|
||||
@ -96,7 +96,7 @@ static int ro_composite_tile_read(struct storage_backend * store, const char *xm
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ctx->store_secondary->tile_read(ctx->store_secondary, ctx->xmlconfig_secondary, x, y, z, buf, sz, compressed, log_msg) < 0) {
|
||||
if(ctx->store_secondary->tile_read(ctx->store_secondary, ctx->xmlconfig_secondary, options, x, y, z, buf, sz, compressed, log_msg) < 0) {
|
||||
snprintf(log_msg,1024, "ro_composite_tile_read: Failed to read tile data of secondary backend\n");
|
||||
cairo_surface_destroy(imageA);
|
||||
return -1;
|
||||
@ -140,18 +140,18 @@ static int ro_composite_tile_read(struct storage_backend * store, const char *xm
|
||||
return closure.pos;
|
||||
}
|
||||
|
||||
static struct stat_info ro_composite_tile_stat(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) {
|
||||
static struct stat_info ro_composite_tile_stat(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z) {
|
||||
struct ro_composite_ctx * ctx = (struct ro_composite_ctx *)(store->storage_ctx);
|
||||
return ctx->store_primary->tile_stat(ctx->store_primary,ctx->xmlconfig_primary,x, y, z);
|
||||
return ctx->store_primary->tile_stat(ctx->store_primary,ctx->xmlconfig_primary, options, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
static char * ro_composite_tile_storage_id(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char * string) {
|
||||
static char * ro_composite_tile_storage_id(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, char * string) {
|
||||
|
||||
return "Something or another";
|
||||
return "Coposite tile";
|
||||
}
|
||||
|
||||
static int ro_composite_metatile_write(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, const char *buf, int sz) {
|
||||
static int ro_composite_metatile_write(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz) {
|
||||
log_message(STORE_LOGLVL_ERR, "ro_composite_metatile_write: This is a readonly storage backend. Write functionality isn't implemented");
|
||||
return -1;
|
||||
}
|
||||
|
@ -63,13 +63,14 @@ static char * ro_http_proxy_xyz_to_storagekey(struct storage_backend * store, in
|
||||
return key;
|
||||
}
|
||||
|
||||
static int ro_http_proxy_tile_retrieve(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) {
|
||||
static int ro_http_proxy_tile_retrieve(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z) {
|
||||
struct ro_http_proxy_ctx * ctx = (struct ro_http_proxy_ctx *)(store->storage_ctx);
|
||||
char * path;
|
||||
CURLcode res;
|
||||
struct MemoryStruct chunk;
|
||||
long httpCode;
|
||||
|
||||
//TODO: Deal with options
|
||||
if ((ctx->cache.x == x) && (ctx->cache.y == y) && (ctx->cache.z == z) && (strcmp(ctx->cache.xmlname, xmlconfig) == 0)) {
|
||||
log_message(STORE_LOGLVL_DEBUG, "ro_http_proxy_tile_fetch: Got a cached tile");
|
||||
return 1;
|
||||
@ -129,10 +130,10 @@ static int ro_http_proxy_tile_retrieve(struct storage_backend * store, const cha
|
||||
}
|
||||
}
|
||||
|
||||
static int ro_http_proxy_tile_read(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char *buf, size_t sz, int * compressed, char * log_msg) {
|
||||
static int ro_http_proxy_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 * log_msg) {
|
||||
struct ro_http_proxy_ctx * ctx = (struct ro_http_proxy_ctx *)(store->storage_ctx);
|
||||
|
||||
if (ro_http_proxy_tile_retrieve(store, xmlconfig, x, y, z) > 0) {
|
||||
if (ro_http_proxy_tile_retrieve(store, xmlconfig, options, x, y, z) > 0) {
|
||||
if (ctx->cache.st_stat.size > sz) {
|
||||
log_message(STORE_LOGLVL_ERR, "ro_http_proxy_tile_read: size was too big, overrun %i %i", sz, ctx->cache.st_stat.size);
|
||||
return -1;
|
||||
@ -145,11 +146,11 @@ static int ro_http_proxy_tile_read(struct storage_backend * store, const char *x
|
||||
}
|
||||
}
|
||||
|
||||
static struct stat_info ro_http_proxy_tile_stat(struct storage_backend * store, const char *xmlconfig, int x, int y, int z) {
|
||||
static struct stat_info ro_http_proxy_tile_stat(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z) {
|
||||
struct stat_info tile_stat;
|
||||
struct ro_http_proxy_ctx * ctx = (struct ro_http_proxy_ctx *)(store->storage_ctx);
|
||||
|
||||
if (ro_http_proxy_tile_retrieve(store, xmlconfig, x, y, z) > 0) {
|
||||
if (ro_http_proxy_tile_retrieve(store, xmlconfig, options, x, y, z) > 0) {
|
||||
return ctx->cache.st_stat;
|
||||
} else {
|
||||
tile_stat.size = -1;
|
||||
@ -162,12 +163,12 @@ static struct stat_info ro_http_proxy_tile_stat(struct storage_backend * store,
|
||||
}
|
||||
|
||||
|
||||
static char * ro_http_proxy_tile_storage_id(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, char * string) {
|
||||
static char * ro_http_proxy_tile_storage_id(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, char * string) {
|
||||
|
||||
return ro_http_proxy_xyz_to_storagekey(store, x, y, z, string);
|
||||
}
|
||||
|
||||
static int ro_http_proxy_metatile_write(struct storage_backend * store, const char *xmlconfig, int x, int y, int z, const char *buf, int sz) {
|
||||
static int ro_http_proxy_metatile_write(struct storage_backend * store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz) {
|
||||
log_message(STORE_LOGLVL_ERR, "ro_http_proxy_metatile_write: This is a readonly storage backend. Write functionality isn't implemented");
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user