encoding  utf-8
source dvojzavrt_po_objave.th
select rez@dvojzavrt_po_objave

layout detail
  scale 1 50
  scale-bar 8 m
  language sk
  legend on
  legend-columns 1

  # Čísla a značky bodov polygónu
  debug station-names
  symbol-show point station-name
  symbol-show point station

  # Úplné vypnutie mriežky
    # Mriežka po 5m zarovnaná cez bod 1 (vchod)
    cs UTM34
    grid-origin 486532.23 5390264.22 811.187 m
    grid bottom
    grid-size 5 5 5 m

  # Farba stien a polygónu
  color map-fg [95]
  symbol-color line survey [75 65 45]

  # Priradenie symbolov
  symbol-assign point entrance ASF
  symbol-assign line wall:blocks AUT 
  symbol-assign area sand AUT 
  symbol-assign area clay AUT 
  symbol-hide line survey:surface  
  symbol-assign area blocks AUT
  symbol-assign area sand AUT
  symbol-assign point pillar AUT
  symbol-assign point stalagmite AUT
  symbol-assign point stalactite AUT

  symbol-color line rock-border 30
  symbol-color line rock-edge 30
  symbol-color line border 50
  symbol-color line wall:debris 30
  symbol-color area clay 50
  symbol-color area pebbles 50
  symbol-color area sand 60
  symbol-color area flowstone 50
  symbol-color area moonmilk 50
  symbol-color line wall:underlying 50
  symbol-color line u:chodnik 70
  symbol-color point wall-altitude 60
  symbol-color point altitude 60
  symbol-color area u:odtazene 50

  # Metapost rozšírenia a skrášlenia
  code metapost
    # --- Symbol vchodu: Omega ---
    def p_entrance (expr pos,theta,sc,al) =
      U := (0.4u, 0.4u);
      T := identity aligned al rotated theta scaled sc shifted pos;
      pickup PenA;
      path p;
      p := (-0.35u, -0.25u) -- (-0.2u, -0.25u){dir 135} .. (0, 0.25u) .. {dir 225}(0.2u, -0.25u) -- (0.35u, -0.25u);
      thdraw p;
    enddef;

    def p_entrance_legend =
      pickup PenA;
      path p;
      p := (-0.35u, -0.25u) -- (-0.2u, -0.25u){dir 135} .. (0, 0.25u) .. {dir 225}(0.2u, -0.25u) -- (0.35u, -0.25u);
      draw p shifted ((0.5, 0.5) inscale);
    enddef;

    let p_entrance_ASF = p_entrance;
    let p_entrance_ASF_legend = p_entrance_legend;

    # --- Štandardná horizontálna grafická mierka (8m s 1m rozlíšením) ---
    def s_scalebar (expr l, units, txt) =
      begingroup
        interim warningcheck:=0;
        tmpl:=l / Scale * cm * units / 2;
        tmpx:=l / Scale * cm * units / 8;
        tmph:=5bp; % výška mierky
      endgroup;
      pickup PenC;
      draw (-tmpl,0)--(tmpl,0)--(tmpl,-tmph)--(-tmpl,-tmph)--cycle;
      p:=(0,0)--(tmpx,0)--(tmpx,-tmph)--(0,-tmph)--cycle;
      for i:=-4 step 2 until 3:
        fill p shifted (i * tmpx,0);
      endfor;
      begingroup
        interim labeloffset:=3.5bp;
        for i:=0 step 1 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("Mierka 1 : " & decimal round(Scale*100)),(0,-tmph));
      endgroup;
    enddef;

    # --- Smerovka na sever (Shaded Compass Rose - Juraj Halama) ---
    def s_northarrow (expr rot) =
      scale_value = 0.42;
      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:
            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:
            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;

    # --- Symboly pohľadu: symbol_plan a symbol_extend ---
    def p_u_symbol_plan (expr pos,theta,sc,al) =
      U := (-3.25u, 3.25u);
      T := identity aligned al rotated theta scaled sc shifted pos;
      pickup PenB;
      q := ((-3.26u, -.95u) -- (1.74u, -.95u) -- (2.8u, .82u) -- (-1.49u, .82u) -- cycle);
      thfill q withcolor .85;
      thdraw q;
      q := ((-.175u, .5u) -- (0u, 0u) -- (.175u, .5u) .. (0u, .45u) .. cycle);
      thfill q withcolor .5green;
      thdraw q withcolor .5green;
      thdraw (0u, 0u) -- (0u, 2.31u) withcolor .5green; 
    enddef;

    def p_u_symbol_extend (expr pos,theta,sc,al) =
      U := (-2.5u, 2.5u);
      T := identity aligned al rotated theta scaled sc shifted pos;
      pickup PenB;
      q := ((-2.346u, -2.480u) -- (-.48u, -2.116u) -- (-.48u, 1.573u) -- (-2.346u, 1.354u) -- cycle);
      thfill q withcolor .85;
      q := ((-1.551u, -2.878u) -- (1.438u, -.766u) -- (1.438u, 2.388u) -- (-1.551u, 1.118u) -- cycle);
      thfill q withcolor .75;
      thdraw q;
      thdraw (-.48u, -2.116u) -- (-.48u, 1.573u) dashed evenly;
      q := ((.446u, -1.461u) -- (2.120u, -1.094u) -- (2.120u, 2.184u) -- (.446u, 1.965u) -- cycle);
      thfill q withcolor .85;
      thdraw (.446u, -1.461u) -- (.446u, 1.965u) dashed evenly;
      q := ((-.175u, .5u) -- (0u, 0u) -- (.175u, .5u) .. (0u, .45u) .. cycle) rotated -90;
      thfill q withcolor .5green;
      thdraw q withcolor .5green;
      thdraw (0u, 0u) -- (2.31u, 0u) withcolor .5green; 
    enddef;

    # --- Postavičky jaskyniarov v mierke (Walking & Climbing caver) ---
    picture u_man_c_pic;
    u_man_c_pic := image (
      draw (0cm, -0cm) -- (-8cm, 27cm) -- (-36cm, 55cm) -- (-50cm, 99cm) withpen pencircle scaled 16cm;
      draw (27cm, 48cm) -- (0, 64cm) -- (-29cm, 61cm) -- (-38cm, 102cm) withpen pencircle scaled 16cm;
      draw (-65cm, 48cm) -- (-75cm, 75cm) -- (-53cm, 106cm) -- (0, 106cm) withpen pencircle scaled 14cm;
      draw (-44cm, 130cm) withpen pencircle scaled 27cm withcolor black;
    ) shifted (20cm, -67cm);

    picture u_man_w_pic;
    u_man_w_pic := image (
      draw (0, 0) -- (7.5cm, 36cm) -- (0cm, 69cm) -- (9cm, 99cm) withpen pencircle scaled 16cm;
      draw (42cm, 9cm) -- (37.5cm, 42cm) -- (13.5cm, 69cm) -- (30cm, 102cm) withpen pencircle scaled 16cm;
      draw (21.5cm, 100.5cm) -- (6.6cm, 69cm) withpen pencircle scaled 16cm;
      draw (-24cm, 75cm) -- (-13.5cm, 102cm) -- (9cm, 112.5cm) -- (30cm, 108cm) -- (51cm, 87cm) -- (75cm, 93cm) withpen pencircle scaled 14cm;
      draw (30cm, 132cm) withpen pencircle scaled 27cm withcolor black;
    ) shifted (-20cm, -70cm);

    def p_u_man_c (expr P, R, S, A) =
      U := (60cm, 85cm) scaled (0.01 / Scale);
      T := identity aligned A rotated R scaled S shifted P;
      thdraw u_man_c_pic scaled (0.01 / Scale);
    enddef;

    def p_u_man_w (expr P, R, S, A) =
      U := (60cm, 80cm) scaled (0.01 / Scale);
      T := identity aligned A rotated R scaled S shifted P;
      thdraw u_man_w_pic scaled (0.01 / Scale);
    enddef;

    # --- Umelá stena / výstuž ---
    def l_wall_artificial (expr P) =
      T:=identity;
      pickup PenA;
      thdraw P withcolor (0.1, 0.3, 0.6);
    enddef;
  endcode

  # --- TeX rozloženie: Hlavička hore so scalebarom (max 8m, krok 1m), Legenda vľavo ---
  code tex-map
    \overfullrule=0pt\relax
    \legendwidth=5.2cm
    \legendcolumns=1

    % 1. HLAVIČKA NAD MAPOU (Logo, text a smerovka, pod nimi 8m grafická mierka s 1m krokom)
    \def\mapheader{%
      \vbox{\hsize=\hsize
        \hbox to \hsize{%
          \vbox to 3.2cm{\vfill\hbox{\pdfximage width 3.6cm {C:/Users/A1497335/Downloads/Dvojzavrt_po_objave/Dvojzavrt_po_objave/logo_cassovia.jpg}\pdfrefximage\pdflastximage}\vfill}\hfil
          \vbox to 3.2cm{\vfill\vbox{\hsize=0.52\hsize
            {\leftskip=0pt plus 1fil \rightskip=0pt plus 1fil \parfillskip=0pt
              {\size[24]\bf DVOJZÁVRT\endgraf}
              \vskip 3pt
              {\size[12]\rm Zádielska planina / Slovenský kras\endgraf}
              \vskip 3pt
              {\size[10.5]\it Speleoklub Cassovia\endgraf}
              \vskip 6pt
              {\size[9]\rm Zameral: {\bf Ladislav Gagy} \qquad Kreslil: {\bf Michal Danko}\endgraf}
              \vskip 2pt
              {\size[8.5]\rm Dátum merania: 16. 8. 2026 \qquad Dĺžka: {\bf 37 m} \qquad Hĺbka: {\bf 22 m}\endgraf}
            }
          }\vfill}\hfil
          \vbox to 3.2cm{\vfill\hbox{\northarrow}\vfill}%
        }
        \vskip 0.4cm
        \centerline{\scalebar}
        \vskip 0.8cm
      }
    }

    % 2. ĽAVÝ STĹPEC (1-stĺpcová legenda značiek)
    \def\mapleftcol{%
      \vtop{\hsize=\legendwidth
        {\the\legendtextsectionsize\the\legendtitle}\bigskip
        \insertlegend
      }
    }

    % 3. ROZLOŽENIE NA LISTE
    \def\maplayout{
      \legendbox{50}{100}{S}{\mapheader}
      \legendbox{22}{95}{NE}{\mapleftcol}
    }
  endcode

endlayout    

text sk "line wall:ice" "plastová rúra (spevnenie)"
text sk "point u:symbol_plan" ""
text sk "point u:symbol_extend" ""
text sk "point u:man_w" "postava (kráčajúca)"
text sk "point u:man_c" "postava (lezecká)"

# Export rez s 1-stĺpcovou ľavou legendou a 8m mierkou
export map -layout detail -projection [elevation 012] -o rez012c_1col.pdf
