#!/usr/bin/perl -w
-# WARNING: Doing this for zoom level 0 requires 90 GB of space in $TEMP!
-# That's why layers 0-2 are not generated by default (you need to change
+# This is a helper script for generating pimped up OSM tiles.
+# The standard openstreetmap-carto-style as used on openstreetmap.org
+# looks extremely dull in Zoomlevels 0-8. They look a lot nicer if
+# "landuse" (forests, deserts) is shown. One way to do this is to
+# generate two modifications of the osm-carto style, render tiles
+# in each style, and then merge them:
+# - For the background, essentially empty all .mss files except
+# style.mss and landcover.mss - you need to throw out everything but
+# the landuse. For the landuse, make sure to adapt the rules so that
+# it is shown on zoomlevel 8. Render only zoomlevel 8.
+# - For the foreground, change style.mss: background-color within
+# Map { } needs to be "transparent" (without the quotes). #world in
+# shapefiles.mss needs to be removed. Render zoomlevels 0-8.
+# Then use this script to merge back+foreground. Voila, nicer looking
+# tiles!
+
+# WARNING: Doing this for zoom level 0 in HD requires 90 GB of
+# space in $TMPDIR!
+# That's why levels 0+1 are not generated by default (you need to change
# a line below)
-# URL is: /zoom/X/Y.png
-$srcpath = '/mnt/tiles/lowzoomtilegen/';
-$dstpath='/mnt/tiles/statictiles/mergedtiles/';
+# URL generally is: /zoom/X/Y.png within the dirs below.
-use Graphics::Magick;
+# The source for the foreground that you want to put over the
+# background. The foreground needs to exist for all zoomlevels you
+# want to generate.
+$srcfgpath = '/mnt/tiles/statictiles/lowzoom-fg/';
+# The source for the background. Only one zoomlevel needs to exist,
+# see ZOOMMAX below.
+$srcbgpath = '/mnt/tiles/statictiles/lowzoom-bg/';
+# Where the combined tiles (background+foreground) are written to.
+$dstpath='/mnt/tiles/statictiles/mergedtileshd/';
+
+# The name is a bit misleading: ZOOMMAX actually sets the zoomlevel
+# from which the backgrounds are taken (and then scaled as needed).
+# You obviously cannot merge tiles with a zoomlevel greater than
+# that.
+$ZOOMMAX = 8;
-# No need to change this usually
-$ZOOMMAX = 9;
-$TILESIZE = 256;
+# Tilesize. Usually 256 for normal tiles or 512 for HD.
+$TILESIZE = 512;
+
+use Graphics::Magick;
# Par. 0: Z
# Par. 1: X
my $YS = $_[2];
my $N = 1;
my $dstfilename = sprintf("%s/%d/%d/%d.png", $dstpath, $ZS, $XS, $YS);
- my $olfilename = sprintf("%s/%d/%d/%d.png", $srcpath, $ZS, $XS, $YS);
- if ($ZS >= $ZOOMMAX) {
+ my $olfilename = sprintf("%s/%d/%d/%d.png", $srcfgpath, $ZS, $XS, $YS);
+ if ($ZS > $ZOOMMAX) {
print("Sorry - can only merge Z <= $ZOOMMAX\n"); exit(1);
}
my $z = $ZS;
my $x; my $y;
for ($x = 0; $x < $N; $x++) {
for ($y = 0; $y < $N; $y++) {
- my $fn = sprintf("%s/%d/%d/%d.png", $srcpath, $ZOOMMAX, $XS + $x, $YS + $y);
+ my $fn = sprintf("%s/%d/%d/%d.png", $srcbgpath, $ZOOMMAX, $XS + $x, $YS + $y);
#print("Loading: $fn\n");
my $tmpimg = Graphics::Magick->new();
$status = $tmpimg->Read($fn);
#mergetile(7, 67, 43);
#mergetile(8, 135, 87);
my $rz; my $rx; my $ry;
-for ($rz = 3; $rz <= 8; $rz++) {
+for ($rz = 2; $rz <= 8; $rz++) {
my $ntilesperdir = 2 ** $rz; # Allgemein: 2 ^ Zoomlevel
for ($rx = 0; $rx < $ntilesperdir; $rx++) {
my $targdir = sprintf("%s/%d/%d", $dstpath, $rz, $rx);
}
$ntilesperdir = $ntilesperdir * 2;
}
+