Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^7: help figuring out what a section of script does

by poj (Abbot)
on Mar 25, 2017 at 19:31 UTC ( [id://1185946]=note: print w/replies, xml ) Need Help??


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

    The script runs against TempMapTiles, which I assume is the output of the previous scripts right?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-24 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found