chiark / gitweb /
generate-board: support L2
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Mar 2019 01:41:16 +0000 (01:41 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Mar 2019 01:41:16 +0000 (01:41 +0000)
generate-board

index f71845c53a74f8285ea56f71a9b583a6b97a4ebb..563202a71c3d9b970de205df3e3086ec2916742b 100755 (executable)
@@ -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);
 }