From b76f41fefa2a0d9a46533f3ad78b3668dc2fb137 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 2 Mar 2019 01:41:16 +0000 Subject: [PATCH] generate-board: support L2 --- generate-board | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/generate-board b/generate-board index f71845c..563202a 100755 --- a/generate-board +++ b/generate-board @@ -35,15 +35,15 @@ sub prep_region_rmap () { die if $prs2region{$prs}; $prs2region{$prs} = $rn; } - - # bodgery for the sea and land - $prs2region{'NZ | L'} = 'NZ'; - $prs2region{'L | NZ'} = 'NZ'; } our $sre = qr{(?:(\")|(?=\w))(.*)\1$}; # 2 captures, $2 is the name -sub prs2r ($) { $prs2region{$_[0]} // confess "@_ ?" } +sub prs2r ($) { + # bodgery for the sea and land + return 'NZ' if m/ \| / && !grep { !m{^(?:NZ|L2?)$} } split / \| /, $_[0]; + $prs2region{$_[0]} // confess "@_ ?" +} sub prs2rr ($) { $region{prs2r($_[0])} } #----- file reader for plag output ----- @@ -68,7 +68,7 @@ sub read_faces () { my $last_ai; if ($rr->{Name} eq 'NZ') { # We combined L and NZ; now we must split them again - # in fact, we just throw away L entirely. + # in fact, we just throw away L and L2 entirely. # Here, when processing NZ, we keep only vertices that # are part of NZ. @edges = grep { @@ -125,7 +125,7 @@ sub read_faces () { } $process_rr->(); - $region{$_}{Special} = 1 foreach qw(NZ L); + $region{$_}{Special} = 1 foreach qw(NZ L L2); } #----- geometry mangling ----- @@ -309,7 +309,7 @@ sub facepscolour ($) { sub fill_faces() { o("clippath ", facepscolour('land'), " fill\n"); foreach my $rr (values %region) { - next if $rr->{Name} eq 'L'; + next if $rr->{Name} =~ m/^L2?$/; face_path($rr); o(" ", facepscolour($rr->{Colour}), " eofill\n"); } @@ -318,7 +318,7 @@ sub fill_faces() { sub some_edge_faces (@) { o("5 setlinewidth 1 setlinejoin 0 setgray\n"); foreach my $rr (@_) { - next if $rr->{Name} eq 'L'; + next if $rr->{Name} =~ m/^L2?$/; face_path($rr); o(" stroke\n"); } @@ -347,8 +347,7 @@ sub edge_faces() { some_edge_faces($region{'NZ'}); afsluitdijk(); some_edge_faces(grep { - my $n = $_->{Name}; - !($n eq 'L' || $n eq 'NZ' || $n eq 'ZZ') + $_->{Name} !~ m{^(?:L2?|NZ|ZZ)$} } values %region); } -- 2.30.2