aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/convert.pl49
-rwxr-xr-xbin/convertL.pl62
-rwxr-xr-xbin/convertLB.pl51
3 files changed, 162 insertions, 0 deletions
diff --git a/bin/convert.pl b/bin/convert.pl
new file mode 100755
index 000000000..a5e3d7a6b
--- /dev/null
+++ b/bin/convert.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+
+# convert.pl:
+# Out of date tile conversion
+#
+# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: convert.pl,v 1.1 2006-09-19 15:08:36 matthew Exp $
+
+use strict;
+
+my @squares = (
+ '', '', '', '', 'HP', '', '',
+ '', '', '', 'HT', 'HU', '', '',
+ '', 'HW', 'HX', 'HY', 'HZ', '', '',
+ 'NA', 'NB', 'NC', 'ND', '', '', '',
+ 'NF', 'NG', 'NH', 'NJ', 'NK', '', '',
+ 'NL', 'NM', 'NN', 'NO', '', '', '',
+ '', 'NR', 'NS', 'NT', 'NU', '', '',
+ '', 'NW', 'NX', 'NY', 'NZ', 'OV', '',
+ '', '', 'SC', 'SD', 'SE', 'TA', '',
+ '', '', 'SH', 'SJ', 'SK', 'TF', 'TG',
+ '', 'SM', 'SN', 'SO', 'SP', 'TL', 'TM',
+ '', 'SR', 'SS', 'ST', 'SU', 'TQ', 'TR',
+ 'SV', 'SW', 'SX', 'SY', 'SZ', 'TV', '');
+
+my %squares;
+my $i = 0;
+foreach my $square (@squares) {
+ $squares{$square} = $i if $square;
+ $i++;
+}
+
+for (<*.png>) {
+ /^(..)-(\d+)\.png$/ or die $!;
+ my $square = $1;
+ $square = $squares{$square};
+ my $square_row = int($square/7);
+ my $square_col = $square%7;
+ my $part = $2;
+ my $part_row = int($part/16);
+ my $part_col = $part%16;
+
+ my $out_col = $square_col*16+$part_col;
+ my $out_row = $square_row*16+$part_row;
+ print "$_ $square_row $square_col $part_row $part_col : $out_col x $out_row\n";
+ system("cp $_ $out_col.$out_row.png");
+}
diff --git a/bin/convertL.pl b/bin/convertL.pl
new file mode 100755
index 000000000..429dc26d9
--- /dev/null
+++ b/bin/convertL.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl -w
+
+# convertL.pl:
+# Out of date tile conversion
+#
+# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+
+use strict;
+
+my @squares = (
+ '', '', '', '', 'HP', '', '',
+ '', '', '', 'HT', 'HU', '', '',
+ '', 'HW', 'HX', 'HY', 'HZ', '', '',
+ 'NA', 'NB', 'NC', 'ND', '', '', '',
+ 'NF', 'NG', 'NH', 'NJ', 'NK', '', '',
+ 'NL', 'NM', 'NN', 'NO', '', '', '',
+ '', 'NR', 'NS', 'NT', 'NU', '', '',
+ '', 'NW', 'NX', 'NY', 'NZ', 'OV', '',
+ '', '', 'SC', 'SD', 'SE', 'TA', '',
+ '', '', 'SH', 'SJ', 'SK', 'TF', 'TG',
+ '', 'SM', 'SN', 'SO', 'SP', 'TL', 'TM',
+ '', 'SR', 'SS', 'ST', 'SU', 'TQ', 'TR',
+ 'SV', 'SW', 'SX', 'SY', 'SZ', 'TV', '');
+
+my %squares;
+my $i = 0;
+foreach my $square (@squares) {
+ $squares{$square} = $i if $square;
+ $i++;
+}
+
+print "Converting TIF to PNGs...\n";
+for (</home/tom/25k/BaseMap/*.TIF>) {
+ /(S[Q-Z]\d+).TIF$/ or next;
+ my $name = $1;
+ unless (-e "$name-0.png") {
+ print " $_\n";
+ `convert $_ -crop 250x250 tl/$name.png`;
+ }
+}
+print "Renaming PNGs...\n";
+for (<tl/*.png>) {
+ /^tl\/(..)(\d+)-(\d+)\.png$/ or next;
+ print " $_\n";
+ my $square = $1;
+ $square = $squares{$square};
+ my $square_row = int($square/7);
+ my $square_col = $square%7;
+ my $parta = $2;
+ my $parta_col = int($parta/10);
+ my $parta_row = 9 - $parta%10;
+ my $partb = $3;
+ my $partb_row = int($partb/16);
+ my $partb_col = $partb%16;
+
+ my $out_col = ($square_col*10+$parta_col)*16+$partb_col;
+ my $out_row = ($square_row*10+$parta_row)*16+$partb_row;
+# print "$_ $out_col x $out_row\n";
+ system("mv $_ tl/$out_col.$out_row.png");
+}
+print "Done.\n";
diff --git a/bin/convertLB.pl b/bin/convertLB.pl
new file mode 100755
index 000000000..42a2401db
--- /dev/null
+++ b/bin/convertLB.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -w
+
+# convertLB.pl:
+# Out of date tile conversion
+#
+# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: convertLB.pl,v 1.1 2006-09-19 15:08:36 matthew Exp $
+
+use strict;
+
+my @squares = (
+ '', '', '', '', 'HP', '', '',
+ '', '', '', 'HT', 'HU', '', '',
+ '', 'HW', 'HX', 'HY', 'HZ', '', '',
+ 'NA', 'NB', 'NC', 'ND', '', '', '',
+ 'NF', 'NG', 'NH', 'NJ', 'NK', '', '',
+ 'NL', 'NM', 'NN', 'NO', '', '', '',
+ '', 'NR', 'NS', 'NT', 'NU', '', '',
+ '', 'NW', 'NX', 'NY', 'NZ', 'OV', '',
+ '', '', 'SC', 'SD', 'SE', 'TA', '',
+ '', '', 'SH', 'SJ', 'SK', 'TF', 'TG',
+ '', 'SM', 'SN', 'SO', 'SP', 'TL', 'TM',
+ '', 'SR', 'SS', 'ST', 'SU', 'TQ', 'TR',
+ 'SV', 'SW', 'SX', 'SY', 'SZ', 'TV', '');
+
+my %squares;
+my $i = 0;
+foreach my $square (@squares) {
+ $squares{$square} = $i if $square;
+ $i++;
+}
+
+for (<tl/*.png>) {
+ /^tl\/(\d+)\.(\d+)\.png$/ or die;
+ my $x = $1;
+ my $y = $2;
+ my $partb_col = $x%16;
+ my $partb_row = $y%16;
+ my $parta_col = int($x/16)%10;
+ my $parta_row = 9 - int($y/16)%10;
+ my $square_col = int(int($x/16)/10);
+ my $square_row = int(int($y/16)/10);
+
+ my $square = $squares[$square_row*7+$square_col];
+ my $parta = 10*$parta_col+$parta_row;
+ my $partb = $partb_col+$partb_row*16;
+# print "$_ : $square$parta-$partb.png\n";
+ system("mv $_ tl/$square$parta-$partb.png");
+}