1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
%% symbol library for TikZ track schematics
%
% Copyright (c) 2018 - 2022, 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.
%
\ProvidesFileRCS{tikzlibrarytrackschematic.construction.code.tex}%
%
%%%%%%%%%%%%%%%
% global settings
%%%%%%%%%%%%%%%
\RequirePackage{tikz,etoolbox}%
\usetikzlibrary{calc}%
%
\ifdeflength{\objectlength}{}{% Not defined, so define it!
\newlength{\objectlength}%
}%
\setlength{\objectlength}{4cm}%
%
%%%%%%%%%%%%%%%
% tikz keys for multiple use
%%%%%%%%%%%%%%%
\pgfkeys{%
/tikz/trackschematic/.is family,%
/tikz/trackschematic/.cd,%
%% color foreground
foreground/.store in=\foreground,%
foreground=black,% DEFAULT
/tikz/foreground/.forward to=/tikz/trackschematic/foreground,%
%% color background
background/.store in=\background,%
background=white,% DEFAULT
/tikz/background/.forward to=/tikz/trackschematic/background,%
%% length
length/.store in=\objectlength,% default length 4cm
/tikz/length/.forward to=/tikz/trackschematic/length,%
%% traffic practice
traffic practice/.value required,% left OR right
traffic practice/.store in=\trafficpractice,%
traffic practice=right,% DEFAULT
/tikz/traffic practice/.forward to=/tikz/trackschematic/traffic practice,%
/tikz/position/.forward to=/tikz/trackschematic/traffic practice,%
}%
\newlength{\objectwidth}\setlength{\objectwidth}{0.5cm}%
\pgfkeys{%
/tikz/trackschematic/constructions/.is family,%
/tikz/trackschematic/constructions/.cd,%
%% side
side/.value required,% left, right OR both
side/.store in=\side,% left, right OR both
side=right,% DEFAULT
/tikz/side/.forward to=/tikz/trackschematic/constructions/side,%
%% width
width/.store in=\objectwidth,% default width 0.5cm
/tikz/width/.forward to=/tikz/trackschematic/constructions/width,%
}%
%
%%%%%%%%%%%%%%%
% symbol platform
%%%%%%%%%%%%%%%
%
%% command
\newcommand\platform{}% just for safety
\def\platform[#1]#2(#3){% \platform[options] at (coord);
\pic[#1] at (#3) {platform={#2}}% symbol
}%
%% symbol definition
\tikzset{%
pics/platform/.default=,%
pics/platform/.style args={#1}{code={%
%% settings
\def\coordcommand{#1}% beware of leading and tailing spaces!
%
\ifdefstring{\side}{left}{% side
\pgfmathsetmacro{\sidefactor}{1}%
}{%
\ifdefstring{\side}{right}{% side
\pgfmathsetmacro{\sidefactor}{-1}%
}{%
\ifdefstring{\side}{both}{% side
}{% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/side}{“left“, “right“ OR “both“ as key required}}%
}%
}%
}% end \ifdefstring{\side}
%% platform shape
\tikzset{every path/.style={draw=\foreground,line width=0.75pt}};%
\ifdefstring{\side}{both}{% double side
\path ($-0.5*(\objectlength,0) + (0, \objectwidth)$) --%
($-0.5*(\objectlength,0) + (0, 0.2)$) --%
($ 0.5*(\objectlength,0) + (0, 0.2)$) --%
($ 0.5*(\objectlength,0) + (0, \objectwidth)$);% part 1
\path ($-0.5*(\objectlength,0) + (0, 0.3)$) --%
($ 0.5*(\objectlength,0) + (0, 0.3)$);% part 2
\path ($-0.5*(\objectlength,0) + (0,-\objectwidth)$) --%
($-0.5*(\objectlength,0) + (0,-0.2)$) --%
($ 0.5*(\objectlength,0) + (0,-0.2)$) --%
($ 0.5*(\objectlength,0) + (0,-\objectwidth)$);% part 3
\path ($-0.5*(\objectlength,0) + (0,-0.3)$) --%
($ 0.5*(\objectlength,0) + (0,-0.3)$);% part 4
}{% single side
\path ($-0.5*(\objectlength,0) + \sidefactor*(0,\objectwidth)$) --%
($-0.5*(\objectlength,0) + \sidefactor*(0,0.2)$) --%
($ 0.5*(\objectlength,0) + \sidefactor*(0,0.2)$) --%
($ 0.5*(\objectlength,0) + \sidefactor*(0,\objectwidth)$);% part 1
\path ($-0.5*(\objectlength,0) + \sidefactor*(0,0.3)$) --%
($ 0.5*(\objectlength,0) + \sidefactor*(0,0.3)$);% part 2
}%
}},% END pics/platform/.style args={#1}
% symbology entry
symbology_platform/.pic = {%
\maintrack (0,0) -- (6,0);%
\platform[side=left] at (3,0);%
},%
}%
%
%%%%%%%%%%%%%%%
% symbol level crossing
%%%%%%%%%%%%%%%
%
%% command
\newcommand\levelcrossing{}% just for safety
\def\levelcrossing[#1]#2(#3){% \levelcrossing[options] at (coord);
\pic[side=both,#1] at (#3) {level_crossing={#2}}% symbol
}%
%% tikz keys
\newlength{\roadwidth}\setlength{\roadwidth}{0.4cm}%
\newtoggle{show_road}\settoggle{show_road}{true}%
\pgfkeys{%
/tikz/trackschematic/constructions/level crossing/.is family,%
/tikz/trackschematic/constructions/level crossing/.cd,%
%% barrier
barrier/.store in=\barrier,% full, semi OR none
barrier=none,% DEFAULT
/tikz/barrier/.forward to=/tikz/trackschematic/constructions/level crossing/barrier,%
/tikz/barrier side/.forward to=/tikz/trackschematic/constructions/side,%
%% show road
no road/.value forbidden,%
no road/.code={\settoggle{show_road}{false}},%
/tikz/no road/.forward to=/tikz/trackschematic/constructions/level crossing/no road,%
%% road width
road width/.store in=\roadwidth,% default width 0.4cm
/tikz/road width/.forward to=/tikz/trackschematic/constructions/level crossing/road width,%
}%
%% symbol definition
\tikzset{%
pics/level_crossing/.default=,%
pics/level_crossing/.style args={#1}{code={%
%% settings
\def\coordcommand{#1} % beware of leading and tailing spaces!
%% traffic practice setup
\ifdefstring{\trafficpractice}{left}{% branch
\pgfmathsetmacro{\trafficfactor}{-1}%
}{%
\ifdefstring{\trafficpractice}{right}{% branch
\pgfmathsetmacro{\trafficfactor}{1}%
}{% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/trafficcontrol/traffic practice}{“left“ OR “right“ as key required}}%
}%
}% end \ifdefstring{\trafficpractice}
%% symbol
\tikzset{every path/.style={draw=\foreground,line width=1pt}};%
\iftoggle{show_road}{% true
\path ($0.5*(-\roadwidth,0) + (0,-0.1)$) --%
++($(0,-\objectwidth)$);% road part 1
\path ($0.5*( \roadwidth,0) + (0,-0.1)$) --%
++($(0,-\objectwidth)$);% road part 2
\path ($0.5*(-\roadwidth,0) + (0, 0.1)$) --%
++($(0, \objectwidth)$);% road part 3
\path ($0.5*( \roadwidth,0) + (0, 0.1)$) --%
++($(0, \objectwidth)$);% road part 4
}{}% END \iftoggle{show_road}
\ifdefstring{\barrier}{full}{% full barrier
\ifdefstring{\side}{both}{%
\filldraw[\foreground]% left barrier part 1
($(-0.5\roadwidth,0)+(-0.2,0)+(0,0.35)$) circle (0.05);%
\filldraw[\foreground]% left barrier part 2
($( 0.5\roadwidth,0)+( 0.2,0)+(0,0.35)$) circle (0.05);%
\path ($(-0.5\roadwidth,0)+(-0.2,0)+(0,0.35)$) --%
++($( 0.45\roadwidth,0)+( 0.2,0)$);% left barrier part 3
\path ($( 0.5\roadwidth,0)+( 0.2,0)+(0,0.35)$) --%
++($(-0.45\roadwidth,0)+(-0.2,0)$);% left barrier part 4
%
\filldraw[\foreground]% right barrier part 1
($( 0.5\roadwidth,0)+( 0.2,0)+(0,-0.35)$) circle (0.05);%
\filldraw[\foreground]% right barrier part 2
($(-0.5\roadwidth,0)+(-0.2,0)+(0,-0.35)$) circle (0.05);%
\path ($( 0.5\roadwidth,0)+( 0.2,0)+(0,-0.35)$) --%
++($(-0.45\roadwidth,0)+(-0.2,0)$);% right barrier part 3
\path ($(-0.5\roadwidth,0)+(-0.2,0)+(0,-0.35)$) --%
++($( 0.45\roadwidth,0)+( 0.2,0)$);% right barrier part 4
}{%
\ifdefstring{\side}{left}{%
\filldraw[\foreground]% left barrier part 1
($(-0.5\roadwidth,0)+(-0.2,0)+(0,0.35)$) circle (0.05);%
\filldraw[\foreground]% left barrier part 2
($( 0.5\roadwidth,0)+( 0.2,0)+(0,0.35)$) circle (0.05);%
\path ($(-0.5\roadwidth,0)+(-0.2,0)+(0,0.35)$) --%
++($( 0.45\roadwidth,0)+( 0.2,0)$);% left barrier part 3
\path ($( 0.5\roadwidth,0)+( 0.2,0)+(0,0.35)$) --%
++($(-0.45\roadwidth,0)+(-0.2,0)$);% left barrier part 4
}{%
\ifdefstring{\side}{right}{%
\filldraw[\foreground]% right barrier part 1
($( 0.5\roadwidth,0)+( 0.2,0)+(0,-0.35)$) circle (0.05);%
\filldraw[\foreground]% right barrier part 2
($(-0.5\roadwidth,0)+(-0.2,0)+(0,-0.35)$) circle (0.05);%
\path ($( 0.5\roadwidth,0)+( 0.2,0)+(0,-0.35)$) --%
++($(-0.45\roadwidth,0)+(-0.2,0)$);% right barrier part 3
\path ($(-0.5\roadwidth,0)+(-0.2,0)+(0,-0.35)$) --%
++($( 0.45\roadwidth,0)+( 0.2,0)$);% right barrier part 4
}{%% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/side}{“left“, “right“ OR “both“ as key required}}%
}% END \ifdefstring{\side}{right}
}% END \ifdefstring{\side}{left}
}% END \ifdefstring{\side}{both}
}{%
\ifdefstring{\barrier}{semi}{% semi barrier
\ifdefstring{\side}{both}{%
\filldraw[\foreground]% left barrier part 1
($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)+(0,0.35)$) circle (0.05);%
\path ($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)+(0,0.35)$) --%
++($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)$);% left barrier part 2
%
\filldraw[\foreground]% right barrier part 1
($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)+(0,-0.35)$) circle (0.05);%
\path ($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)+(0,-0.35)$) --%
++($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)$);% right barrier part 2
}{%
\ifdefstring{\side}{left}{%
\filldraw[\foreground]% left barrier part 1
($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)+(0,0.35)$) circle (0.05);%
\path ($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)+(0,0.35)$) --%
++($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)$);% left barrier part 2
}{%
\ifdefstring{\side}{right}{%
\filldraw[\foreground]% right barrier part 1
($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)+(0,-0.35)$) circle (0.05);%
\path ($\trafficfactor*(0.5\roadwidth,0)+\trafficfactor*(0.2,0)+(0,-0.35)$) --%
++($\trafficfactor*(-0.5\roadwidth,0)+\trafficfactor*(-0.2,0)$);% right barrier part 2
}{%% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/side}{“left“, “right“ OR “both“ as key required}}%
}% END \ifdefstring{\side}{right}
}% END \ifdefstring{\side}{left}
}% END \ifdefstring{\side}{both}
}{%
\ifdefstring{\barrier}{none}{% no barriers
}{% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/level crossing/barrier}{“full“, “semi“ OR “none“ as key required}}%
}%
}% END \ifdefstring{\barrier}{semi}
}% END \ifdefstring{\barrier}{full}
}},% END pics/level_crossing/.style args={#1}
% symbology entry
symbology_level_crossing/.pic = {%
\maintrack (0,0) -- (6,0);%
\levelcrossing[barrier=semi] at (3,0);%
},%
}%
%
%%%%%%%%%%%%%%%
% symbol bridge
%%%%%%%%%%%%%%%
%
%% command
\newcommand\bridge{}% just for safety
\def\bridge[#1]#2(#3){% \bridge[options] at (coord);
\pic[side=both,#1] at (#3) {bridge={#2}}% symbol
}%
\newlength{\shiftleft}\setlength{\shiftleft}{0cm}%
\newlength{\shiftright}\setlength{\shiftright}{0cm}%
\newtoggle{show_background}\settoggle{show_background}{true}%
%% tikz keys
\pgfkeys{%
/tikz/trackschematic/constructions/bridge/.is family,%
/tikz/trackschematic/constructions/bridge/.cd,%
% shift
shift left/.store in=\shiftleft,% default shift 0cm
/tikz/shift left/.forward to=/tikz/trackschematic/constructions/bridge/shift left,%
shift right/.store in=\shiftright,% default shift 0cm
/tikz/shift right/.forward to=/tikz/trackschematic/constructions/bridge/shift right,%
%% show road
no background/.value forbidden,%
no background/.code={\settoggle{show_background}{false}},%
/tikz/no background/.forward to=/tikz/trackschematic/constructions/bridge/no background,%
}%
%% symbol definition
\tikzset{%
pics/bridge/.default=,%
pics/bridge/.style args={#1}{code={%
%% settings
\def\coordcommand{#1} % beware of leading and tailing spaces!
%% symbol
\iftoggle{show_background}{% true
\fill[\background]%
($(-0.5\objectlength,\objectwidth)+(0,-0.1)$) rectangle%
($(0.5\objectlength,-\objectwidth)+(0,0.1)$);%
}{}%
\tikzset{every path/.style={draw=\foreground,line width=0.75pt}};%
\ifdefstring{\side}{both}{%
\path ($-0.5*(\objectlength,0)+(-0.1,0)+(\shiftleft,\objectwidth)$) --%
++($(0.1,-0.1)$) --%
++($(\objectlength,0)$) --%
++($(0.1,0.1)$);% left bridge
\path ($-0.5*(\objectlength,0)+(-0.1,0)+(\shiftright,-\objectwidth)$) --%
++($(0.1,0.1)$) --%
++($(\objectlength,0)$) --%
++($(0.1,-0.1)$);% right bridge
}{%
\ifdefstring{\side}{left}{%
\path ($-0.5*(\objectlength,0)+(-0.1,0)+(\shiftleft,\objectwidth)$) --%
++($(0.1,-0.1)$) --%
++($(\objectlength,0)$) --%
++($(0.1,0.1)$);% left bridge
}{%
\ifdefstring{\side}{right}{%
\path ($-0.5*(\objectlength,0)+(-0.1,0)+(\shiftright,-\objectwidth)$) --%
++($(0.1,0.1)$) --%
++($(\objectlength,0)$) --%
++($(0.1,-0.1)$);% right bridge
}{%% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/side}{“left“, “right“ OR “both“ as key required}}%
}% END \ifdefstring{\side}{right}
}% END \ifdefstring{\side}{left}
}% END \ifdefstring{\side}{both}
}},% END pics/bridge/.style args={#1}
% symbology entry
symbology_bridge/.pic = {%
\bridge[] at (3,0);% first
\maintrack (0,0) -- (6,0);%% secound
},%
}%
%
%%%%%%%%%%%%%%%
% symbol interlocking
%%%%%%%%%%%%%%%
%
%% command
\newcommand\interlocking{}% just for safety
\def\interlocking#1(#2){% \interlocking at (coord);
\pic at (#2) {interlocking={#1}}% symbol
}%
%% tikz keys
% \pgfkeys{%
% /tikz/trackschematic/.is family,%
% /tikz/trackschematic/.cd,%
% }%
%% symbol definition
\tikzset{%
pics/interlocking/.default=,%
pics/interlocking/.style args={#1}{code={%
%% settings
\def\coordcommand{#1} % beware of leading and tailing spaces!
%% symbol
\tikzset{every path/.style={draw=\foreground,line width=1pt}};%
\path (-0.6,-0.4 ) rectangle ++(1.2,0.8); % building
\path[fill=\foreground] (-0.5,-0.3 ) rectangle ++(1.0,0.2); % table
\path[fill=\foreground] ( 0 , 0.15) circle (0.15); % human dot
}},% END pics/interlocking/.style args={#1}
% symbology entry
symbology_interlocking/.pic = {
\interlocking at (3,0);%
},%
}%
%
%%%%%%%%%%%%%%%
% symbol hump
%%%%%%%%%%%%%%%
%
%% command
\newcommand\hump{}% just for safety
\def\hump#1(#2){% \hump at (coord);
\pic at (#2) {hump={#1}}% symbol
}%
%% tikz keys
% \pgfkeys{%
% /tikz/trackschematic/.is family,%
% /tikz/trackschematic/.cd,%
% }%
%% symbol definition
\tikzset{%
pics/hump/.default=,%
pics/hump/.style args={#1}{code={%
%% settings
\def\coordcommand{#1} % beware of leading and tailing spaces!
%% symbol
\tikzset{every path/.style={draw=\foreground,line width=0.75pt}};%
% left side
\path (-0.3, 0.1) -- ++(0,0.05);
\path (-0.2, 0.1) -- ++(0,0.15);
\path (-0.1, 0.1) -- ++(0,0.25);
\path ( 0.0, 0.1) -- ++(0,0.35);
\path ( 0.1, 0.1) -- ++(0,0.25);
\path ( 0.2, 0.1) -- ++(0,0.15);
\path ( 0.3, 0.1) -- ++(0,0.05);
% right side
\path (-0.3,-0.1) -- ++(0,-0.05);
\path (-0.2,-0.1) -- ++(0,-0.15);
\path (-0.1,-0.1) -- ++(0,-0.25);
\path ( 0.0,-0.1) -- ++(0,-0.35);
\path ( 0.1,-0.1) -- ++(0,-0.25);
\path ( 0.2,-0.1) -- ++(0,-0.15);
\path ( 0.3,-0.1) -- ++(0,-0.05);
}},% END pics/hump/.style args={#1}
% symbology entry
symbology_hump/.pic = {%
\secondarytrack (0,0) -- (6,0);%
\hump at (3,0);%
},%
}%
%
%
%%%%%%%%%%%%%%%
% symbol pylon
%%%%%%%%%%%%%%%
%
%% command
\newcommand\pylon{}% just for safety
\def\pylon[#1]#2(#3){% \pylon[options] at (coord);
\pic[#1] at (#3) {pylon={#2}}% symbol
}%
%% symbol definition
\tikzset{%
pics/pylon/.default=,%
pics/pylon/.style args={#1}{code={%
%% settings
\def\coordcommand{#1}% beware of leading and tailing spaces!
%
\ifdefstring{\side}{left}{% side
\pgfmathsetmacro{\sidefactor}{1}%
}{%
\ifdefstring{\side}{right}{% side
\pgfmathsetmacro{\sidefactor}{-1}%
}{%
\ifdefstring{\side}{both}{% side
}{% error message
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/constructions/side}{“left“, “right“ OR “both“ as key required}}%
}%
}%
}% end \ifdefstring{\side}
%% pylon shape
\tikzset{every path/.style={draw=\foreground,line width=0.5pt}};%
\ifdefstring{\side}{both}{% double side
\path (0,-0.5) circle [radius=0.075];% part 1
\path (0, 0.5) circle [radius=0.075];% part 2
\path (0,-0.425) -- (0, 0.425);% part 3
}{% single side
\path ($\sidefactor*(0,0.5)$) circle [radius=0.075];% part 1
\path ($\sidefactor*(0,0.425)$) -- ++($\sidefactor*(0,-0.7)$);% part 2
}%
}},% END pics/pylon/.style args={#1}
% symbology entry
symbology_pylon/.pic = {%
\maintrack (0,0) -- (6,0);%
\pylon[side=left] at (1,0);%
\pylon[side=left] at (3,0);%
\pylon[side=left] at (5,0);%
},%
}%
%
%%%%%%%%%%%%%%%
\endinput%
%
|