1

I have multiple tables of data in my PostgreSQL database that have wkb_geometry columns used to generate layers. I would like to allow users to select which layers on a map they will see by accessing UI components such as checkboxes. When doing so, based on the selected UI components, it should send a request to my tile server and update the Mapnik XML file accordingly before rendering the tiles. How can I do this without having to restart renderd each time and how can I make sure that concurrent accesses won't overwrite changes to my XML file?

I do not want to cache these tiles as the same URL could have different parameters (layers turned on) so how would I avoid caching these requests?

1

I ended up editing the source code for mod_tile to force the map to refresh its XML source each time a tile is rendered. I did so by editing the gen_tile.cpp file and rebuilding mod_tile.

I added this code to the function "void *render_thread(void * arg)"

I placed it inside of the following if statement

...
if (check_xyz(item->mx, item->my, req->z, &(maps[i]))) {

    ######## START OF MY CODE #######
    try {
        maps[i].map = Map(256,256,maps[i].map.srs());
        mapnik::load_map(maps[i].map, maps[i].xmlfile);
    }
    catch (std::exception const& ex) {
        syslog(LOG_ERR, "An error occurred");
        maps[iMaxConfigs].ok = 0;
        break;
    } catch (...) {
        syslog(LOG_ERR, "An unknown error occurred ");
        maps[iMaxConfigs].ok = 0;
        break;
    }
    ######## END OF MY CODE ########

    metaTile tiles(req->xmlname, req->options, item->mx, item->my, req->z);
...

I did not solve the issue of caching the requests and have created a script that removes the cache directory if the request coming in is for different layers than the previous request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.