/[maps]/stich.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /stich.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Mon Oct 15 21:15:26 2007 UTC revision 10 by dpavlin, Tue Oct 16 09:27:16 2007 UTC
# Line 9  use strict; Line 9  use strict;
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    
# Line 95  my $y_size = $y_tiles * $tile_size->{y}; Line 103  my $y_size = $y_tiles * $tile_size->{y};
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    
# Line 113  foreach my $tile_file ( @files ) { Line 126  foreach my $tile_file ( @files ) {
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();

Legend:
Removed from v.2  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26