#!/usr/bin/perl $dir = './tile.openstreetmap.org/mapnik'; opendir(DIR, $dir); @zooms = grep { /^\d/ } readdir(DIR); closedir DIR; foreach $z (@zooms) { if ($z > 17) { next; } opendir(DIR, $dir . '/' . $z); @xs = grep { /^\d/ } readdir(DIR); closedir DIR; foreach $x (@xs) { opendir(DIR, $dir . '/' . $z . '/' . $x); @images = grep { /^\d/ } readdir(DIR); closedir DIR; foreach $i (@images) { $y = $i; $y =~ s/^(\d*).png/\1/; $l = -s "$dir/$z/$x/$i"; print "$z $x $y\n"; #print("./eatblob New.sqlitedb $dir/$z/$x/$i \"delete from images where zoom = $z and x = $x and y = $y; insert into images (zoom, x, y, flags, length, data) values ($z, $x, $y, 2, $l, ?);\""); system("./eatblob New.sqlitedb $dir/$z/$x/$i \"insert into images (zoom, x, y, flags, length, data) values (" . ($z-1) . ", $x, $y, 2, $l, ?);\""); } } }