# adapted from Tresviso (SVN) which was adapted from SpeleoPhilippines (GitHub), and bits taken from Bruce Mutton, Tarquin WJ etc. under Creative Commons Share Alike
### index of file options from _layouts.mp
## include "copy xxx" in thconfig or from within another layout
#copy custom_flowstone
#copy custom_water_blue
#copy custom_legend_large_format_5U
#copy custom_scalebar
#copy custom_continuations
#copy custom_border
#copy custom_standard_settings
#copy custom_rigging_topos
#copy custom_boxed_labels
#copy custom_entrance
#############################################################################################################################
layout custom_standard_settings
##Ideally used for large scale Plan pdfs, but can call and then override in thconfig for smaller ones
copy custom_border
copy custom_lines
copy custom_scalebar
copy custom_boxed_labels
#copy custom_continuations
#copy custom_grid
copy custom_entrance
color-legend off
symbol-colour area water [25 50 100]
symbol-colour point water-flow [25 50 100]
symbol-colour line water-flow [25 50 100]
symbol-colour area sump [10 10 100]
symbol-colour point station [100 0 0]
symbol-colour line rope [100 0 0] #make rope red
symbol-colour point rope [100 0 0] #make rope red
transparency on
grid top
symbol-set BCRA
statistics topo off # hiding individual survey members, replaced with Leck Fell Chums in the map-comment below
map-comment "Extended Elevation
Leck Fell Chums
BCRA Grade 5D (except where stated)
Data: cave-registry.org.uk/svn/NorthernEngland/Three Counties"
doc-author "Leck Fell Chums"
#doc-keywords "Goyden Pot, New Goyden Pot, Nidderdale, Thrope Pot, Manchester Hole"
#doc-subject "Goyden Cave System, Nidderdale, United Kingdom 2024"
#doc-title "Goyden Cave System, Nidderdale, United Kingdom 2024"
endlayout
#############################################################################################################################
layout custom_rigging_topos
symbol-colour line rope [100 0 0] #make rope red
symbol-colour point rope [100 0 0] #make rope red
###Adding custom styled labels at any point/linepoint
code metapost
vardef create_styled_label (expr plaintext,P,R,S,A,defaultstyle)=
save textsize, style, thetext;
string textsize;
if S = 0.5:
textsize:="\thtinysize";
elseif S = 0.7:
textsize:="\thsmallsize";
elseif S = 1.4:
textsize:="\thlargesize";
elseif S = 2:
textsize:="\thhugesize";
else: % normal is 1
textsize:="\thnormalsize";
fi;
if known ATTR_labelstyle:
style:=scantokens(ATTR_labelstyle);
else:
style:=defaultstyle;
fi;
picture thetext;
thetext:=thTEX("\thframed {" & textsize & " \thfb " & plaintext & "}");
if A = (-1,1):
p_label.ulft(thetext,P,R,style);
elseif A = (0,1):
p_label.top(thetext,P,R,style);
elseif A = (1,1):
p_label.urt(thetext,P,R,style);
elseif A = (-1,0):
p_label.lft(thetext,P,R,style);
elseif A = (1,0):
p_label.rt(thetext,P,R,style);
elseif A = (-1,-1):
p_label.llft(thetext,P,R,style);
elseif A = (0,-1):
p_label.bot(thetext,P,R,style);
elseif A = (1,-1):
p_label.lrt(thetext,P,R,style);
else:
p_label(thetext,P,R,style);
fi;
enddef;
endcode
#number within circle to use text en "point u:ropelength" "rope length" set the text of the label, use “-attr text 17” in its options.
code metapost
def p_u_ropelength (expr P,R,S,A) =
T:=identity shifted P;
U:=(0,0);
if known ATTR_text:
% approximate size (varies with proportional font)
U:=(S*u*(length ATTR_text)/4,S*u*(length ATTR_text)/4);
create_styled_label(ATTR_text,P,R,S,A,p_label_mode_passageheight);
fi;
enddef;
initsymbol("p_u_ropelength");
def p_u_ropelength_legend =
begingroup;
save ATTR_text;
string ATTR_text;
ATTR_text:="12";
p_u_ropelength((.5,.5) inscale,0,1,(0,0));
endgroup;
enddef;
endcode
#deviations
code metapost
def l_u_deviation (expr P) =
begingroup;
save ellipse;
T:=identity;
pickup PenC;
path ellipse;
ellipse:=fullcircle xscaled (.5u) yscaled (.25u) shifted (point (length P) of P);
thdraw P cutafter ellipse;
draw ellipse;
endgroup;
enddef;
initsymbol("l_u_deviation");
def l_u_deviation_legend =
l_u_deviation(((.1,.5)--(.8,.5)) inscale);
enddef;
endcode
endlayout
#############################################################################################################################
layout custom_flowstone
symbol-assign area flowstone TEST
code metapost
initsymbol ("a_flowstone_TEST");
beginpattern(pattern_flowstone_TEST);
pickup PenC;
p:=(-.25u,0){dir -60} .. {dir 60}(0.25u,0);
draw p;
draw p shifted (0.35u,0.4u);
patternxstep(0.9u);
patternystep(0.30u);
endpattern;
def a_flowstone_TEST (expr Path) =
T:=identity;
thclean Path;
thfill Path withpattern pattern_flowstone_TEST;
enddef;
endcode
endlayout
#############################################################################################################################
layout custom_entrance
#Change entrance to a theta symbol (Dave Clucas 2014)
code metapost
def p_entrance_MY (expr pos,theta,sc,al)=
U:=(.2u,.5u);
T:=identity aligned al rotated theta scaled sc shifted pos;
path p;
p = (-.3u,-.25u) -- (-.2u,-.25u){dir 135} .. (0u, .25u) .. {dir 225}(.2u,-.25u) -- (.3u,-.25u);
thdraw p withpen PenA;
thdraw unitsquare scaled u shifted (-0.5u,-0.5u) rotated 45 withpen PenD;
enddef;
initsymbol("p_entrance_MY");
let p_entrance = p_entrance_MY;
endcode
endlayout
#############################################################################################################################
layout custom_water_blue
code metapost
# define water to be light blue
def a_water (expr p) =
T:=identity;
#nice light blue - but nearly same as level colour - change back when we have control of that
thfill p withcolor (0.48, 0.84, 1.0);
# thfill p withcolor (0.0, 0.0, 1.0);
enddef;
# define sump to be dark blue
def a_sump (expr p) =
T:=identity;
thfill p withcolor (0.05, 0.0, 0.7);
enddef;
endcode
endlayout
#############################################################################################################################
layout custom_legend_large_format_5U
code metapost
% code to make the legend boxes much bigger
%
def draw_legend_box =
%make the objects in the legend boxes bigger
currentpicture := currentpicture scaled 1.7;
clip currentpicture to unitsquare scaled 5u;
drawoptions();
pickup PenB;
draw unitsquare scaled 5u ;
enddef;
%clear the background of the larger legend boxes
def clean_legend_box =
unfill unitsquare scaled 5u;
enddef;
%change the value of inscale to fill the legend boxes
def inscale =
xscaled legend_scale yscaled (0.618*legend_scale)
%xscaled legend_scale yscaled legend_scale
enddef;
endcode
endlayout
############################################################################################################################
layout custom_scalebar
#Change the scale bar to black and white bar, split into 5 and labelled
code metapost
def s_scalebar (expr l, units, txt) =
begingroup
interim warningcheck:=0;
tmpl:=l / Scale * cm * units / 2;
tmpx:=l / Scale * cm * units / 5;
tmph:=5bp; % bar height
endgroup;
pickup PenC;
#Adjusted to make lines not stick out: 0.25*u/10,0 is half thickness of PenC
draw (-tmpl+0.25*u/10,0)--(tmpl-0.25*u/10,0);
draw (tmpl-0.25*u/10,-tmph)--(-tmpl+0.25*u/10,-tmph);
p:=(0,0)--(tmpx,0)--(tmpx,-tmph)--(0,-tmph)--cycle;
for i:=-2.5 step 2 until 2:
fill p shifted (i * tmpx,0);
endfor;
begingroup
interim labeloffset:=3.5bp;
for i:=0 step (l/5) until (l-1):
tmpx:=tmpl * (i * 2 / l - 1);
label.top(thTEX(decimal (i)),(tmpx,0));
endfor;
label.top(thTEX(decimal (l) & "\thinspace" & txt),(tmpl,0));
# label.bot(thTEX("Original Scale = 1 : " & decimal (Scale*100)),(0,-tmph));
endgroup;
enddef;
endcode
endlayout
##############################################################################################################################
layout custom_continuations
#this metapost for continuations makes the text appear after the ? on the actual survey
code metapost
def p_continuation(expr pos,theta,sc,al) =
% draw default continuation symbol ie ?
p_continuation_UIS(pos,theta,sc,al);
% if text attribute is set
if known(ATTR__text) and picture(ATTR__text):
% set labeling color to light orange
push_label_fill_color(0.8, 0.8, 0.0);
% draw filled label with text next to symbol ?
p_label.urt(ATTR__text,(.5u,-.25u) transformed T,0.0,8);
% restore original labeling color
pop_label_fill_color;
fi;
enddef;
endcode
endlayout
#############################################################################################################################
layout custom_border
##this draws thicker border around pdf output
code tex-map
\framethickness=0.5mm
endcode
endlayout
#############################################################################################################################
layout custom_grid
##change default cross hair grid to grid
code metapost
def s_hgrid (expr xpos, ypos, xsize, ysize) =
pickup PenD;
if ( xpos >= -xsize ) and ( ypos >= -ysize ):
draw ( -xsize/2, 0) -- ( xsize/2, 0);
draw ( 0, -ysize/2) -- ( 0, ysize/2);
fi
enddef;
endcode
endlayout
#############################################################################################################################
layout custom_North1
####Shaded Compass Rose pointing to the magnetic North####
code metapost
def s_northarrow (expr rot) =
scale_value = 0.5;
decl := MagDecl;
T := identity;
picture tmp_pic;
tmp_pic = image (
pickup pencircle scaled 1;
thdraw fullcircle scaled 4cm;
thdraw fullcircle scaled 2.75cm;
pickup pencircle scaled .5;
thdraw fullcircle scaled 3.75cm;
for whereto=11.25 step 22.5 until 360:
thdraw dir(whereto)*2.75/2cm--dir(whereto)*3.75/2cm;
endfor;
% arrows
path halfarrow;
halfarrow = (+.3cm,.3cm)--(0,2cm)--(0,0)--cycle;
for whereto = 45 step 90 until 315:
% thfill halfarrow scaled .85 rotated whereto withcolor .30;
pickup pencircle scaled 1;
for halfarrowgrad = 1 step -.05 until 0:
thdraw ((halfarrowgrad*.3cm, halfarrowgrad*.3cm)--(0,2cm)) scaled .85 rotatedaround ((0, 0),whereto) withcolor .75halfarrowgrad;
endfor;
pickup pencircle scaled .5;
thdraw halfarrow scaled .85 rotated whereto;;
thfill halfarrow xscaled -1 scaled .85 rotated whereto withcolor white;
thdraw halfarrow xscaled -1 scaled .85 rotated whereto;;
endfor;
for whereto = 0 step 90 until 270:
% thfill halfarrow scaled 1.15 rotated whereto withcolor .30;
pickup pencircle scaled 1;
for halfarrowgrad = 1 step -.05 until 0:
thdraw ((halfarrowgrad*.3cm, halfarrowgrad*.3cm)--(0,2cm)) scaled 1.15 rotatedaround ((0, 0),whereto) withcolor .75halfarrowgrad;
endfor;
pickup pencircle scaled .5;
thdraw halfarrow scaled 1.15 rotated whereto;;
thfill halfarrow xscaled -1 scaled 1.15 rotated whereto withcolor white;
thdraw halfarrow xscaled -1 scaled 1.15 rotated whereto;;
endfor;
% central circles
thfill fullcircle scaled .56cm withcolor 1white;
pickup pencircle scaled .5;
thdraw fullcircle scaled .56cm;
thfill fullcircle scaled .3cm withcolor .30;
% characters
label.bot(thTEX("\bf{}N") scaled 1.5, (0,2.9cm));
label.lft(thTEX("\bf{}E") scaled 1.5, (2.9cm,0));
label.rt (thTEX("\bf{}W") scaled 1.5, (-2.95cm,0));
label.top(thTEX("\bf{}S") scaled 1.5, (0,-2.9cm));
% space among characters
pickup pencircle scaled .5;
thdraw (dir(45)*2cm)--(dir(45)*2.5cm);
thdraw (dir(135)*2cm)--(dir(135)*2.5cm);
thdraw (dir(225)*2cm)--(dir(225)*2.5cm);
thdraw (dir(315)*2cm)--(dir(315)*2.5cm);
);
thdraw tmp_pic scaled scale_value rotatedaround (origin, - rot);
enddef;
endcode
endlayout
###############################################################################################################################################
layout custom_lines
## dotted lines for offsets, arrow heads, hydro connection
code metapost
% Q = 0 -- no arrows
% 1 -- end
% 2 -- begin
% 3 -- both
def l_arrow (expr P, Q) =
T:=identity;
pickup PenB;
thdraw P;
p := (-.1u,-.5u)--(0,0)--(.1u,-.5u)--cycle;
% 0.25 changed to .5 and close end to get nicer arrowhead
if odd Q:
thfilldraw p rotated (angle(thdir(P,0))+90)
shifted (point 0 of P);
fi;
if Q>1:
thfilldraw p rotated (angle(thdir(P,length P))-90)
shifted (point infinity of P);
fi;
enddef;
def l_mapconnection (expr P) =
thdrawoptions(dashed dashpattern(on 1bp off 2bp on 1bp off 2bp)
scaled (3 * optical_zoom) withpen PenB);
%draw map-connection line with arrowhead at end
l_arrow(P,1); %How to double or triple arrowhead size with this call?
%draw dot at start of map-connection line
thdraw point infinity of P withpen pencircle scaled 0.3u;
%Why infinity and not 0 for dot at start of line??
%If point before arrow head, then point does not render in legend but does on map??
thdrawoptions();
enddef;
def l_wall_unsurveyed (expr P) =
#CODE TO MAKE UNSURVEYED WALL LINES LIGHT-WEIGHT AND DASHED
T:=identity;
pickup PenC;
thdraw P dashed evenly scaled (2*optical_zoom);
enddef;
endcode
code metapost
def p_camp_GFS (expr pos,r,s,al) =
U:=(.4u, .5u);
T:=identity aligned al scaled s shifted pos;
pickup PenC;
thdraw (-.5u,-.4u)--(.5u,-.4u);
pickup PenD;
thdraw (-.4u,-.4u)--(0,.5u)--(.4u,-.4u);
thfill (-.3u,-.4u)--(0,.30u)--(.3u,-.4u)--cycle;
thfill (0,.5u)--(.35u,.45u)--(.07u,.35u)--cycle;
enddef;
initsymbol("p_camp_GFS");
symbol-assign point camp GFS
def l_u_hydro (expr P) =
#Create new line for showing presumed hydrological connections on overlay (Phil Walker - 2024)
T:=identity;
pickup PenA scaled 2;
thdraw P dashed evenly scaled (4*optical_zoom);
enddef;
endcode
symbol-colour line u:hydro [48 84 100] #make 'presumed' hydrological connection lines blue
code metapost
##break lines Select this as line type “u” with “-subtype break” in its options.
##You will also need to define it with “-clip off” in its options to allow the ends of the line to show up outside the walls.
def l_u_break(expr P)=
begingroup;
save mainpath, parallel, orientation, direction, gapsize;
T:=identity;
gapsize:=u/3;
path mainpath;
%make the ends stick out beyond the passage
mainpath:=( (point 0 of P) + u * unitvector( thdir(P, 0) rotated 180 ) / 2 )
-- P --
( (point (length P) of P) + u * unitvector( thdir(P, arclength P) ) / 2 );
path parallel;
string orientation;
orientation:=if known ATTR_orientation: ATTR_orientation; else: "horizontal"; fi;
if orientation = "vertical":
direction:=if (xpart (point 0 of mainpath)) > (xpart (point (length mainpath) of mainpath)): 1; else: -1; fi;
parallel:=mainpath shifted (0, direction * gapsize);
else:
direction:=if (ypart (point 0 of mainpath)) > (ypart (point (length mainpath) of mainpath)): -1; else: 1; fi;
parallel:=mainpath shifted (direction * gapsize, 0);
fi;
if known fill_l_u_break:
thfill (mainpath -- (reverse parallel) -- cycle) withcolor fill_l_u_break;
else:
thunfill (mainpath -- (reverse parallel) -- cycle);
fi;
pickup PenC;
thdraw mainpath;
thdraw parallel;
endgroup;
enddef;
initsymbol("l_u_break");
def l_u_break_legend =
l_wall_bedrock(((0,.2) .. controls (.3,.2) and (.4,.4) .. (.6,.4)) inscale);
l_wall_bedrock(((.7,.6) .. controls (.4,.6) and (.3,.4) .. (0,.4)) inscale);
l_u_break(((.6,.4) -- (.7,.6)) inscale);
enddef;
endcode
code metapost
rgbcolor fill_l_u_break;
fill_l_u_break:=(1,1,1);
endcode
endlayout
#############################################################################################################################
layout custom_boxed_labels
##adapted from Benedikt Hallinger
# Symbol to denote assigned survey.
# Option "-attr text " shows given text; otherwise current survey is shown.
# Option "-attr bordersmooth " overrides edge smoothness (0 for sharp edges)
# Option "-attr bordermargin " overrides margin text/border
# Option "-attr basescale " overrides basic text sizing factor (default text size)
# Option "-attr fillsize " fills with page background color; s_pct is percent of bbox size
code metapost
def p_u_mappe(expr pos, theta, sc, al) =
T:=identity aligned al rotated theta scaled sc shifted pos;
begingroup;
% Basic config
bordersmooth:=4; % smoothness of box corners (0=90° edges)
bordermargin:=5.0bp; % padding border->text
basescale:=1.0; % basic scaling of default-sized text
fillsize:=-1.0; % proportional size of label filling (percent)
if known(ATTR_bordersmooth): bordersmooth:=scantokens(ATTR_bordersmooth); fi;
if known(ATTR_bordermargin): bordermargin:=scantokens(ATTR_bordermargin); fi;
if known(ATTR_basescale): basescale:=scantokens(ATTR_basescale); fi;
if known(ATTR_fillsize): fillsize:=scantokens(ATTR_fillsize); fi;
% GET LABEL TEXT:
string txt;
if known(ATTR_text):
txt := ATTR_text;
else:
txt := ATTR__survey;
fi;
% PREPARE LABEL:
lab:=thelabel(txt, (0.0,0.0));
pickup PenA; % border thickness
interim bboxmargin:=bordermargin; % padding border->text
% PREPARE BOX and DRAW BOX BACKGROUND:
% q is the box as drawed, but we fill the place first before drawing
q:=((bbox lab) smoothed bordersmooth) aligned al scaled (sc * basescale) rotated theta shifted pos;
if (fillsize <> -1.0):
% draw extending filled box around symbol
if known(MapBackground):
% from therion versions newer than 6.0.3+3551531+dev (23.11.2021) we use page background
thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale * fillsize) withcolor MapBackground;
else:
thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale * fillsize) withcolor label_fill_color;
fi;
fi;
% the following will draw the actual visible interior-filling of the box
thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale) withcolor label_fill_color;
% DRAW BOX
draw q;
% DRAW LABEL TEXT
lab:=lab aligned al;
lab:=lab scaled (sc * basescale);
lab:=lab rotated theta;
lab:=lab shifted pos;
process_label(pos, 0.001); % for some weird reason "0.0" does not work here and puts the label to map-center at scrap-rotation.
endgroup;
enddef;
endcode
#code metapost
#let a_debris = a_debris_AUT;
#let p_debris = p_debris_AUT;
#let l_wall_debris = l_wall_debris_AUT;
#let a_blocks = a_blocks_AUT;
#let p_blocks = p_blocks_AUT;
#let l_wall_blocks = l_wall_blocks_AUT;
#let p_gradient = p_slopearrow;
#let p_flowstone = p_flowstone_GB;
#end code
endlayout