[Question]
  [
[In the United States](http://mutcd.fhwa.dot.gov/services/publications/fhwaop02090/twtmarkings_longdesc.htm), the two opposing directions of traffic on a road are separated by a dashed yellow line if passing is allowed and two solid yellow lines if passing is not allowed.
![road line rules graphic](https://i.stack.imgur.com/uiAeE.png)
(Just one side can be dashed to allow passing on that side, and yellow lines can mean other things like center or reversible lanes, but we aren't concerned with any of those cases.)
Write a program that takes in a [run-length encoded](http://en.wikipedia.org/wiki/Run-length_encoding) string of `P` for *passing* and `N` for *no passing*, and prints an ASCII version of the corresponding road. Except for the center line, the road always has the same pattern, which can be easily inferred from the examples below.
There will be a positive decimal number before each `P` and `N` in the input string. This number defines the length of the *passing* or *no passing* region of the current part of the road.
### Examples
An input of `12N` would produce 12 columns of *no passing* road (center line all `=`):
```
____________
============
____________
```
An input of `12P` would produce 12 columns of *passing* road (center line `-`  repeating):
```
____________
- - - - - - 
____________
```
*Passing* and *no passing* can then be combined, e.g. `4N4P9N7P1N1P2N2P` would produce:
```
______________________________
====- - =========- - - -=-==- 
______________________________
```
These are 4 *no passing* columns, then 4 *passing*, then 9 *no passing*, etc.
**Note that a *passing* zone always starts with a dash (`-`) on the leftmost side, not a space (). This is required.**
### Details
* The input will never have two `N` zones or two `P` zones in a row. e.g. `4P5P` will never occur.
* You don't need to support letters without a leading positive number. Plain `P` will always be `1P`, plain `N` will always be `1N`.
* There may be trailing spaces as long as they do not extend beyond the final column of the road. There may be one optional trailing newline.
* Instead of a program, you may write a function that takes in the run-length encoded string and prints or returns the ASCII road.
* Takes input in any standard way (stdin, command line, function arg).
**The shortest code in bytes wins. Tiebreaker is earlier post.**
  
[Answer]
# JavaScript (ES6), 114
Using [template strings](https://developer.mozilla.org/it/docs/Web/JavaScript/Reference/template_strings), the 5 linefeeds are significant and thus must be counted.
```
f=s=>(b=(s=s.replace(/(\d+)(.)/g,(x,n,b)=>(b<'P'?'=':'- ').repeat(n).slice(0,n))).replace(/./g,'_'))+`
   
${s}
`+b
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 46 bytes
Created on the APL Farm with lots of input from chrispsn.
```
{++(,/(.x@y)#'"-="x_y#="PNP";"_")@3\466}`c$!58
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6rW1tbQ0dfQq3Co1FRWV9K1VaqIr1S2VQrwC1CyVopX0nQwjjExM6tNSFZRNLXg4kowsEpTUDI08lOCMwNgTBM/kwBLP/MAQz/DACM/oDgAQCoWRQ==)
---
# k9 2021.03.27, ~~53~~ 52 bytes
-1 byte thanks to chrispsn!
```
++"_  ",|"_ ",,,/{.[x]#*"-="y#="PNP"}/'-2^(~=':64>)^
```
[Try it online](https://kparc.io/k/#f%3A%2B%2B%22_%20%20%22%2C%7C%22_%20%22%2C%2C%2C%2F%7B.%5Bx%5D%23*%22-%3D%22y%23%3D%22PNP%22%7D%2F%27-2%5E(%7E%3D%27%3A64%3E)%5E%3B%20f%20%2212P4N4P9N7P1N1P2N2P%22) on kparc.io!
[Answer]
# CJam, 38 bytes
```
"_  - _":N3'=t:P;q~]2/e~z'
*"--"/"- "*
```
**How it works**
We first assign the correct road column to variables `N` and `P` and then simply evaluate the input string. This leaves a pair of the length and the column on stack. We group them up, run an RLD on it to get the full columns, transpose to join them and then finally, convert the continuous `--` to `-` .
```
:_  - _":N                    e# This is the no passing column. We assign it to N
          3'=t:P              e# Replace the '-' in N with '=" and assign it to P
                q~]2/         e# Read the input, evaluate it and then group it in pairs
                     e~       e# Run a run-length-decoder on the pairs
                       z'
*                             e# Transpose and join with new lines.
 "--"/                        e# Split on two continuous occurrence of -
      "- "*                   e# Join by an alternate "- "
```
[Try it online here](http://cjam.aditsu.net/#code=%22_%20%20-%20_%22%3AN3%27%3Dt%3AP%3Bq%7E%5D2%2Fe%7Ez%27%0A*%22--%22%2F%22-%20%22*&input=4N4P9N7P1N1P2N2P)
[Answer]
# [rs](https://github.com/kirbyfan64/rs), 252 chars
Although this might not count because I [added the convergence operator as a ripoff of Martin Büttner's Retina](https://github.com/kirbyfan64/rs/commit/29f5993f443a40982ca89fe5be48a920718f0072) an hour ago...I'm not really here to compete anyway. It's just fun making a regex-based solution for this.
```
(\d+\D)/#\1
+(\d*)#(?:(((((((((9)|8)|7)|6)|5)|4)|3)|2)|1)|0)(?=\d*\D)/\1\1\1\1\1\1\1\1\1\1\2\3\4\5\6\7\8\9\10#
\d(?=\d*#N)/=
(^|(?<=\D))\d(?=\d*#P)/-
+(?<=-)\d\d(?=\d*#P)/ -
(?<=-)\d(?=\d*#P)/ 
#\D/
((?:(=|-| ))+)/A\1\n\n\n\1\n\nA\1\n
+(A_*)(.)/\1_
A/
```
I got line 2 from [Martin's Retina answer for Programming Languages Through the Years](https://codegolf.stackexchange.com/a/48479/21009).
## Explanation
```
(\d+\D)/#\1
+(\d*)#(?:(((((((((9)|8)|7)|6)|5)|4)|3)|2)|1)|0)(?=\d*\D)/\1\1\1\1\1\1\1\1\1\1\2\3\4\5\6\7\8\9\10#
```
This does lots of magic. See the answer I linked above for more info.
Basically, with the input `4N4P9N7P1N1P2N2P`, this will be the result:
```
4444#N4444#P999999999#N7777777#P1#N1#P22#N22#P
```
Next:
```
\d(?=\d*#N)/=
```
This replaces the numbers preceding the no-passing symbol (N) with the equal signs. The result with the previous input:
```
====#N4444#P=========#N7777777#P=#N1#P==#N22#P
```
This:
```
(^|(?<=\D))\d(?=\d*#P)/-
```
replaces the first number preceding a passing symbol (P) with the first dash. The result:
```
====#N-444#P=========#N-777777#P=#N-#P==#N-2#P
```
The next two lines continue the same pattern:
```
+(?<=-)\d\d(?=\d*#P)/ -
(?<=-)\d(?=\d*#P)/ 
```
The first line replaces the rest of the line with the dash-space pattern. The second one handles an odd number; it replaces the last dash followed by a single integer (such as `-5`) with a dash-space (`-`). Now, the output is:
```
====#N- - #P=========#N- - - -#P=#N-#P==#N- #P
```
Now things are starting to fall into place. The next line:
```
#\D/
```
just removes the `#N` and `#P`.
```
((?:(=|-| ))+)/A\1\n\n\n\1\n\nA\1\n
+(A_*)(.)/\1_
```
set up the underscores on the top and bottom to give:
```
A______________________________
====- - =========- - - -=-==- 
A______________________________
```
Lastly, we remove the `A`:
```
A/
```
[Answer]
## Python 2, 136 bytes
Surprisingly, importing `re` seems to be actually worthwhile here.
```
import re
s=""
for x,y in re.findall("(\d+)(.)",input()):s+=(("- ","==")[y=="N"]*int(x))[:int(x)]
t="_"*len(s);print t+"\n"*3+s+"\n"*2+t
```
[Answer]
# k9 2021.03.27, 72 bytes
```
" -=_"{++(3;0;0;mod[x]+2*~x;0;3)}@{y*x+y}\&?`P=!/`i`n$+-2^{9<a|-a:-':x}^
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~71~~ ~~69~~ ~~68~~ ~~64~~ ~~69~~ ~~68~~ 65 bytes
```
{++"_  ",|"_ ",+" =-"@+/1(~<\2=)\-78+*'&.'!/|+0N 2#(&~=':58<x)_x}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6rW1laKV1BQ0qkBUko62koKtrpKDtr6hhp1NjFGtpoxuuYW2lrqanrqivo12gZ+CkbKGmp1tupWphY2FZrxFbVcXMVWSiZ+JgGGBn7mAYZ+hgFGfkYBSlxcCQZWaQ7FAEE4FqE=)
-2 superfluous parens
  
-1 shuffling
  
-4 borrowing a parsing idea from ovs
  
+5 I actually prefer using "-" for the embankment, but what evs.
  
-1 woo hoo!
  
-4 bye bye beloved Bubbler train...
[Answer]
# Python 3, ~~169~~ 168 bytes. (167 with Python 2)
```
p,s='',str.split
for _ in s('N '.join(s('P '.join(s(input(),'P')),'N'))):
 v=int(_[:-1]);p+=['='*v,('- '*v)[:v]][_[-1]=='P']
l=len(p)
u='_'*l
print(u+'\n'*3+p+'\n\n'+u)
```
**Fairly ungolfed:**
```
p=''
for i in'N '.join('P '.join(input().split('P')).split('N')).split():
  v=int(i[:-1])         # Get the number from the input section
  
  if i[-1]=='N':        # Check the letter (last char) from the input section
      p+=('='*v)        # Repeat `=` the number from input (v)
  else:
      p+=('- '*v)[:v]   #Repeat `- ` v times, then take first v chars (half)
l=len(p)                #Get the length of the final line markings
print('_'*l+'\n\n\n'+p+'\n\n'+'_'*l)
```
---
```
print('_'*l                          # Print _ repeated the length of p
           +'\n\n\n'                 # 3 new lines
                    +p+              # print out p (the markings)
                       '\n\n'        # 2 new lines
                             +'_'*l) # Print _ repeated the length of p
```
---
```
for i in
        'N '.join(
                  'P '.join(
                            input().split('P'))
                                               .split('N'))
                                                           .split():
                            # Split the input into items of list at P
                  # Join together with P and ' '
                                                # Split at N...
         # Join with N and ' '
                                                           # Split at space
# Loop through produced list
```
Try it online [here](http://repl.it/lOt).
[Answer]
# J (~~69~~ ~~59~~ ~~55~~ 52 bytes)
-14 bytes thanks to *Raul Miller* and *ovs* on *The APL Farm* Discord.  
-3 bytes by removing noun assigments
```
6$'_',4$'','',:'\d+.'(".@}:$'-= '#~'PNP'={:)rxapply]
```
[Attempt This Online](https://ato.pxeger.com/run?1=LYxLCoJQAEXnreJWwlUySXv0eSQ0cvh4CyhCUonIlCgoHraRJjZoES2l3fQxOKPLued239b143TM-pOXGFlc0RUW6X6QXCQ9j3bHm1fSYj8Eu1dqpRka6RzOcVnuLsv_V2X7OE8RejAGti3acujAwsCBkfKK7yAczMALUVUgW0kBRgglXRgPzInskMYJfqGmWj_T9aZABAol9FSNta98HahAsxHe)
#### Explanation
`'\d+'(...)rxapply]`: For every match of pattern `\d+`, apply the function...
`".@}:$'-= '#~'PNP'={:`, a Fork/3-Train.
* `'-= '#~'PNP'={:`: The right tine of the Fork. `{:` takes the last element (`'N'` or `'P'`), and checks it's equality against `'PNP'`, then uses the resulting boolean mask to select from `'-= '`. `'P'` gets `1 0 1` so it selects `'- '`, and N gets `0 1 0` and selects `'='`.
* `".@}:"`: The left tine of the Fork. `}:` drops the last element, keeping the digit(s) as a sting. The string is converted to a integer with `".`, the Execute operator.
* `$`: The Reshape operator reshapes the right arg by the left arg
The expression so far has produced the mid line, eg. `====- - =========- - - -=-==-` , which I will refer to as `m` below.
`,:` Itemize `m` (ie. Puts it in an array, changing the shape from `30` to `1 30`)
`4$'',''` Prepend 2 blank rows (arrays are rectangular, so the 2 chars get padded to the width of `m`) and then reshape by 4. Since there are 3 rows, reshape cycles to reuse the first row, adding another blank line.
`6$'_',` Prepends a `_` char (which again gets padded to the width of `m`) then reshapes to 6. Again, since there's 5 rows, reshaping cycles back to the first item in the array (ie. the top line) which is appended to the array, producing the final result.
[Answer]
# Haskell, 165 bytes
```
k 'N'="="
k _="- "
d c=c>'/'&&c<':'
p[]=[]
p s=take(read$takeWhile d s)(cycle$k a)++p r where(a:r)=dropWhile d s
f s=unlines[q,"\n",p s,"",q]where q=map(\x->'_')$p s
```
Example run (`f` returns a string, so for better display print it):
```
*Main> putStr $ f "4N4P9N7P1N1P2N2P"
______________________________
====- - =========- - - -=-==- 
______________________________
```
How it works: `p` returns the middle line by recursively parsing the input string and concatenating the given number of symbols found by the lookup function `k`. The main function `f` joins a five element list with newlines, consisting of the top line (every char of the middle line replaced by `_`), a newline, the middle line, an empty line and the bottom line (same as top).
[Answer]
# PHP, 187 bytes
```
preg_match_all('/(\d+)(\w)/',$argv[1],$m,2);
$o='';
foreach($m as $p)
    $o.=str_replace('--','- ',str_repeat($p[2]<'P'?'=':'-',$p[1]));
$a=preg_replace('/./','_',$o);
echo("$a\n\n\n$o\n\n$a\n");
```
The code can stay on a single line; it is displayed here on multiple lines to be more readable (the whitespaces and newlines used for formatting were not counted).
Two bytes can be saved by not printing the trailing newline. Five more bytes can be saved by using real newline characters on the `echo()`:
```
echo("$a
$o
$a");
```
Six additional bytes can be saved by omitting the initialization of `$o` (`$o='';`) but this will trigger a notice. The notice can be suppressed by running the script using the command line:
```
$ php -d error_reporting=0 <script_name> 4N4P9N7P1N1P2N2P
```
These brings it to 174 bytes.
[Answer]
# Ruby, ~~137~~ 135 bytes
Not the shortest I could come up with, but close to the nicest. Partly borrowed from Optimizer's answer.
```
require'scanf'
N='_  = _'
P='_  - _'
a=[]
scanf('%d%c'){|l,t|a+=[eval(t).chars]*l}
puts (a.shift.zip(*a).map(&:join)*?\n).gsub'--','- '
```
Ungolfed:
```
require 'scanf'
N = '_  = _'
P = '_  - _'
columns = [] # array of columns
# scan stdin for a number followed by a single char
scanf('%d%c') do |length, type|
  columns += [eval(type).chars] * length
done
# Convert to an array of rows, and join into a string
rows = columns.shift.zip(*columns).map(&:join)
str = rows * "\n" # join lines
# Replace '--' by '- ' and print
puts str.gsub(/--/, '- ')
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~35~~ 34 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.γa}2ôε`„PN…- =2ä‡s∍}J©¶ĆìĆ'_®∍DŠ»
```
[Try it online](https://tio.run/##AVUAqv9vc2FiaWX//y7Os2F9MsO0zrVg4oCeUE7igKYtID0yw6TigKFz4oiNfUrCqcK2xIbDrMSGJ1/CruKIjUTFoMK7//80TjRQOU43UDFOMVAyTjJQMTJO) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TpuSZV1BaYqWgZF@pw6XkX1oC4elU/tc7tzmx1ujwlnNbEx41zAvwe9SwTFfB1ujwkkcNC4sfdfTWeh1aeWjbkbbDa460qccfWgcUcjm64NDu/zqHttn/NzTy4zI0CuAy8TMJsPQzDzD0Mwww8jMKAAA).
**Explanation:**
```
.γ                # Consecutive group the (implicit) input by:
  a               #  Check if the character is a letter
   }2ô            # After the group by: split it into parts of size 2
ε                 # Map each pair of integer + letter to:
 `                #  Pop and push them separated to the stack
  „PN             #  Push string "PN"
     …- =         #  Push string "- ="
         2ä       #  Split it into 2 parts: ["- ","="]
           ‡      #  Transliterate the "P" to "- " and "N" to "="
            s     #  Swap to take the integer value
             ∍    #  Extend (or shorten) the string to that length
              }J  # After the map: join all parts together to a single string
                © # And store it in variable `®` (without popping)
¶                 # Push a newline character "\n"
 Ć                # Double it "\n\n"
  ì               # Prepend it in front of the string
   Ć              # Enclose the string, appending it's own first character
'_               '# Push string "_"
  ®∍              # Extend it to a size equal to the length of string `®`
    D             # Duplicate it
     Š            # Triple swap the three values on the stack from a,b,c to c,a,b
      »           # Join the values on the stack with newline delimiter
                  # (after which the result is output implicitly)
```
[Answer]
# Ruby, 94 bytes
Borrows the `gsub'--','- '` idea from [14mRh4X0r's answer](https://codegolf.stackexchange.com/a/49406/26465). I think that answer is more interesting, though, although this is shorter.
```
f=->x{n=?_*x.gsub!(/(\d+)(.)/){($2==?P??-:?=)*$1.to_i}.size
"#{n}
#{x.gsub'--','- '}
#{n}"}
```
Testing:
```
f=->x{n=?_*x.gsub!(/(\d+)(.)/){($2==?P??-:?=)*$1.to_i}.size
"#{n}
#{x.gsub'--','- '}
#{n}"}
puts f['4N4P9N7P1N1P2N2P']
```
Produces:
```
______________________________
====- - =========- - - -=-==- 
______________________________
```
[Answer]
let me include my ***matlab*** version
## MATLAB (267 b)
```
function d=p(V,a),j=numel(V)-1;if (a==0),d=0;return; end,d=(V(a)-48+10*p(V,a-1))*(V(a)<64);fprintf('%c%.*s%c%.*s',(a>=j)*10,(a==j|a==1)*eval(strcat(regexprep(V,'[NP]','+'),48)),ones(99)*'_',(a<3)*10,(V(a+1)>64)*d,repmat((V(a+1)==78)*'=='+(V(a+1)==80)*'- ',[1 99]));end
```
---
## input
An ascii-formatted string tailed by a space (since there is no end of chain '\0' in matlab
**example** V='12N13P '
---
## output
pattern representation of the road
```
_________________________
============- - - - - - -
_________________________
```
## function
the function must be called from its tail-1 (the empty character is removed)
**example** : p(V,numel(V)-1) 
## Simulation
try it online [here](http://www.tutorialspoint.com/codingground/index.htm?port=9197&sessionid=sup8e17e757ccean6qdbiahe91&home=http://codingground.tutorialspoint.com)
[Answer]
# R, 132 bytes
Not greatly happy with this, but it was a bit of fun to do:) Tried to get rid of the multiple `gsub`s, but my efforts were in vain. I suspect there's a much better way to do this.
```
cat(rbind(nchar(a<-scan(,'',t=gsub('PN','P N',gsub('NP','N P',chartr('- =','PPN',scan(,'',sep='|')[4]))))),substring(a,1,1)),sep='')
```
* `scan` gets the strings from STDIN and grabs the 4th one. **Note** that the empty lines require a space (or something) in them for scan to carry on getting the input.
> 
> "====- - =========- - - -=-==- "
> 
> 
>
* It replaces the `=`s with `N`s, the `-` and  with `P`s.
> 
> "NNNNPPPPNNNNNNNNNPPPPPPPNPNNPP"
> 
> 
>
* Then it inserts a space between each `NP` and `PN`
> 
> "NNNN PPPP NNNNNNNNN PPPPPPP N P NN PP"
> 
> 
>
* The scan splits the string on spaces
> 
> "NNNN" "PPPP" "NNNNNNNNN" "PPPPPPP" "N" "P" "NN" "PP"
> 
> 
>
* The string length is then bound(`rbind`) with the first character of each string
> 
> 4 4 9 7 1 1 2 2  
> 
>  "N" "P" "N" "P" "N" "P" "N" "P"
> 
> 
>
* The array is then output using `cat`.
Test run
```
cat(rbind(nchar(a<-scan(,'',t=gsub('PN','P N',gsub('NP','N P',chartr('- =','PPN',scan(,'',sep='|')[4]))))),substring(a,1,1)),sep='')
1: ____________
2:  
3:  
4: ============
5:  
6: ____________
7: 
Read 6 items
Read 1 item
12N
> 
> cat(rbind(nchar(a<-scan(,'',t=gsub('PN','P N',gsub('NP','N P',chartr('- =','PPN',scan(,'',sep='|')[4]))))),substring(a,1,1)),sep='')
1: ____________
2:  
3:  
4: - - - - - - 
5:  
6: ____________
7: 
Read 6 items
Read 1 item
12P
> cat(rbind(nchar(a<-scan(,'',t=gsub('PN','P N',gsub('NP','N P',chartr('- =','PPN',scan(,'',sep='|')[4]))))),substring(a,1,1)),sep='')
1: ______________________________
2:  
3:  
4: ====- - =========- - - -=-==- 
5:  
6: ______________________________
7: 
Read 6 items
Read 8 items
4N4P9N7P1N1P2N2P
```
[Answer]
# C, 155 153 bytes
−2 bytes thanks to **ceilingcat**
```
l=6;main(k,v,n,x,s,c)char*s,**v,c;{for(;l--;puts(s))for(s=v[1];*s;s+=k)for(x=sscanf(s,"%d%c%n",&n,&c,&k);n--;)putchar(" -=_"[l%5?l^2?0:c^78?++x&1:2:3]);}
```
More readable:
```
main(l,v,k,n,x,s,c)
    char*s,**v,c;
{
    for(l=6;l--;puts(s))
        for(s=v[1];*s;s+=k)
            for(x=sscanf(s,"%d%c%n",&n,&c,&k);n--;)
                putchar(l%5?l^2?32:c^78?++x&1?45:32:61:95);
}
```
The outer loop counts lines from 5 to 0.
The middle loop iterates over parts of the encoded string:
```
4N4P9N7P1N1P2N2P
4P9N7P1N1P2N2P
9N7P1N1P2N2P
7P1N1P2N2P
1N1P2N2P
1P2N2P
2N2P
2P
string is empty - exit
```
The inner loop decodes a part, like, `7P`, and iterates the needed number of times (e.g. 7).
Each iteration prints one `char`. The value of the `char` is described by the code `" -=_"[l%5?l^2?0:c^78?++x&1:2:3]`:
* If line number is 5 or 0, print `_`
* Otherwise, if line number is not equal to 2, print a space
* Otherwise, if the symbol is 'N', print `=`
* Otherwise, increase `x` by 1 (it was initialized to 2 by `sscanf`)
* If odd, print `-`, else print a space
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, ~~30~~ ~~29~~ ~~28~~ 29 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Takes input in lowercase, prepend `v<space>` for +2 bytes if that's not allowed. Had to sacrifice a byte to fix a bug with inputs that contained a `0` :\
```
ò!Í®n îZèÍg"- ="òÃ¬yÈû4 Ôû6'_
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=8iHNrm4g7lrozWciLSA9IvLDrHnI%2bzQg1Ps2J18&input=IjRuNHA5bjdwMW4xcDJuMnAi)
```
ò!Í®n îZèÍg"- ="òÃ¬yÈû4 Ôû6'_     :Implicit input of string
ò!Í                               :Partition into the run length groups we need (See more detailed explanation below)
   ®                              :Map each Z
    n                             :   Convert to integer (the letter at the end is ignored)
      î                           :   Repeat and slice to that length
       Zè                         :     Count the occurrences in Z of
         Í                        :     "n" (see below for the why)
          g                       :     Index into
           "- ="ò                 :     Partitions of "- =" of length 2
                 Ã                :End map
                  ¬               :Join
                   y              :Transpose
                    È             :Pass each row through the following function and transpose back
                     û4           :   Centre pad with spaces to length 4
                        Ô         :   Reverse ('cause centre padding is right-biased)
                         û6'_     :   Centre pad with "_" to length 6
```
OK, I finally (think I) figured out how the partitioning is working! First the basics: The `ò` method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using `Í` here, which is the shortcut for `n2<space>`. The space is used to close the `ò` method and the `n` and the `2` being split into two separate arguments, with the second being ignored as `ò` only expects one argument. That means that we're currently testing `XnY` but, by adding the `!`, the elements get flipped giving us `YnX`.
And now for the trickery: The possible combinations we can have (where `L=[np]` & D=`[0-9]`) are `DnL`, `LnD` & `DnD` and, in all cases, both elements are strings, which is important. The `n` attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:
* `Dnp` squares the integer resulting in a non-empty string, which is truthy, creating a partition.
* `Dnn` negates the integer resulting in a non-empty string, which is truthy, creating a partition.
* `DnD` & `LnD`, for some reason that I can't figure out, both result in `0`, which is falsey, so no partition is created.
Hopefully, that all made some sort of sense but, if it helps, [here's a handy table](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LVI&code=5EBbWFlZblggISFZblhdw2kiWCBZIFluWCBCb29sZWFuIrggrvk0IG/5OCC4w2nJIPot&input=IjhuODhwODA4biI).
And, as a final note: the `Í` works exactly the same way as above when passed to the `è` method, which only expects a single string argument.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 158 bytes
```
$f='';($_|sls "\d*\w"-a|% m*).value|%{$n=($_|sls "\d+"-a|% m*).value;if($n-eq$null){$n=1};switch($_[-1]){N{$f+='='*$n}P{$f+=-join(1..$n|%{(' ','-')[$_%2]})}}}
```
**Ungolfed**
```
$args|%{
    # empty string for adding road later
    $finalString=''
    # breaks every pair apart and selects the value (N4, P4, etc.)
    ($_|sls "\d*\w"-a|% m*).value|%{
        
        # selects just the number
        $num = ($_|sls "\d+"-a|% m*).value
        
        # for those pairs that don't have a number associated
        if($num -eq $null){$num = 1}
    
        # switch depending on the char
        switch($_[-1]){
            
            # nothing to do with N so append to finalString var
            N{
                $finalString += '=' * $num
            }
            # for loop to determine the alternating of the road pattern
            P{
                $finalString += -join (1..$num | %{(' ','-')[$_%2]})
            }
        }
    }
        
    # formats string for desired output
    "{0}`n`n`n{1}`n`n{0}" -f $("_"*$finalString.length),$finalString
}
```
[Try it online!](https://tio.run/##XY3RasMwDEXf9xXGKNhO6zCngTJCfsH4vS1Z2OImw3W3ul0eHH@75wQGYwjula6O0Od16m9u6I2J0N3Obs58BN0QUlNoZ2ccwsf3/Dhh3s0ZuuSs@O7Mo08Y2OYPsvkH1KOmYHn/BfZhDFtoEWo3jfe3IZ0duDgxLz3oTUMakoMNah34x3W0VBQF2PSDEkS2hBN2gDYrT4GFECL2z@HVLuXF2qQZI64RUNziHHRhenu@D2wL@inEiEUpMUqqklayUi9yr4QUqpRrtNhO7tSyWvw3rmRZKfwD "PowerShell – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `L`, 180 bits[v1](https://github.com/Vyxal/Vyncode/blob/main/README.md), 22.5 bytes
```
⁽aḊyC½`- =`½$İ$⌊Ẏ∑ƛ4↳Ǔ\_pǏ
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=1#WyJMPSIsIiIsIuKBvWHhuIp5Q8K9YC0gPWDCvSTEsCTijIrhuo7iiJHGmzTihrPHk1xcX3DHjyIsIiIsIjRONFA5TjdQMU4xUDJOMTJQIl0=)
```
  Ḋ                        # Group by...
⁽a                         # Is it an uppercase letter?
   y                       # Uninterleave - split into [numbers, chars]
    C½                     # Charcodes / 2 - N -> 39, P -> 40
            $İ             # Index into...
      `- =`½               # ["- ", "="]
                Ẏ          # Extend to length
              $⌊           # numbers
                 ∑         # Concatenate into a single string
                  ƛ        # For each character
                   4↳      # Prepend three spaces
                     Ǔ     # Move a space to the end
                      \_p  # Prepend a _
                         Ǐ # Append the _
                           # L flag transposes and joins the whole thing
```
[Answer]
# [Lua](https://www.lua.org/), 123 122 bytes
```
p=print s=(...):gsub('(%d+)(.)',load'a,b=...return({N="=",P="- "})[b]:rep(a):sub(1,a)')r=('_'):rep(#s)p(r)p'\n'p(s)p()p(r)
```
[Try it online!](https://tio.run/##HcvRCsIgFIDhVxlGnHPIBMcgEs4riPcVoWxEMJzovIqe3doufz7@ufrWEqf8jmtXGJVSZF6lBgQ8jidCRSDnxY/gZeC/5mmtOeLHsmAhHYtzJ750Cw@Tp4SezPZq6QkoM8ITaIdDoYSZEtwjJNxi79baYAd3tRenrXa97d0P "Lua – Try It Online")
Ungolfed Version:
```
p=print 
s=(...):gsub('(%d+)(.)',                       --For each number/letter pair
function(a,b)                                  --Number in a, letter in b
    return({N="=",P="- "})[b]:rep(a):sub(1,a)  --Replace each number/letter pair 
                                               --with respective pattern
end)
r=('_'):rep(#s)                                --Create edges of road
p(r)p'\n'p(s)p()p(r)                           --Print road
```
[Answer]
# Scala, 163 bytes
```
(s:String)=>{val r=(("\\d+(P|N)"r) findAllIn(s) map(r=>{val l=r.init.toInt;if(r.last=='N')"="*l else ("- "*l).take(l)})).mkString;val k="_"*r.length;s"$k\n\n\n$r\n\n$k"}
```
First try, might be golfed some more.
[Answer]
# [Perl 5](https://www.perl.org/) `-pl`, 64 bytes
```
y/PN/-=/;s/\d+(.)/$1x$&/ge;s/--/- /g;$_=($t=y//_/cr)."
$_
$t"
```
[Try it online!](https://tio.run/##K0gtyjH9/79SP8BPX9dW37pYPyZFW0NPU1/FsEJFTT89FSiiq6uvq6Cfbq0Sb6uhUmJbqa8fr59cpKmnxMXFpRIPxCVK//@b@JkEWPqZBxj6GQYY@RkF/MsvKMnMzyv@r@trqmdgaPBftyAHAA "Perl 5 – Try It Online")
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 89 bytes
```
{,⌿{⍪(⌽,2∘↓∘⊢)⍵,'  _'}¨⍪⍎¯1↓('\d+'⎕R{'(',⍵.Match})('[P]' '[N]'⎕R'⍴''- ''),' '⍴''=''),')⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v1rnUc/@6ke9qzQe9ezVMXrUMeNR22QQ2bVI81HvVh11BYV49dpDK4AqHvX2HVpvCJTWUI9J0VZ/1Dc1qFpdQ10HqEzPN7EkOaNWU0M9OiBWXUE92i8WLK/@qHeLurqugrq6JtAkCM8WzAEZXvs/7VHbBKCxj7qaH/WuAcoeWm/8qG0iUGdwkDOQDPHwDP6fpqBu4mcSYOlnHmDoZxhg5GcUoA4A "APL (Dyalog Extended) – Try It Online")
A huge, clunky solution with a lot of regex and `⍎`.
## Explanation
`('[P]' '[N]'⎕R'⍴''- ''),' '⍴''=''),')⍵` Replace `N` with code for producing '=' and `P` for producing '- ' with a closing bracket
`('\d+'⎕R{'(',⍵.Match})` prepend an opening bracket to each digit
('\d+'⎕R{'(',⍵.Match})
`⍎¯1↓` drop the last character, and execute (gives the road markings)
`⍪` table it
`⍵,' _'}¨` add two spaces and underscore for each marking
`⍪(⌽,2∘↓∘⊢)` Palindromize that, table it
`,⌿` join all the columns into a single road
]