in reply to Re^6: help figuring out what a section of script does
in thread help figuring out what a section of script does
Ok, try this
#!perl use strict; use DBI; my $database = 'TestMapTiles.sqlitedb'; my $tablename = 'image'; # open db my $dbh = open_db($database); my $imgfolder = 'maptiles-output'; if (! -d $imgfolder){ mkdir($imgfolder, 0755) or die "$!"; } # select data my $sql = 'SELECT * from '.$tablename; my $sth = $dbh->prepare($sql); $sth->execute(); # recreate files # 0..3 a int, b int, c int, d int, # 4..6 tileset int, retrieved int, current bool, # 7..9 etag text, size int, data blob, open LOG,'>',$tablename.'.dat'; while (my @f = $sth->fetchrow_array){ print LOG join "\t",@f[0..8],"\n"; my $pk = join '_',@f[0..3]; # a_b_c_d primary key my $filename = "$imgfolder/$pk.png"; # my $filename = "$imgfolder/$x,$y\@$zoom.png"; print "creating $filename\n"; open OUT,'>:raw',$filename or die "$filename : $!"; print OUT $f[9]; # data blob close OUT; } close LOG; # open db sub open_db { my $dbfile = shift; my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", # dbname = $dbfile was my mistake "", "", { RaiseError => 1 } ) or die $DBI::errstr; return $dbh; }
I can't map your filename variables $x,$y\@$zoom.png to the fieldnames so I have used the primary key fields a_b_c_d. All the data (except the blob) should be in the log file image.dat. Maybe you can determine which fields are the x,y map co-ordinates and zoom level.
poj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: help figuring out what a section of script does
by michaelsingleton (Novice) on Mar 26, 2017 at 12:42 UTC |