source: trunk/npemap.org.uk/scripts/tile-processing/rename-tiles.pl @ 408

Last change on this file since 408 was 408, checked in by Nick Burch, 15 years ago

Two new helper scripts

  • Property svn:executable set to *
File size: 780 bytes
Line 
1#!/usr/bin/perl
2# Rename tiles, based on the position of the top left tile
3#
4# Like David's terrifying debian-only rename line
5#
6# Nick Burch - 04/12/2006
7
8use strict;
9my $tl_e = shift;
10my $tl_n = shift;
11
12unless($tl_n) {
13        print "Use:\n";
14        print "\trename-tiles.pl <top left easting> <top left northing-1>\n";
15        print "\n";
16        print "Give the bottom left easting and northing of the top left most\n";
17        print " tile, eg top right is 244,859 given 244,858\n";
18        exit 1;
19}
20
21foreach my $f (<tile-*-*.jpg>) {
22        my ($e,$n) = ($f =~ /^tile\-([0-9]+)\-([0-9]+).jpg$/);
23        unless(length($n)) { warn("Invalid '$f'\n"); next; }
24
25        my $easting = $tl_e + $e;
26        my $northing = $tl_n - $n;
27        my $nf = sprintf("tile-%03d-%03d.jpg",$easting,$northing);
28
29        print "$f\n$easting $northing\n";
30        rename($f,$nf);
31}
Note: See TracBrowser for help on using the repository browser.