/[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 7 by dpavlin, Mon Oct 15 22:34:20 2007 UTC
# Line 12  use Imager; Line 12  use Imager;
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;
# Line 95  my $y_size = $y_tiles * $tile_size->{y}; Line 98  my $y_size = $y_tiles * $tile_size->{y};
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    
# Line 113  foreach my $tile_file ( @files ) { Line 121  foreach my $tile_file ( @files ) {
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();

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

  ViewVC Help
Powered by ViewVC 1.1.26