Changeset 423


Ignore:
Timestamp:
Jan 3, 2007, 7:26:22 PM (12 years ago)
Author:
Nick Burch
Message:

Generate meta files at scale 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/tile-processing/makeSmaller.pl

    r411 r423  
    3838$maxy = max(map { max(keys %{$tiles{$_}})} keys %tiles);
    3939
     40# The meta info's to re-create
     41# (Only done for scale 1, and only record the eastings to update)
     42my %update_meta;
     43
    4044# start at 0, if there are any tiles in a WxW square, render a scale model
    4145# of it
     
    4448    foreach my $y (0..($maxy/$scale)) {
    4549        my $filename = sprintf("%s/%03d/%03d.jpg", $outdir, $x, $y);
     50                my $meta_filename = sprintf("meta1/%03d.txt", $x);
    4651        my $outdir = sprintf("%s/%03d/", $outdir, $x);
    4752               
     53                # Do we need to create the meta info?
     54                if( ($scale == 1) && (! -f $meta_filename) ) {
     55                        $update_meta{$x}++;
     56                }
    4857
    4958        if( (! -f $filename) && any_tiles($x, $y, \%tiles) ) {
     
    7584 }
    7685
     86                        # Do we need to update the meta info?
     87                        if($scale == 1) {
     88                                $update_meta{$x}++;
     89                        }
     90                       
     91                        # Resize the image to 125x125, and write it out
    7792            $out->Resize("${tilesize}x$tilesize");
    7893            $out->Set(quality=>85);
     
    8398   }
    8499}
     100
     101# Re-create the meta files
     102foreach my $easting (sort keys %update_meta) {
     103        my $meta_filename = sprintf("meta1/%03d.txt", $easting);
     104        open(META, ">$meta_filename");
     105        print META "# easting,northing,sheet,year\n";
     106       
     107        foreach my $northing (sort keys %{$tiles{$easting}}) {
     108                my $file = $tiles{$easting}{$northing};
     109                my ($sheet) = ($file =~ /^(\d+\w?)\-/);
     110                my ($year) = ($file =~ /^\d+\w?\-tiles\-(\d+)/);
     111                print META "${easting},${northing},$sheet,$year\n";
     112        }
     113
     114        print "Recreated $meta_filename\n";
     115        close META;
     116}
     117
    85118
    86119use Data::Dumper;
Note: See TracChangeset for help on using the changeset viewer.