Tag: maxzoom=28

Inreased Zoom Level to 28 in OSM

Do you want to increase the zoom level of the OSM server? Then my friends, you are at right blog.;)

For it I am assuming that you have already made your pc an OSM server. While doing so, you have encountered with the term mod_tile. Am I right?

So, the whole story will revolve around mod_tile. If you are excited to know more about mod_tile then you can browse to my previous blogs.

Coming back to the topic we have to change overall 4 files in the directory mod_tile.

Edit the file /go/to/your/mod_tile/directory/openstreetmap-tiles-update-expire

EXPIRY_MAXZOOM=18

to

EXPIRY_MAXZOOM=28

The second file you have to edit is renderd.conf.

In [default] section uncomment the line MAXZOOM=18 and the change the value  from 18 to 28.

Note:- The file renderd.conf is located in two places. First one in mod_tile directory and other one in /usr/local/etc. You have to make changes in mod_tile directory because after making all necessary changes and recompiling mod_tile again. This renderd.conf file in mod_tile directory will automatically cloned to /usr/loca/etc.

Now, the turn comes for the third file i.e. mod_tile/includes/render_config.h

Change the variable

#define MAX_ZOOM 18

to

#define MAX_ZOOM 28

The last file which you have to edit is mod_tile/src/store_file_utils.c

This file need a lot of changes. So better to backup of this file initially.

 unsigned char i, hash[5];
to
unsigned char i, hash[7];

for (i=0; i<5; i++) {
to
for (i=0; i<7; i++) {

snprintf(path, len, “%s/%s/%d/%u/%u/%u/%u/%u.png”, tile_dir, xmlconfig, z, hash[4], hash[3], hash[2], hash[1], hash[0]);
to
snprintf(path, len, “%s/%s/%d/%u/%u/%u/%u/%u/%u/%u.png”, tile_dir, xmlconfig, z, hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]);

int i, n, hash[5], x, y, z;
to
int i, n, hash[7], x, y, z;

n = sscanf(path+i, “/%40[^/]/%d/%d/%d/%d/%d/%d”, xmlconfig, pz, &hash[0], &hash[1], &hash[2], &hash[3], &hash[4]);
if (n != 7) {
to
n = sscanf(path+i, “/%40[^/]/%d/%d/%d/%d/%d/%d/%d/%d”, xmlconfig, pz, &hash[0], &hash[1], &hash[2], &hash[3], &hash[4], &hash[5], &hash[6]);
if (n != 9) {

for (i=0; i<5; i++) {
to
for (i=0; i<7; i++) {

if (n != 4) {
to
if (n != 6) {

unsigned char i, hash[5], offset, mask;
to
unsigned char i, hash[7], offset, mask;

for (i=0; i<5; i++) {
to
for (i=0; i<7; i++) {

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);
to
snprintf(path, len, “%s/%s/%d/%u/%u/%u/%u/%u/%u/%u.%s.meta”, tile_dir, xmlconfig, z, hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0], options);

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]);
to
snprintf(path, len, “%s/%s/%d/%u/%u/%u/%u/%u/%u/%u.meta”, tile_dir, xmlconfig, z, hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]);

You have noticed that the hash value hash[5] is converted to hash[7]. It is due to make the metatile path longer. Not understood yet? Let me give an example.

The metatile take 5 bytes= 40 bits to cover all tiles for maximum zoom level 20. In simple words /var/lib/mod_tile/a/b/c/d/e/.meta

20 bits for x axis and 20 bits for y axis.

For zoom level 20 it require 5 bytes. Correspondingly for zoom level 28 it require 7 bytes.

28 bits for x axis and 28 bits for y axis.

That is why hash[5] changed to hash[7].

Now recompile your mod_tile again through the below commands.

make

sudo make install

sudo make install-mod_tile

sudo ldconfig

Now change the maxzooom parameter to 28 in Leaflet or any other Javascript library. You are done with it.

If you are having any problem with it. Then please do comment.

Advertisements