source: trunk/npemap.org.uk/scripts/tile-processing/copyArea.pl @ 83

Last change on this file since 83 was 83, checked in by David Sheldon, 14 years ago

Some of the scripts used to sort out tiling the maps.

  • Property svn:executable set to *
File size: 947 bytes
Line 
1#!/usr/bin/perl
2#
3use List::Util qw[min max];
4use File::Copy;
5
6my $scale = 1;
7
8my $outdir = "scaled$scale";
9
10if (! -d $outdir) {
11    mkdir $outdir or die "Unable to create dir '$outdir'"
12}
13
14my @files = glob("*/tile-*.jpg");
15my %tiles ;
16
17my $minx, $miny, $maxx, $maxy;
18
19foreach my $f (@files) {
20  $f =~ m/-(\d+)-(\d+)\./;
21  my ($x, $y) = ($1 +0, $2 +0);
22  $tiles{$x} ||= {};
23  $tiles{$x}{$y} = $f;
24
25}
26
27
28$maxx = max(keys %tiles);
29$maxy = max(map { max(keys %{$tiles{$_}})} keys %tiles);
30
31# start at 0, if there are any tiles in a WxW square, render a scale model
32# of it
33
34foreach my $x (0..$maxx) {
35    foreach my $y (0..$maxy) {
36      my $filename = sprintf("%s/%03d-%03d.jpg", $outdir,$x,$y);
37      if (! -f $filename) {
38
39          if (defined($tiles{$x}{$y})) {
40            copy($tiles{$x}{$y}, $filename) or die "Copy ($tiles{$x}{$y}, $filename) failed: $!";
41          }
42          print "($x,$y)\n";
43      }
44    }
45}
46
47print "($maxx, $maxy)\n";
48
Note: See TracBrowser for help on using the repository browser.