|Previous| |Contents|

Using user defined symbol types

If therion does not offer any appropriate symbol for the feature you want to draw to the map, you can use user defined symbol type (type u, valid for point, line and area objects).

The syntax is very simple. Assume you want to create "bat" point, line and area. You just use u:bat as a type (bat is in fact subtype) of u type. So your code will be like this:

point 555.0 480.0 u:bat

or

line u:bat

or

area u:bat

When you export map without defining the symbols in MetaPost, user defined symbols are highlighted in red without any graphical representation.

To display them correctly you need to define symbols for them in MetaPost languge the same way as ordinary symbols are usually redefined.

Firstly point symbol. In the

code metapost

section of your layout define point u:bat symbol like this

def p_u_bat(expr pos, theta, sc, al) = 
  T := identity shifted pos;
  thfill (bat_path scaled 2.0) withcolor black;
enddef;

similarly the line u:bat symbol

def l_u_bat(expr P) =
  T:=identity;
  cas := 0;
  dlzka := arclength P;
  mojkrok:=adjust_step(dlzka, 1.0u);
  pickup PenD;
  forever:
    t := arctime cas of P;
    thfill bat_path scaled 0.5 shifted (point t of P) withcolor black;
    cas := cas + mojkrok;
    exitif cas > dlzka + (mojkrok / 3); % for rounding errors
  endfor;
enddef;

and finally the area u:bat symbol (pattern in this case)

% bat pattern
beginpattern(pattern_bat);
    fill bat_path withcolor black;
endpattern;

% bat area symbol
def a_u_bat (expr Path) =
  T:=identity;
  thclean Path;
  thfill Path withpattern pattern_bat;
enddef;

These symbols will be included also in the legend. To change the way how they are drawn there just define appropriate macro. Its name should be symbol macro name with _legend suffix.

def l_u_bat_legend = 
  l_u_bat(((.2,.2) -- (.8,.8)) inscale) 
enddef;

Finally, add description of your new symbols that will be shown in the legend using text command anywhere in the configuration file.

text en "point u:bat" "bat"
text en "line u:bat" "bat path"
text en "area u:bat" "lot of bats"

After all these definitions you receive bat point, line and area symbols with proper graphical representation and legend boxes.


|Previous| |Contents|