%!TEX TS-program = pdflatexmk

% Copyright 2018 Martin Scheidt (ISC license)
% Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

\documentclass[tikz,border=2]{standalone}

\usepackage{lmodern}
\usepackage[prefix=]{xcolor-solarized}

\def\rootTrackschematic{../../tikz-trackschematic}
\def\srcTrackschematic{\rootTrackschematic/src}
\input{\srcTrackschematic/topology.tikz}
\input{\srcTrackschematic/constructions.tikz}
\input{\srcTrackschematic/vehicles.tikz}
\input{\srcTrackschematic/trafficControl.tikz}   % Order 1
\input{\srcTrackschematic/layoutSymbols_DE.tikz} % Order 2 (important)

\begin{document}
  \begin{tikzpicture}[font=\sffamily]
  { % % stations
    \tikzset{every node/.style={base00}};
    \node[right,align=left] at ( 5,1.3) {to and from\\ Berg};
    \node                   at (21,3.9) {{\LARGE Bf Chamstadt}};
    \node[left,align=right] at (37.5,1.3) {to and from\\ Dornroda};
    \node[left,align=right] at (36.5,4.0) {to and from\\ Ehrenstein};
  }
  { % % tracks
    \draw[MainTrack] ( 4.5, 0) -- ++(33, 0);
    \draw[MainTrack] (15  , 0) -- ++( 1, 1) -- ++(14,0);
    \draw[MainTrack] (14  , 0) -- ++( 1,-1) -- ++(10.5,0) -- ++( 1,1);
    \draw[MainTrack] (27  , 1) -- ++( 1,-1);
    \draw[MainTrack] (29  , 0) -- ++( 5, 5);
    \draw[SideTrack] ( 9  , 1) -- ++( 7, 0);
    % % track numbers
    \node[fill=background] at (12.5, 1) {11};
    \node[fill=background] at (21.75, 1) { 1};
    \node[fill=background] at (21.75, 0) { 2};
    \node[fill=background] at (21.75,-1) { 3};
    % % bufferstops
    \pic at ( 9, 1) {bufferstop_backward};
    % % turnouts
    \pic  at (14.8, 1) {derailer_left_forward};
    \node at (14.7, 0.6) {\footnotesize Gs7};
    \pic  at (14,0) {turnout_right_forward};
    \pic  at (14,0) {fouling_point_right_forward};
    \node at (14,0.2) {\footnotesize W1};
    \pic  at (15,0) {turnout_left_forward};
    \pic  at (15,0) {fouling_point_left_forward};
    \node at (15,-0.2) {\footnotesize W2};
    \pic  at (16,1) {turnout_left_backward};
    \pic  at (16,1) {fouling_point_left_backward};
    \node at (16,1.2) {\footnotesize W3};
    \pic  at (26.5,0) {turnout_left_backward};
    \pic  at (26.5,0) {fouling_point_left_backward};
    \node at (26.5,0.2) {\footnotesize W4};
    \pic  at (27,1) {turnout_right_forward};
    \pic  at (27,1) {fouling_point_right_forward};
    \node at (27,1.2) {\footnotesize W5};
    \pic  at (28,0) {turnout_right_backward};
    \pic  at (28,0) {fouling_point_right_backward};
    \node at (28,-0.2) {\footnotesize W6};
    \pic  at (29,0) {turnout_left_forward};
    \pic  at (29,0) {fouling_point_left_forward};
    \node at (29,-0.2) {\footnotesize W7};
    \pic  at (30,1) {turnout_left_backward};
    \pic  at (30,1) {fouling_point_left_backward};
    \node at (30.3,0.8) {\footnotesize W8};

    % % platforms
    \pic at (19,0) {platform_left};
    \pic at (19,1) {platform_right};
  }
  { % % signals
    \pic         at ( 7.5, 0  ) {distant_signal_forward};
    \node[left]  at ( 7.5,-0.4) {Va};
    \pic         at (10, 0  ) {route_signal_forward};
    \pic         at (10, 0  ) {distant_signal_forward};
    \node[left]  at (10,-0.4) {A};
    \pic         at (16,-1  ) {route_signal_backward};
    \node[right] at (16,-0.6) {P3};
    \pic         at (18, 1  ) {route_signal_backward};
    \node[right] at (18, 1.4) {P1};
    \pic         at (18, 0  ) {route_signal_backward};
    \node[right] at (18, 0.4) {P2};
    \pic         at (24, 1  ) {route_signal_forward};
    \node[left]  at (24, 0.6) {N1};
    \pic         at (24, 0  ) {route_signal_forward};
    \node[left]  at (24,-0.4) {N2};
    \pic         at (25,-1  ) {route_signal_forward};
    \node[left]  at (25,-1.4) {N3};
    \pic         at (33, 0  ) {route_signal_backward};
    \pic         at (33, 0  ) {distant_signal_backward};
    \node[right] at (33, 0.4) {F};
    \pic         at (35.5, 0  ) {distant_signal_backward};
    \node[right] at (35.5, 0.4) {Vf};
    \pic[rotate=45] at (32.5, 2.5) {route_signal_backward};
    \pic[rotate=45] at (32.5, 2.5) {distant_signal_backward};
    \node[right,rotate=45] at (32.2, 2.8) {G};
    \pic[rotate=45] at (34, 4  ) {distant_signal_backward};
    \node[right,rotate=45] at (33.7, 4.3) {Vg};
    % % routes
    \pic at (21,-1) {route_freight_backward};
    \pic at (22.5,-1) {route_freight_forward};
    \pic at (21,0) {route_passanger_backward};
    \pic at (22.5,0) {route_passanger_forward};
    \pic at (21,1) {route_passanger_backward};
    \pic at (22.5,1) {route_passanger_forward};
  }
  { % % clearing points
    \pic at (10  , 0) {clearing_point};
    \pic at (13  , 0) {clearing_point};
    \pic at (14  , 1) {clearing_point};
    \pic at (16  , 0) {clearing_point};
    \pic at (16  ,-1) {clearing_point};
    \pic[rotate=45] at (15.5, 0.5) {clearing_point};
    \pic at (18  , 1) {clearing_point};
    \pic at (18  , 0) {clearing_point};
    \pic at (24  , 1) {clearing_point};
    \pic at (24  , 0) {clearing_point};
    \pic at (26  , 1) {clearing_point};
    \pic at (25  ,-1) {clearing_point};
    \pic at (27  , 0) {clearing_point};
    \pic[rotate=-45] at (27.5, 0.5) {clearing_point};
    \pic[rotate= 45] at (29.5, 0.5) {clearing_point};
    \pic at (30.2, 0) {clearing_point};
    \pic at (33  , 0) {clearing_point};
    \pic[rotate= 45] at (30.2, 1.2) {clearing_point};
    \pic[rotate= 45] at (32  , 3  ) {clearing_point};
  }
  { % % vehicles
    \pic  at ( 7  ,0) {train_direction_forward=2};
    \node at ( 6,0) {\emph{RB}};
    % \pic  at (21.5,2) {train=3};
    % \node at (23  ,2) {\emph{WG}};
    \pic  at (10.2,1) {train=1};
    \node at (10.7,1) {\emph{Tfz}};
    \pic  at (16.5,-1) {train_direction_backward};
    \node at (18.5,-1) {\emph{GZ}};
  }
  { % % hectometer posts
    \tikzset{every node/.style={left,base00,rotate=-90},every path/.style={base00,dashed}};
    \node at (07.5,-2.75) { 7.200};
    \draw    (07.5,-1.55) -- ++(0,0.7);
    \node at (10.0,-2.75) { 8.200};
    \draw    (10.0,-1.55) -- ++(0,0.7);
    \node at (13.0,-2.75) { 8.400};
    \draw    (13.0,-1.55) -- ++(0,1.1);
    \node at (14.0, 2.25) { 8.500};
    \draw    (14.0, 2.15) -- ++(0,-.8);
    \node at (15.5, 2.25) { 8.550};
    \draw    (15.5, 2.15) -- ++(0,-.8);
    \node at (16.0,-2.75) { 8.600};
    \draw    (16.0,-1.55) -- ++(0,0.3);
    \node at (18.0, 2.25) { 8.700};
    \draw    (18.0, 2.15) -- ++(0,-.3);
    \node at (19.0, 2.25) { 8.750};
    \draw    (19.0, 2.15) -- ++(0,-.8);
    \node at (23.0, 2.25) { 9.000};
    \draw    (23.0, 2.15) -- ++(0,-.8);
    \node at (24.0, 2.25) { 9.100};
    \draw    (24.0, 2.15) -- ++(0,-.8);
    \node at (25.0,-2.75) { 9.150};
    \draw    (25.0,-1.55) -- ++(0,0.0);
    \node at (26.0, 2.25) { 9.200};
    \draw    (26.0, 2.15) -- ++(0,-.8);
    \node at (27.0,-2.75) { 9.250};
    \draw    (27.0,-1.55) -- ++(0,1.1);
    \node at (27.5,-2.75) { 9.300};
    \draw    (27.5,-1.55) -- ++(0,1.1);
    \node at (29.5,-2.75) { 9.450};
    \draw    (29.5,-1.55) -- ++(0,1.1);
    \node at (30.2,-2.75) { 9.500};
    \draw    (30.2,-1.55) -- ++(0,1.1);
    \node at (33.0,-2.75) { 9.900};
    \draw    (33.0,-1.55) -- ++(0,1.3);
    \draw    (33.0, 0.85) -- ++(0,1.2) -- ++(-0.5,0.5);
    \node at (35.5,-2.75) {10.900};
    \draw    (35.5,-1.55) -- ++(0,1.3);
    \draw    (35.5, 0.85) -- ++(0,1.7) -- ++(-1.5,1.5);
  }
  \end{tikzpicture}
\end{document}