source: subversion/applications/utils/tirex/backend-mapnik/metatilehandler.h @ 29342

Last change on this file since 29342 was 28463, checked in by frederik, 7 years ago

support for mapnik2 (might break 0.7 compat, possible todo)
support for larger tiles and scale factor (config options
scalefactor, metarowscols, tilesize)

File size: 1.8 KB
Line 
1/*
2 * Tirex Tile Rendering System
3 *
4 * Mapnik rendering backend
5 *
6 * Originally written by Jochen Topf & Frederik Ramm.
7 *
8 */
9
10/**
11 * MetatileHandler
12 *
13 * This class is responsible for analysing a "metatile" request received from
14 * the network, calling the proper rendering functions to fulfil the request,
15 * preparing the render result, and returning an answer to the client.
16 */
17
18#ifndef metatilehandler_included
19#define metatilehandler_included
20
21#include <string>
22#include <mapnik/map.hpp>
23
24#include "requesthandler.h"
25#include "networkrequest.h"
26#include "networkresponse.h"
27#include "renderrequest.h"
28#include "renderresponse.h"
29
30#define MAXZOOM 25
31
32struct entry {
33    int offset;
34    int size;
35};
36
37struct meta_layout {
38    char magic[4];
39    int count; // METATILE ^ 2
40    int x, y, z; // lowest x,y of this metatile, plus z
41    struct entry index[]; // count entries
42};
43
44class MetatileHandler : public RequestHandler
45{
46    public:
47
48    MetatileHandler(const std::string& tiledir, const std::string& stylefile, unsigned int tilesize, double scalefactor, unsigned int mtrowcol);
49    ~MetatileHandler();
50    const NetworkResponse *handleRequest(const NetworkRequest *request);
51    void xyz_to_meta(char *path, size_t len, const char *tile_dir, int x, int y, int z) const;
52    bool mkdirp(const char *tile_dir, int x, int y, int z) const;
53    const std::string getRequestType() const { return "metatile_request"; }
54
55    private:
56
57    long long fourpow[MAXZOOM];
58    long long twopow[MAXZOOM];
59    const RenderResponse *render(const RenderRequest *rr);
60
61    unsigned int mTileWidth;
62    unsigned int mTileHeight;
63    unsigned int mMetaTileRows;
64    unsigned int mMetaTileColumns;
65    unsigned int mTileSize;
66    double mScaleFactor;
67    std::string mTileDir;
68    mapnik::Map mMap;
69};
70
71#endif
72
Note: See TracBrowser for help on using the repository browser.