source: trunk/npemap.org.uk/scripts/tile-processing/make-tiles-wld.pl @ 467

Last change on this file since 467 was 467, checked in by Nick Burch, 13 years ago

Add world making scripts

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2# Makes .wld files for NPE tiles
3#
4# Nick Burch - 27/10/2006
5
6use strict;
7
8my $dir = shift;
9if($dir && $dir =~ /^\d+-tiles/ && -d $dir) {
10        # Good
11} else {
12        print "Use:\n";
13        print "   make-stiles-wld.pl <tiles-dir>\n";
14        print "\nWhere the directory <tiles-dir>/ is a child of the current one\n";
15        exit;
16}
17
18# Files are in:
19#   <tiles-dir>/tile-<sc easting>-<sc northing>.jpg
20print "Processing $dir\n";
21my $scale = 1;
22
23# Loop over the files
24# Get northings
25my @files = `cd $dir/ && find . -maxdepth 1 -type f -name '*.jpg' | sed s#./##`;
26foreach my $f (@files) {
27        chomp $f;
28        my ($e,$n) = ($f =~ /^tile-(\d+)\-(\d+)\.jpg$/);
29        print "$e - $n - $f\n";
30
31        # Note - Add 1 to northing, as y offset is -ve
32
33        my ($easting, $northing) = ( (($e) * $scale), (($n+1) * $scale) );
34        $easting *= 1000;
35        $northing *= 1000;
36
37        # Write the world .jpw file
38        open(WLD, "> $dir/tile-${e}-${n}.jpw");
39
40        # Images are 125x125, and cover one grid square at scale 1
41
42        # size of pixel in x direction
43        print WLD (1000 * $scale / 125)."\n";
44
45        # rotation term for row - typically zero
46        # rotation term for column - typically zero
47        print WLD "0.000\n0.000\n";
48
49        # size of pixel in y direction
50        print WLD (-1000 * $scale / 125)."\n";
51
52        # x coordinate of centre of upper left pixel in map units
53        print WLD "$easting\n";
54
55        # y coordinate of centre of upper left pixel in map units
56        print WLD "$northing\n";
57
58        close WLD;
59}
60
Note: See TracBrowser for help on using the repository browser.