\documentclass[tikz]{standalone}

\usepackage{tikz}
\usepackage{fontspec}
\usepackage{contour}

\ExplSyntaxOn
\cs_new_eq:NN \strcaseOTF \str_case:onTF
\cs_new_eq:NN \strifeqOTF \str_if_eq:onTF
\cs_new_eq:NN \strreplace \tl_replace_all:Nnn
\cs_new_eq:NN \strset \str_set:Nn
\cs_new_eq:NN \tlset \tl_set:Nn
\cs_new_eq:NN \tlreplace \tl_replace_all:Nnn
\cs_new_eq:NN \tlremove \tl_remove_all:Nn
\cs_new_eq:NN \tlremoveone \tl_remove_one:Nn
\cs_new_eq:NN \tlputleft \tl_put_left:Nn
\cs_new_eq:NN \tlputright \tl_put_right:Nn

\cs_new_eq:NN \seqsetsplit \seq_set_split:Nnn
\cs_new_eq:NN \seqMapInline \seq_set_map:NNn
\cs_new_eq:NN \seqPopRight \seq_pop_right:NN
\cs_new_eq:NN \seqUse \seq_use:Nn

% scratch space for multi-line labels later
\seq_new:N \nodeseq
\seq_new:N \temp
\ExplSyntaxOff
\usepackage{pgfplots}

\setmainfont{Atkinson Hyperlegible}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}

\definecolor{one}{RGB}{243,155,154}
\definecolor{two}{RGB}{176,0,68}
\definecolor{three}{RGB}{213,173,0}
\definecolor{four}{RGB}{247,171,99}
\definecolor{five}{RGB}{0,150,94}
\definecolor{seven}{RGB}{135,204,0}
\definecolor{nine}{RGB}{149,107,37}
\definecolor{ten}{RGB}{166,15,128}
\definecolor{twelve}{RGB}{94,107,175}
\definecolor{fourteen}{RGB}{228,142,0}
\definecolor{fifteen}{RGB}{225,117,0}
\definecolor{sixteen}{RGB}{147,194,59}
\definecolor{nineteen}{RGB}{227,0,11}
\definecolor{twentyfour}{RGB}{33,195,100}
\definecolor{twentyseven}{RGB}{140,29,117}
\definecolor{thirtyone}{RGB}{243,155,154}
\definecolor{thirtythree}{RGB}{94,107,175}

\input{../shapes.tex}

\pgfdeclarelayer{bg}
\pgfdeclarelayer{lines}
\pgfdeclarelayer{stops}
\pgfdeclarelayer{labels}
\pgfdeclarelayer{legend}
\pgfsetlayers{bg,lines,stops,labels,main,legend}

\contourlength{.2ex}

\begin{document}

