12 |
|
|
13 |
my $path = shift @ARGV || die "usage: $0 path_to_dump_dir\n"; |
my $path = shift @ARGV || die "usage: $0 path_to_dump_dir\n"; |
14 |
|
|
15 |
|
# Mireo 1, Google 0 |
16 |
|
my $flip_vertical = 0; |
17 |
|
|
18 |
my ( $range, $usage ); |
my ( $range, $usage ); |
19 |
|
|
20 |
my @files; |
my @files; |
98 |
|
|
99 |
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"; |
100 |
|
|
101 |
my $map = Imager->new( xsize => $x_size, ysize => $y_size ); |
my $map = Imager->new( xsize => $x_size, ysize => $y_size ) or $img->errstr(); |
102 |
|
|
103 |
foreach my $tile_file ( @files ) { |
foreach my $tile_file ( @files ) { |
104 |
$img->read( file => "$path/$tile_file" ) or die $img->errstr(); |
$img->read( file => "$path/$tile_file" ) or die $img->errstr(); |
105 |
|
|
106 |
# this is specific to globe position, I guess ... this is europe |
# this is specific to globe position, I guess ... this is europe |
107 |
my $x = ( $file_pos->{$tile_file}->{x} - $range->{min}->{x} ) / $step->{x}; |
my $x = ( $file_pos->{$tile_file}->{x} - $range->{min}->{x} ) / $step->{x}; |
108 |
my $y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; |
my $y; |
109 |
|
if ( $flip_vertical ) { |
110 |
|
$y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; |
111 |
|
} else { |
112 |
|
$y = ( $file_pos->{$tile_file}->{y} - $range->{min}->{y} ) / $step->{y}; |
113 |
|
} |
114 |
|
|
115 |
printf("%3dx%-3d %s\n", $x, $y, $tile_file); |
printf("%3dx%-3d %s\n", $x, $y, $tile_file); |
116 |
|
|
121 |
); |
); |
122 |
} |
} |
123 |
|
|
124 |
$map->write( file => 'dump.png' ) or die $img->errstr(); |
$path =~ s/\W+/_/g; |
125 |
|
$path =~ s/^_+//; |
126 |
|
$path =~ s/_+$//; |
127 |
|
|
128 |
|
$map->write( file => "$path.png" ) or die $img->errstr(); |