9 |
use File::Find; |
use File::Find; |
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
use Imager; |
use Imager; |
12 |
|
use Getopt::Long; |
13 |
|
|
14 |
|
# Mireo 1, Google 0 |
15 |
|
my $flip_vertical = 0; |
16 |
|
|
17 |
|
GetOptions( |
18 |
|
'flip-vertical' => \$flip_vertical, |
19 |
|
); |
20 |
|
|
21 |
my $path = shift @ARGV || die "usage: $0 path_to_dump_dir\n"; |
my $path = shift @ARGV || die "usage: $0 path_to_dump_dir\n"; |
22 |
|
|
103 |
|
|
104 |
print "final map size: $x_size x $y_size from $x_tiles x $y_tiles tiles\n"; |
print "final map size: $x_size x $y_size from $x_tiles x $y_tiles tiles\n"; |
105 |
|
|
106 |
my $map = Imager->new( xsize => $x_size, ysize => $y_size ); |
my $map = Imager->new( xsize => $x_size, ysize => $y_size ) or $img->errstr(); |
107 |
|
|
108 |
foreach my $tile_file ( @files ) { |
foreach my $tile_file ( @files ) { |
109 |
$img->read( file => "$path/$tile_file" ) or die $img->errstr(); |
$img->read( file => "$path/$tile_file" ) or die $img->errstr(); |
110 |
|
|
111 |
# this is specific to globe position, I guess ... this is europe |
# this is specific to globe position, I guess ... this is europe |
112 |
my $x = ( $file_pos->{$tile_file}->{x} - $range->{min}->{x} ) / $step->{x}; |
my $x = ( $file_pos->{$tile_file}->{x} - $range->{min}->{x} ) / $step->{x}; |
113 |
my $y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; |
my $y; |
114 |
|
if ( $flip_vertical ) { |
115 |
|
$y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; |
116 |
|
} else { |
117 |
|
$y = ( $file_pos->{$tile_file}->{y} - $range->{min}->{y} ) / $step->{y}; |
118 |
|
} |
119 |
|
|
120 |
printf("%3dx%-3d %s\n", $x, $y, $tile_file); |
printf("%3dx%-3d %s\n", $x, $y, $tile_file); |
121 |
|
|
126 |
); |
); |
127 |
} |
} |
128 |
|
|
129 |
$map->write( file => 'dump.png' ) or die $img->errstr(); |
$path =~ s/\W+/_/g; |
130 |
|
$path =~ s/^_+//; |
131 |
|
$path =~ s/_+$//; |
132 |
|
|
133 |
|
$map->write( file => "$path.png" ) or die $img->errstr(); |