\begin{tikzpicture}[
    railway line/.style = {
      color=gray,
      line width=0.075cm,
      rounded corners=0.5cm,
    },
    railway/.style = {
      railway line,
      {Latex[length=5mm]}-{Latex[length=5mm]},
    },
    railway outwards/.style = {
      railway line,
      -{Latex[length=5mm]},
    },
    stop/.style = {
      rounded corners=0.1cm,
      line width=0.05cm,
      fill=white,
      draw,
      shape=stop,
      anchor=center,
      minimum height=0.2cm,
    },
    stop1/.style = {
      stop,
      minimum width=0.2cm,
    },
    stop2/.style = {
      stop,
      minimum width=0.4cm,
    },
    stop3/.style = {
      stop,
      minimum width=0.6cm,
    },
    stop4/.style = {
      stop,
      minimum width=0.8cm,
    },
    stop5/.style = {
      stop,
      minimum width=1.0cm,
    },
    stop6/.style = {
      stop,
      minimum width=1.2cm,
    },
    stop7/.style = {
      stop,
      minimum width=1.4cm,
    },
    line/.style = {
      line width=0.15cm,
      rounded corners=0.1cm,
    },
    help line/.style = {
      line width=0.05cm,
    },
    label/.style = {
      font=\scriptsize,
      align=center,
    },
    line name/.style = {
      label,
      color=white,
      minimum width=1em,
      minimum height=1em,
      inner sep=0pt,
      outer sep=.7em,
    },
  ]

  % movable circle line
  \newcommand{\polar}[1]{($#1 + (-.2,.5)$)}
  \def\rad{5}

  \def\centerarc(#1:#2:#3)
    { ($(-.2,.5) + ({#3*cos(#1)},{#3*sin(#1)})$) arc (#1:#2:#3) }


  \begin{pgfonlayer}{stops}
    \pgfmathsetmacro{\offset}{0.1*tan(45/2)}


    % core stations
    \node[stop4, rotate=45] (Lega Lombarda) at (-1.1,4.5) {};
    \node[stop4] (Lanza) at (0,3) {};
    \node[stop4] (Cusani) at (0,2) {};
    \node[stop6, below=1 of Cusani.east, anchor=east] (Cordusio) {};

    \node[stop2, below=1.5 of Cordusio.four eighth, anchor=one half] (DuomoN) {};
    \node[stop4, below=.6 of DuomoN.one half, anchor=one half] (Duomo) {};
    \draw[stop]
      ($(DuomoN.two half)+(90:0.1)+(0:0.1)$)
    -- ++(-.4,0)
    -- ++(0,-.8)
    -- ++(.8,0)
    -- ++(0,.2)
    -- ++(-.4,0)
    -- ++(0,.4)
    -- cycle
    ;

    % left side
    \node[stop2, rotate=90, left=1.5 of Cordusio.center, anchor=one half] (Ancona) {};
    \node[stop2, rotate=-90, anchor=two half] (Cadorna) at ($(-2.7, 2) + (0,\offset)$) {};

    \node[stop1] (Castello Cairoli) at (-1.1,2.5) {};
    \node[stop1] (Ricasoli) at (-2.2,2.5) {};

    \node[stop3, rotate=-45] (Via Torino Via S Maria Valle) at (-1,-2.5) {};

    % ring
    \node[stop3, rotate=-30] (Centrale) at \polar{(65:8.2)} {};
    \node[stop2, anchor=west, rotate=70] (Monte Santo) at \polar{(70:5.1)} {};
    \node[stop3, anchor=center, rotate=57] (Repubblica) at \polar{(60:5)} {};
    \node[stop3, anchor=center, rotate=45] (Vittorio Veneto) at \polar{(50:5)} {};
    \node[stop1, anchor=center] (Porta Venezia) at \polar{(30:5)} {};
    \node[stop2, anchor=one half, rotate=20] (Viale Piave) at \polar{(20:5)} {};
    \node[stop3, anchor=center, rotate=90] (Piazza 5 Giornate) at \polar{(-3:5)} {};
    \node[stop1, anchor=center] (Monte Nero Via Spartaco) at \polar{(-16:5)} {};
    \node[stop1, anchor=center, rotate=-30] (Viale Monte Nero Via Bergamo) at \polar{(-30:5)} {};
    \node[stop1, anchor=center, rotate=-45] (Porta Romana) at \polar{(-45:5)} {};
    \node[stop1, anchor=center, rotate=-50] (Via Ripamonti Viale Sabotino) at \polar{(-50:5)} {};
    \node[stop1, anchor=center, rotate=10] (Porta Lodovica) at \polar{(-81:5)} {};
    \node[stop2, anchor=two half, rotate=90] (24 Maggio) at \polar{(-97:5)} {};
    \node[stop2, anchor=two half, rotate=71] (Via Vigenavo) at \polar{(-108:5)} {};
    \node[stop4, anchor=north center, rotate=-38] (Piazzale Cantore) at \polar{(-118:5)} {};
    \node[stop2, rotate=-45, anchor=two half] (Porta Genoa) at ($(Piazzale Cantore.two half) + (-134:1)$) {};
    \node[stop2, rotate=40, anchor=two half] (Piazzale Coni Zugna Via Solari) at \polar{(-140:5)} {};

    \node[stop1, anchor=center] (Piazzale Aquileia) at \polar{(-160:5)} {};
    \node[stop1, anchor=center] (Piazzale Baracca) at \polar{(174:5)} {};
    \node[stop2, anchor=center, rotate=71] (Quinto Alpini) at \polar{(161:5)} {};
    \node[stop2, anchor=two half, rotate=-40] (Arco della Pace) at \polar{(145:4.6)} {};
    \node[stop2, anchor=two half, rotate=50] (Corso Sempione Via Procaccini) at \polar{(140:5.4)} {};
    \node[stop2, anchor=center, rotate=25] (Via Bramante) at \polar{(120:5.4)} {};
    \node[stop3, anchor=center, rotate=9] (Via Farini Via Ferrari) at \polar{(99:5.4)} {};








    % west
    \node[stop1, left=2 of Piazzale Baracca] (De Angeli) {};
    \node[stop1] (Segesta) at ($(De Angeli) + (-1.4,1)$) {};
    \node[stop1, left=2 of Segesta] (San Siro Stadio) {};

    \node[stop2, rotate=45, anchor=two half] (Domodossola) at ($(Corso Sempione Via Procaccini.one half) + (135:1.5)$) {};
    \node[stop1, below left=1 of Domodossola.south one half, anchor=north] (Viale Boezio) {};
    \node[stop1, below=0.4 of Viale Boezio] (6 Febbraio) {};

    % right side
    \node[stop3, rotate=90, anchor=east] (Missori) at ($(DuomoN) + (1.5,-0.1)$) {};
    \node[stop3, rotate=90] (Augusto) at ($(Piazza 5 Giornate) - (1.2,0)$) {};
    \node[stop3, rotate=90, left=1 of Augusto.center, anchor=center] (Via Larga) {};

    \node[stop2] (Piazza Fontana) at ($(Augusto) + (-0.5,1)$) {};
    \node[stop2, rotate=45] (Crocetta) at ($(Missori) + (1,-1)$) {};



    % Città studi
    \node[stop3, rotate=90, anchor=one half] (Adalaide di Savoia) at ($(Viale Piave.north two half) + (2.2,0)$) {};
    \node[stop2, rotate=135, anchor=two half] (Valvassori Peroni) at ($(Adalaide di Savoia.one half) + (3,3)$) {};
    \node[stop1, anchor=center] (Stazione Lambrate) at \polar{(32:11.9)} {};
    \node[stop1, right=1 of Valvassori Peroni.south two half, anchor=center] (Rimembranze di Lambrate) {};

    \node[stop1, anchor=west] (Piazza Ferravilla) at ($(Adalaide di Savoia.south two half) + (1+\offset,-1)$) {};
    \node[stop1, right=1.9 of Piazza Ferravilla] (Ortica) {};

    % 33 & 5
    \node[stop2, rotate=45, anchor=center] (Viale Tunisia) at \polar{(46:6.5)} {};
    % 5
    \node[stop2, rotate=-45, anchor=two half] (Via Vitruvio) at \polar{(46:8-.2)} {};
    % 1
    \node[stop1] (Greco Rovereto) at ($(Via Vitruvio.two half) + (2,2)$) {};


    % south
    \node[stop1, below=2 of Porta Lodovica] (Agrippa) {};
    \node[stop2, below=3 of 24 Maggio] (Piazza Abbiategrasso) {};
    \node[stop2, below=3 of Piazza Abbiategrasso] (Via dei Missaglie Via Baroni) {};
    \node[stop1, below left=1 of Via dei Missaglie Via Baroni.two half] (Via Grandi Via Bouzzi Rozzano) {};
    \node[stop1, left=3 of Via Grandi Via Bouzzi Rozzano] (Via G Rossa) {};

    \node[stop1] (Vigentino) at ($(Via Ripamonti Viale Sabotino) + (-50:5)$) {};

    % south west
    \node[stop1] (Via Valenza Alzaia Nav Grande) at ($(Porta Genoa.south one half) + (-.8,0)$) {};
    \node[stop1] (Piazzale Negrelli) at ($(Via Valenza Alzaia Nav Grande.west) + (-140:4.5)$) {};

    \node[stop1] (Lorenteggio) at ($(Piazzale Coni Zugna Via Solari.north one half) + (-143:5)$) {};

    % south of Città studi
    \node[stop2, rotate=90, right=2 of Piazza 5 Giornate.two half, anchor=two half] (Piazza Emilia) {};
    \node[stop1, anchor=west] (Via Arconati) at ($(Piazza Emilia.south one half) + (.5,-1.5)$) {};
    \node[stop1, right=1 of Via Arconati] (Viale Molise) {};
    \node[stop1, right=3.8 of Piazza Emilia.two half] (Repetti) {};
    \node[stop1] (Viale Ungheria Via Mercante) at ($(Repetti.east) + (2,-3)$) {};
    \node[stop1] (Viale Ungheria) at ($(Viale Ungheria Via Mercante) - (0,1)$) {};

    \node[stop1] (Via Comelico) at ($(Viale Monte Nero Via Bergamo.center) + (-30:3)$) {};
    \node[stop1] (Piazza Salgari) at ($(Via Comelico) + (-30:0.3) + (1,0)$) {};
    \node[stop1] (Via Monte Velino) at ($(Piazza Salgari.east) + (.5,1)$) {};


    % north west
    \node[stop2, rotate=90] (Cenisio) at ($(Via Bramante) + (-1,1)$) {};
    \node[stop2, rotate=90, left=1 of Cenisio.center, anchor=center] (Piazza Diocleziano) {};
    \node[stop2, rotate=90, anchor=two half] (Piazza Firenze) at ($(Piazza Diocleziano.two half) + (-2,0)$) {};

    \node[stop2, rotate=90, anchor=one half] (Via Mac Mahon Via Artieri) at ($(Piazza Diocleziano.north one half) + (-3.5,1.5)$) {};
    \node[stop2, rotate=90, anchor=one half] (Piazza Castelli) at ($(Via Mac Mahon Via Artieri.one half) + (-1,0)$) {};

    \node[stop2, rotate=90] (Piazzale Accursio) at ($(Piazza Firenze) + (-2,0)$) {};
    \node[stop2] (Piazzale Santorre di Santarosa) at ($(Piazza Castelli.north one half) + (-1,1)$) {};
    \node[stop2, rotate=70, anchor=south one half, above=1 of Piazzale Santorre di Santarosa] (Certosa) {};
    \node[stop2, rotate=70] (Roserio) at ($(Certosa) - (-20:2)$) {};

    \node[stop1, left=3 of Piazzale Accursio.two half] (Piazzale Cimitero Maggiore) {};


    % north
    \node[stop2, above=1 of Via Farini Via Ferrari.one half, anchor=one half] (Via Farini Via Valtellina) {};
    \node[stop2, above=1 of Via Farini Via Valtellina] (Via Farini Viale Stelvio) {};

    \node[stop1, above=4.2 of Via Farini Viale Stelvio.two half] (Ospedale Niguarda) {};
    \node[stop1, above=2 of Ospedale Niguarda.one half] (Niguarda Parco Nord) {};
    \node[stop1] (Bausan) at ($(Via Farini Viale Stelvio.north one half) + (-4,.5)$) {};

    \node[stop1] (Via Ugo Bassi) at ($(Via Farini Via Ferrari.two half) + (0,.7) + (.2,.2)$) {};

    \node[stop2, anchor=one half] (Piazzale Lagosta) at ($(Via Ugo Bassi) + (2,1.2)$) {};

    \node[stop2, rotate=-30, anchor=one half] (Viale Lunigiana) at ($(Centrale.center) + (60:1)$) {};

    \node[stop2, above=2.1 of Piazzale Lagosta.center, anchor=center] (Marche) {};
    \node[stop2, above=2 of Marche.center, anchor=center] (Ca Granda) {};
    \node[stop2, above=1 of Ca Granda] (Viale Testi Via S Marcellina) {};
    \node[stop2, above=1 of Viale Testi Via S Marcellina] (Bicocca) {};
    \node[stop1] (Precotto Interno Deposito) at ($(Bicocca.north two half) + (3.5,.5)$) {};

    \node[stop1, above=3 of Bicocca.one half] (Primo Maggio) {};


    \node (Milano Porta Vittoria) at (8,-.5) {};
  \end{pgfonlayer}

  \begin{pgfonlayer}{lines}
    \pgfmathsetmacro{\offset}{0.1*tan(45/2)}
    \pgfmathsetmacro{\line}{0.2}

    %% \foreach\angle in {-170,-160,...,180} {
    %%   \draw[help line, color=gray!50] \polar{(0,0)} -- \polar{(\angle:8)};
    %%   \node at \polar{(\angle:8)} { \angle };
    %% };

    \draw[railway outwards]
    (Centrale.center)
    {[rounded corners=0.01cm]
    -- (Centrale.four eighth)
    }
    -- \polar{(61:12)}
    arc (90:20:4.4)
    -- \polar{(32:12.1)}
    arc(10:-12:30)
    {[rounded corners=2cm]
    -- \polar{(-40:10.5)}
    -- \polar{(-134:9.5)}
    }
    -- ++(-140:4.5)
    node[label, below, anchor=north west] {Mortara};

    \draw[railway line]
    (Porta Genoa.five eighth)
    {[rounded corners=1cm]
    -- \polar{(-134:7)}
    }
    -- \polar{(-134:9.5)}
    -- ++(-140:4);

    \draw[railway line]
    \polar{(32:12.1)}
    arc(10:3:30)
    -- ($(Ortica) + (1,0.5)$)
    -- ++(0:2)
    ;

    \draw[railway] ($(Certosa.four sixth) - (-20:1) + (-4,0)$)
    node[label, above, anchor=south west] {Torino}
    -- ($(Certosa.four sixth) - (-20:1)$)
    -- (Certosa.four sixth)
    -- ($(Via Farini Via Valtellina) + (-2,0)$)
    -- ($(Via Farini Via Valtellina) - (0,.5)$)
    arc (90:70:12)
    -- ($(Viale Tunisia.four sixth)$)
    -- ($(Adalaide di Savoia.north west) - (0,.2)$)
    -- ($(Piazza Emilia.north) + (-.1,1)$)
    -- ($(Milano Porta Vittoria) - (1.4,0)$)
    -- ($(Milano Porta Vittoria)$)
    -- ($(Milano Porta Vittoria) + (2,0)$)
    -- ($(Repetti) + (-.15,0)$)
    -- ($(Repetti) + (-.4,1)$)
    -- ($(Ortica) + (1,0.5)$)
    -- ++(0:3)
    node[label, below right, anchor=north] {Verona}
    ;

    \draw[railway outwards]
    ($(Via Farini Via Valtellina) - (0,.5)$)
    arc (90:85:12)
    -- \polar{(75:6)}
    {[rounded corners=2cm]
    -- ++(65:8)
    }
    -- ++(85:5)
    node[label, below left, anchor=north east] {Chiasso (CH)}
    ;

    \draw[railway line]
    (Centrale.center)
    {[rounded corners=0.01cm]
    -- (Centrale.four eighth)
    }
    -- \polar{(61:12)}
    -- ($(75:6) + (65:8) + (-.2,.5)$)
    -- ++(85:5)
    ;

    \draw[railway outwards]
    ($(Repetti) + (-.15,0)$)
    arc(-3:-12:30)
    -- ++(1,-2)
    -- ++(-30:2)
    node[label, above, anchor=south west] {Bologna}
    ;

    \draw[railway outwards]
    ($(Repetti) + (-.15,0)$)
    arc(-3:-12:30)
    -- ++(1,-2)
    -- ++(-90:2)
    node[label, above, anchor=south west] {Genova}
    ;

    \draw[railway line]
    (Certosa.four sixth)
    -- ($(Certosa.four sixth) + (-20:1)$)
    -- ++(1,1.4)
    arc (110:78:25)
    -- \polar{(61:12)}
    arc (90:20:4.4)
    -- \polar{(32:12.1)}
    ;

    \draw[railway line]
    (Certosa.four sixth)
    -- ($(Certosa.four sixth) + (-20:1)$)
    -- ++(1,1.4)
    arc (110:78:25)
    -- \polar{(61:12)}
    -- (Centrale.four eighth)
    ;

    \draw[railway line]
    ($(Certosa.four sixth) + (-17:3)$)
    -- ($(Certosa.four sixth) + (-20:1) + (.5,0)$)
    -- ($(Certosa.four sixth) + (-20:1) + (1,1.4)$)
    arc (110:78:25)
    -- \polar{(61:12)}
    -- (Centrale.four eighth)
    ;

    \draw[railway outwards]
    (Cadorna.four sixth)
    {[rounded corners=.3cm]
    -- ++ (-0.2,0)
    }
    -- \polar{(135:5)}
    -- ($(Piazza Diocleziano) - (1,.3)$)
    arc (-135:-180:10)
    -- ++(0,2)
    node[label, below left, anchor=west] {Asso}
    ;

    \draw[railway outwards]
    (Cadorna.four sixth)
    {[rounded corners=.3cm]
    -- ++ (-0.2,0)
    }
    -- \polar{(135:5)}
    -- ($(Piazza Diocleziano) - (1,.3)$)
    arc (-135:-180:10)
    -- ++(135:2)
    node[label, below left, anchor=west] {Saronno}
    ;


    \draw[line, one]
    (Greco Rovereto)
    -- (Via Vitruvio.two half)
    -- (Viale Tunisia.east)
    -- (Viale Tunisia.west)
    {[rounded corners=0.3cm]
    -- ($(Vittorio Veneto.south one half) + \line*(.7,-.7)$)
    }
    -- (Vittorio Veneto.one half)
    -- \centerarc(53:60:4.8)
    %% -- (Repubblica.one half)
    %% -- (Repubblica.north one half)
    {[rounded corners=0.4cm]
    -- ++(-.6,0)
    -- ($(Cordusio.two half) + (1.3,0)$)
    }
    -- (Cordusio.two half)
    -- (Cusani.two half)
    -- ++(0,0.25)
    -- ($(Cusani.one half) + (-.2,.25)$)
    -- (Cadorna.one half)
    -- (Quinto Alpini.two half)
    -- ($(Quinto Alpini.north two half)$)
    -- ++($(.05,.15+.5*\offset)$)
    -- ($(Arco della Pace.south one half)$)
    -- (Arco della Pace.one half)
    -- (Arco della Pace.north one half)
    -- (Corso Sempione Via Procaccini.one half)
    -- (Domodossola.two half)
    -- ($(Piazza Firenze.south one half)$)
    -- (Piazzale Accursio.one half)
    -- (Piazzale Accursio.north one half)
    {[rounded corners=1.3cm]
    -- ($(Piazzale Santorre di Santarosa.south one half) - (0,1.2)$)
    }
    -- (Piazzale Santorre di Santarosa.south one half)
    -- (Piazzale Santorre di Santarosa.north one half)
    -- (Certosa.south one half)
    -- (Certosa.one half)
    -- (Roserio.one half)
    ;

    \draw[line, two]
    % TODO north
    (Bausan)
    {[rounded corners=.5cm]
    -- ($(Via Farini Viale Stelvio.north one half) + (0,.5)$)
    }
    -- (Via Farini Viale Stelvio.north one half)
    -- (Via Farini Viale Stelvio.one half)
    -- (Via Farini Via Valtellina.one half)
    -- (Via Farini Via Ferrari.one half)
    -- ($(Lega Lombarda.north three quarter) + 2*\offset*(-.7,.7)$)
    -- (Lega Lombarda.three quarter)
    -- ($(Lanza.north three quarter) + (0,2*\offset)$)
    -- (Lanza.three quarter)
    -- (Cusani.three quarter)
    -- (Cordusio.three quarter)
    -- (DuomoN.two half)
    -- ($(Duomo.south two quarter) - (0,2*\offset)$)
    -- (Via Torino Via S Maria Valle.center)
    -- (Piazzale Cantore.north three quarter)
    -- (Piazzale Cantore.three quarter)
    -- (Porta Genoa.one half)
    -- (Porta Genoa.south one half)
    -- (Via Valenza Alzaia Nav Grande)
    -- (Via Valenza Alzaia Nav Grande.west)
    -- (Piazzale Negrelli)
    ;

    \draw[line, three]
    (Duomo.three quarter)
    -- ($(Duomo.south three quarter) - (0,4*\offset)$)
    -- (Via Torino Via S Maria Valle.two half)
    -- (24 Maggio)
    -- (Piazza Abbiategrasso.one half)
    -- (Via dei Missaglie Via Baroni.one half)
    ;

    \draw[line, four]
    (Niguarda Parco Nord)
    -- (Ospedale Niguarda.one half)
    -- (Via Farini Viale Stelvio.two half)
    -- (Via Farini Via Valtellina.two half)
    -- (Via Farini Via Ferrari.center)
    -- ($(Lega Lombarda.north two half)$)
    -- (Lega Lombarda.two half)
    -- ($(Lanza.north two half) + (0,3*\offset)$)
    -- (Lanza.two half)
    -- ++(0,-\line)
    -- ($(Lanza.one half) + (-\line,-\line)$)
    -- (Castello Cairoli)
    -- (Ricasoli)
    ;

    \draw[line, five]
    (Ortica)
    -- (Piazza Ferravilla)
    -- (Piazza Ferravilla.west)
    -- ($(Adalaide di Savoia.south two half) + (\offset, 0)$)
    -- (Adalaide di Savoia.two half)
    -- (Adalaide di Savoia.north two half)
    -- (Viale Tunisia.two half)
    -- (Viale Tunisia.north two half)
    -- (Via Vitruvio.one half)
    -- (Via Vitruvio.north one half)
    -- \centerarc(49:64:8)
    %% -- ($(Centrale.south two half) + (0,2*\offset)$)
    -- (Centrale.two half)
    -- (Viale Lunigiana.south two half)
    -- (Viale Lunigiana.two half)
    -- (Viale Lunigiana.north two half)
    -- \centerarc(65:80:9.4)
    %% {[rounded corners=0.2cm]
    %%   -- ($(Marche.south one half) - (0,\line)$)
    %% }
    -- (Marche.south one half)
    -- (Marche.one half)
    -- (Ca Granda.one half)
    -- (Ca Granda.north one half)
    -- (Ospedale Niguarda)
    ;

    \draw[line, seven]
    (Piazzale Lagosta.two half)
    -- (Marche.two half)
    -- (Ca Granda.two half)
    -- (Bicocca.two half)
    -- (Bicocca.north two half)
    {[rounded corners=.6cm]
    -- ($(Bicocca.north two half) + (0,.5)$)
    }
    -- (Precotto Interno Deposito)
    ;

    \draw[line, nine]
    (Centrale.one half)
    -- (Centrale.south one half)
    -- ($(Monte Santo.east) + (0,2*\offset)$)
    %% -- (Monte Santo.east)
    -- (Monte Santo.west)
    %% -- (Repubblica.north center)
    -- \centerarc(68:-113:\rad)
    %% -- (Vittorio Veneto.center)
    %% -- (Porta Venezia)
    %% -- (Viale Piave.one half)
    %% -- (Piazza 5 Giornate.one half)
    %% -- (Monte Nero Via Spartaco)
    %% -- (Viale Monte Nero Via Bergamo)
    %% -- (Porta Romana)
    %% -- (Via Ripamonti Viale Sabotino)
    %% -- (Porta Lodovica)
    %% -- (24 Maggio.two half)
    %% -- (Via Vigenavo.two half)
    -- (Piazzale Cantore.north two half)
    -- (Piazzale Cantore.two half)
    -- (Porta Genoa.two half)
    ;

    \draw[line, ten]
    (24 Maggio.one half)
    -- \centerarc(-100:-108:5.2)
    -- (Via Vigenavo.one half)
    -- (Via Vigenavo.north one half)
    -- ($(Porta Genoa.east) + (.4,0)$)
    -- (Porta Genoa.east)
    -- ($(Porta Genoa.west) + .1*(-.7,.7)$)
    -- (Piazzale Cantore.two quarter)
    %% -- ($(Piazzale Cantore.north one half) - \offset*(1,1)$)
    -- \centerarc(-123:-195:\rad)
    %% -- (Piazzale Cantore.north one half)
    %% -- (Piazzale Cantore.one half)
    %% -- (Piazzale Coni Zugna Via Solari.south two half)
    %% -- (Piazzale Coni Zugna Via Solari.two half)
    %% -- (Piazzale Aquileia)
    %% -- (Piazzale Baracca)
    -- (Quinto Alpini.center)
    -- (Quinto Alpini.east)
    %% {[rounded corners=.5cm]
    %% -- \polar{(152:4.8)}
    %% }
    -- ($(Arco della Pace.two half) - (0,\offset)$)
    -- (Arco della Pace.two half)
    {[rounded corners=0.3cm]
    -- ($(Arco della Pace.north two half) + \line*(.7,.7)$)
    }
    -- (Corso Sempione Via Procaccini.two half)
    %% {[rounded corners=0.3cm]
    %% -- \polar{(130:5.4)}
    %% }
    %% -- (Via Bramante.west)
    %% -- (Via Bramante.east)
    %% {[rounded corners=0.3cm]
    %% -- \polar{(110:5.2)}
    %% }
    %% -- (Via Farini Via Ferrari.west)
    %% -- (Via Farini Via Ferrari.east)
    -- \centerarc(139:72:5.4)
    -- (Monte Santo.two half)
    -- ($(Monte Santo.south two half) + (0,2*\offset)$)
    -- ($(Centrale.south center) $)
    -- (Centrale.center)
    -- (Viale Lunigiana.one half)
    ;

    \draw[line, twelve]
    % TODO
    (Viale Molise)
    -- (Via Arconati)
    {[rounded corners=0.3cm]
    -- ($(Via Arconati.west) - (.5,0)$)
    }
    -- (Piazza Emilia.south one half)
    -- (Piazza Emilia.one half)
    -- (Piazza 5 Giornate.center)
    -- (Augusto.center)
    -- (Via Larga.center)
    -- ++(-0.2,0)
    -- ($(Missori.two half) + (.2,0)$)
    -- (Missori.two half)
    -- ($(DuomoN.four sixth) - (0,.2)$)
    -- (DuomoN.four sixth)
    -- (Cordusio.three sixth)
    -- (Cusani.one half)
    -- (Lanza.one half)
    -- ($(Lanza.north one half)$)
    -- (Lega Lombarda.one half)
    -- (Lega Lombarda.north one half)
    -- ($(Via Bramante.south one half) - (0,\offset)$)
    -- (Via Bramante.one half)
    -- (Via Bramante.north one half)
    -- (Cenisio.south one half)
    -- (Cenisio.one half)
    -- (Piazza Diocleziano.one half)
    -- (Piazza Diocleziano.north one half)
    {[rounded corners=0.5cm]
    -- ($(Piazza Diocleziano.north one half) - (.5,0)$)
    -- ($(Via Mac Mahon Via Artieri.two half) + (2,0)$)
    }
    -- (Via Mac Mahon Via Artieri.two half)
    -- (Piazza Castelli.two half)
    -- (Piazza Castelli.north two half)
    {[rounded corners=0.3cm] -- ++(-.3,0)
    -- (Piazzale Santorre di Santarosa.south two half)
    }
    -- (Piazzale Santorre di Santarosa.two half)
    -- (Piazzale Santorre di Santarosa.north two half)
    {[rounded corners=0.2cm]
    -- ($(Certosa.south two half) + 4*\offset*(-20:1)$)
    }
    -- (Certosa.two half)
    -- (Roserio.two half)
    ;

    \draw[line, fourteen]
    % TODO
    (Piazzale Cimitero Maggiore)
    -- (Piazzale Accursio.two half)
    -- (Piazza Firenze.two half)
    -- (Piazza Diocleziano.north two half)
    -- (Piazza Diocleziano.two half)
    -- (Cenisio.two half)
    -- ($(Cenisio.south two half) + (2*\offset,0)$)
    -- ($(Via Bramante.north two half)$)
    -- (Via Bramante.two half)
    -- (Via Bramante.south two half)
    -- (Lega Lombarda.north two quarter)
    -- (Lega Lombarda.two quarter)
    -- ($(Lanza.north two quarter) + (0,\offset)$)
    -- (Lanza.two quarter)
    -- (Cusani.two quarter)
    -- (Cordusio.four sixth)
    -- (DuomoN.one half)
    -- ($(Duomo.south one half)$)
    -- (Via Torino Via S Maria Valle.one half)
    -- ($(Piazzale Cantore.north two quarter) + \offset*(2,2)$)
    -- (Piazzale Cantore.one half)
    -- \centerarc(-122:-135:5.2)
    %% -- ($(Piazzale Cantore.south two quarter) + (0,-\offset)$)
    %% -- ($(Piazzale Cantore.south one half) + (-\offset,-\offset)$)
    -- (Piazzale Coni Zugna Via Solari.one half)
    {[rounded corners=0.2cm]
    -- ($(Piazzale Coni Zugna Via Solari.north one half) + (-.1,.1)$)
    }
    -- (Lorenteggio)
    ;

    \draw[line, fifteen]
    (Duomo.two half)
    -- (Duomo.south two half)
    -- (Porta Lodovica)
    -- (Agrippa)
    -- (Agrippa.south)
    {[rounded corners=0.2cm]
      -- ($(Agrippa.south) - (0,.2)$)
      -- ($(Piazza Abbiategrasso.north two half) + (0,.2)$)
    }
    -- (Piazza Abbiategrasso.north two half)
    -- (Piazza Abbiategrasso.two half)
    -- (Via dei Missaglie Via Baroni.two half)
    -- (Via dei Missaglie Via Baroni.south two half)
    {[rounded corners=0.5cm]
    -- ($(Via Grandi Via Bouzzi Rozzano) + (.5,0)$)
    -- (Via Grandi Via Bouzzi Rozzano)
    }
    -- (Via G Rossa)
    ;

    \draw[line, sixteen]
    (San Siro Stadio)
    -- (Segesta)
    -- (Segesta.east)
    {[rounded corners=0.3cm]
    -- ($(Segesta.east) + (.2,0)$)
    -- ($(De Angeli.west) - (.2,0)$)
    }
    -- (De Angeli.west)
    -- (De Angeli)
    -- (Piazzale Baracca)
    -- (Ancona.one half)
    -- (Cordusio.one half)
    -- (DuomoN.six tenth)
    {[rounded corners=0.5cm]
    -- ($(DuomoN.six tenth) - (0,0.6)$)
    }
    -- (Missori.one half)
    -- ++(0.2,0)
    -- (Crocetta.two half)
    -- (Crocetta.south two half)
    -- (Viale Monte Nero Via Bergamo.west)
    -- (Viale Monte Nero Via Bergamo)
    {[rounded corners=0.2cm]
    -- ($(Viale Monte Nero Via Bergamo) + (.1,0)$)
    -- (Via Comelico)
    -- ($(Via Comelico) + (-30:0.3)$)
    }
    -- (Piazza Salgari)
    -- (Piazza Salgari.east)
    {[rounded corners=0.3cm]
      -- ($(Piazza Salgari.east) + (.5,0)$)
    }
    -- (Via Monte Velino)
    ;

    \draw[line, nineteen]
    (Stazione Lambrate)
    arc (10:8.5:30)
    -- (Valvassori Peroni.south one half)
    -- (Valvassori Peroni.one half)
    {[rounded corners=0.2cm]
    -- ($(Adalaide di Savoia.south one half) + (2*\offset,0)$)
    }
    -- (Adalaide di Savoia.one half)
    -- (Viale Piave.north two half)
    -- (Viale Piave.two half)
    -- \centerarc(19:0:5.2)
    -- ($(Piazza 5 Giornate.one half) + (\line,0)$)
    -- (Piazza 5 Giornate.one half)
    -- (Augusto.one half)
    -- (Via Larga.one half)
    -- ++(-0.1,0)
    -- ($(Missori.two quarter) + (.3,0)$)
    -- (Missori.two quarter)
    {[rounded corners=0.3cm]
    -- ($(DuomoN.five eighth) - (0,0.4)$)
    }
    -- (DuomoN.five eighth)
    -- (Cordusio.two quarter)
    -- ($(Cordusio.north two quarter)$)
    -- (Ancona.two half)
    -- (Cadorna.two half)
    -- (Quinto Alpini.one half)
    -- (Quinto Alpini.north one half)
    -- (6 Febbraio.south)
    -- (6 Febbraio)
    -- (Viale Boezio)
    -- (Viale Boezio.north)
    -- (Domodossola.south one half)
    -- (Domodossola.one half)
    -- (Piazza Firenze.west)
    -- (Piazza Firenze.east)
    {[rounded corners=0.3cm]
    -- ($(Piazza Firenze.east) + (-.1,\line)$)
    -- ($(Via Mac Mahon Via Artieri.south one half) + (\line,0)$)
    }
    -- (Via Mac Mahon Via Artieri.south one half)
    -- (Via Mac Mahon Via Artieri.one half)
    -- (Piazza Castelli.one half)
    ;

    \draw[line, twentyfour]
    (Piazza Fontana.one half)
    {[rounded corners=0.2cm]
      |- ++(0,-.7)
    }
    -- ($(Via Larga.two half) + (.1,0)$)
    -- (Via Larga.two half)
    -- ++(-0.3,0)
    -- ($(Missori.two half) + (0,.1)$)
    -- ($(Missori.one half) - (0,.1)$)
    -- (Crocetta.one half)
    -- (Crocetta.south one half)
    {[rounded corners=0.2cm]
      -- ($(Crocetta.south one half) + (-40:.2)$)
      -- ($(Via Ripamonti Viale Sabotino.west) - (-50:.2)$)
    }
    -- (Via Ripamonti Viale Sabotino.west)
    -- (Via Ripamonti Viale Sabotino)
    -- (Via Ripamonti Viale Sabotino.east)
    -- (Vigentino)
    ;

    \draw[line, twentyseven]
    (Viale Ungheria)
    -- (Viale Ungheria Via Mercante)
    {[rounded corners=.3cm]
    -- ($(Viale Ungheria Via Mercante) + (0,.5)$)
    -- ($(Repetti.east) + (0,-.5)$)
    }
    -- (Repetti)
    -- (Piazza Emilia.two half)
    -- (Piazza 5 Giornate.two half)
    -- (Augusto.two half)
    -- ++(-.1,0)
    {[rounded corners=0.2cm]
      -- ($(Piazza Fontana.two half) - (0,.7)$)
    }
    -- (Piazza Fontana.two half)
    ;

    \draw[line, thirtyone]
    (Viale Testi Via S Marcellina.one half)
    -- (Bicocca.one half)
    -- (Primo Maggio)
    ;

    \draw[line, thirtythree]
    (Rimembranze di Lambrate)
    -- (Valvassori Peroni.south two half)
    -- (Valvassori Peroni.two half)
    -- (Adalaide di Savoia.south center)
    -- (Adalaide di Savoia.center)
    -- ($(Adalaide di Savoia.north center) + (-2*\offset,0)$)
    -- (Viale Tunisia.one half)
    -- (Viale Tunisia.north one half)
    -- ($(Vittorio Veneto.south two half)$)
    -- (Vittorio Veneto.two half)
    %% -- (Repubblica.two half)
    %% -- (Monte Santo.south one half)
    %% -- (Monte Santo.north one half)
    -- \centerarc(50:95:5.2)
    -- (Via Farini Via Ferrari.south two half)
    -- ++(0,.7)
    -- (Via Ugo Bassi)
    {[rounded corners=.3cm]
    -- ++(1.8,0)
    }
    -- ($(Piazzale Lagosta.south one half)$)
    -- (Piazzale Lagosta.one half)
    ;
  \end{pgfonlayer}

  \begin{pgfonlayer}{labels}

    \foreach \stop/\stopanchor/\line/\anchor/\name in {
      Greco Rovereto/center/one/south/1,
      Roserio/one half/one/east/1,
      Roserio-one-label/center/twelve/east/12,
      Bausan/center/two/north/2,
      Piazzale Negrelli/center/two/north east/2,
      Duomo/two half/fifteen/north west/15,
      Duomo-fifteen-label/center/three/north/3,
      Via dei Missaglie Via Baroni/two half/three/west/3,
      Niguarda Parco Nord/center/four/west/4,
      Ricasoli/center/four/east/4, % TODO
      Ortica/center/five/south/5,
      Ospedale Niguarda/center/five/east/5,
      Piazzale Lagosta/center/seven/east/7,
      Piazzale Lagosta-seven-label/center/thirtythree/east/33,
      Precotto Interno Deposito/center/seven/west/7,
      Centrale/four eighth/nine/west/9,
      % TODO rest of centrale
      Porta Genoa/center/nine/north east/9,
      24 Maggio/center/ten/north east/10,
      Viale Lunigiana/center/ten/west/10,
      Viale Molise/center/twelve/north/12,
      Piazzale Cimitero Maggiore/center/fourteen/south/14,
      Lorenteggio/center/fourteen/north east/14,
      Via G Rossa/center/fifteen/north/15,
      San Siro Stadio/center/sixteen/north/16,
      Via Monte Velino/center/sixteen/west/16,
      Stazione Lambrate/east/nineteen/west/19,
      Piazza Castelli/one half/nineteen/north east/19,
      Piazza Fontana/one half/twentyfour/east/24,
      Vigentino/center/twentyfour/north east/24,
      Piazza Fontana/two half/twentyseven/west/27,
      Viale Ungheria/center/twentyseven/west/27,
      Viale Testi Via S Marcellina/two half/thirtyone/west/31,
      Primo Maggio/center/thirtyone/east/31,
      Rimembranze di Lambrate/center/thirtythree/north/33
    } {
      \node[label, line name, fill=\line, anchor=\anchor] (\stop-\line-label)
        at ($(\stop.\stopanchor)$)
        {\bf \name};
    };

    \foreach\stop/\stopanchor/\direction/\distance/\anchor/\rotate in {
      Piazzale Cantore/west/190/0/north east/0,
      Via Vigenavo/east/50/.3/center/0,
      Cenisio/east/180/.3/south west/0,
      Quinto Alpini/west/30/-.1/east/0,
      Missori/south center/-45/.2/west/0,
      Monte Santo/north west/-45/.1/east/0,
      Cordusio/south two half/140/.2/north west/0
    } {
      \node[label, rotate=\rotate, anchor=\anchor]
      at ($(\stop.\stopanchor) + (\direction:\distance)$)
           {\contour{white}{\stop}};
    };

    \node[label, anchor=west] at ($(DuomoN.east) + (0,.1)$)
         {\contour{white} {Duomo}};

    \foreach\stop/\stopanchor/\anchor/\rotate in {
      Via G Rossa/north/south/0,
      Cusani/east/west/0,
      Lanza/east/west/0,
      Via Larga/west/west/-45,
      Augusto/west/west/-45,
      Ancona/west/north/0,
      Cadorna/east/north east/0,
      Crocetta/east/south west/0,
      Ricasoli/north/south/0,
      Lega Lombarda/east/west/0,
      Piazza Fontana/north/south/0,
      Piazza 5 Giornate/one half/north west/0,
      % west
      San Siro Stadio/north/south/0,
      Segesta/north/south/0,
      De Angeli/south/north/0,
      6 Febbraio/west/east/0,
      Viale Boezio/west/east/0,
      Domodossola/west/east/0,
      Piazza Firenze/west/east/20,
      Piazzale Accursio/west/east/20,
      % north
      Certosa/east/south/0,
      Bausan/north/south/0,
      Niguarda Parco Nord/west/east/0,
      Primo Maggio/east/west/0,
      Bicocca/west/east/0,
      Ca Granda/east/west/0,
      Marche/west/east/0,
      Via Ugo Bassi/north/south west/0,
      Greco Rovereto/east/west/0,
      Via Vitruvio/east/west/0,
      Viale Tunisia/south east/west/0,
      % east
      Piazza Ferravilla/south/north/0,
      Viale Piave/west/east/0,
      Porta Venezia/west/east/0,
      Stazione Lambrate/west/east/0,
      Valvassori Peroni/east/east/0,
      Piazza Emilia/east/south/0,
      Via Arconati/south/north/0,
      Viale Molise/north/south/0,
      % south east
      Via Comelico/west/north east/0,
      Piazza Salgari/south/north/0,
      Via Monte Velino/west/east/0,
      Repetti/center/south west/0,
      Viale Ungheria/west/east/0,
      % south
      Agrippa/east/west/0,
      % ring
      Via Bramante/north west/east/0,
      24 Maggio/one half/north west/0,
      Porta Lodovica/south east/north west/0,
      Porta Romana/east/west/0,
      Repubblica/two half/south west/0,
      Piazzale Baracca/south/north west/0,
      Piazzale Aquileia/west/east/0
    } {
      \node[label, rotate=\rotate, anchor=\anchor]
      at ($(\stop.\stopanchor)$)
           {\contour{white}{\stop}};
    };

    \foreach \stop/\suffix/\position/\anchor/\rotate in {
      Centrale/nine-label/.2/west/0,
      Viale Lunigiana/ten-label/.2/west/0,
      Lorenteggio/fourteen-label/.2/west/0,
      Piazzale Negrelli/two-label/.2/west/0,
      Porta Genoa/nine-label/.2/west/0,
      Ospedale Niguarda/five-label/-.2/east/0,
      Ortica/five-label/-.2/east/0,
      Vigentino/twentyfour-label/.2/west/0
    } {
      \node[label, rotate=\rotate, anchor=\anchor]
      at ($(\stop-\suffix) + (\position,0)$)
           {\contour{white}{\stop}};
    };

    \node[label, anchor=south east] at ($(Roserio-one-label) + (.35,.2)$) {\contour{white}{Roserio}};


    \def\mlabel(#1, #2, #3, #4, #5)#6{
      \tlset\nodename{#6}
      \tlremove\nodename{/}
      \node[label, align=center, anchor=#2, rotate=#3] at ($(\nodename.#1) + (#4:#5)$) {%
        \seqsetsplit\nodeseq{ /}{#6}%
        \seqMapInline\temp\nodeseq{\contour{white}{##1}}%
        \seqUse\temp{\\}
      };
    }
    \def\slabel(#1, #2)#3{\mlabel(#1, #2, 0, 0, 0){#3}}

    \mlabel(north west, south east, 0, 180, .1){Piazzale Coni Zugna /Via Solari}
    \slabel(north west, south east){Via Torino /Via S Maria Valle}
    \slabel(north west, east){Via Valenza Alzaia /Nav Grande}
    \slabel(west, east){Piazzale Santorre /di Santarosa}
    \mlabel(east, south, 0, 0, -.2){Via Mac Mahon /Via Artieri}
    \slabel(south, north){Piazzale /Cimitero Maggiore}
    \mlabel(east, west, 0, -40, .2){Corso Sempione /Via Procaccini}
    \slabel(west, east){Via Farini /Viale Stelvio}
    \slabel(west, east){Viale Testi /Via S Marcellina}
    \slabel(east, west){Piazzale /Lagosta}
    \slabel(east, south){Piazza /Diocleziano}
    \slabel(north west, east){Via Farini /Via Valtellina}
    \slabel(one half, south east){Via Farini /Via Ferrari}
    \slabel(east, west){Rimembranze /di Lambrate}
    \slabel(west, east){Viale Ungheria /Via Mercante}
    \slabel(east, west){Monte Nero /Via Spartaco}
    \slabel(north east, west){Viale Monte Nero /Via Bergamo}
    \mlabel(west, east, 0, 180, .2){Via Ripamonti /Viale Sabotino}
    \slabel(west, east){Piazza /Abbiategrasso}
    \slabel(west, east){Via dei Missaglie /Via Baroni}
    \slabel(south, north){Via Grandi /Via Bouzzi Rozzano}
    \mlabel(east, south, 0, 70, .2){Adalaide di /Savoia}
    \mlabel(east, west, 0, 0, .5){Precotto /Interno Deposito}
    \mlabel(west, north west, 0, 0, -.2){Piazza /Castelli}
    \mlabel(north, south, 0, -180, 0.1){Castello /Cairoli}
    \mlabel(south west, east, 0, -90, 0.1){Arco della /Pace}
    \mlabel(south west, north, 0, 0, 0){Vittorio /Veneto}

  \end{pgfonlayer}
\end{tikzpicture}

\end{document}
% vim: nospell conceallevel=0
