On Dec 22, 2007 7:59 PM, Xavier Pennec <Xavier.Pennec at sophia.inria.fr> wrote:
> As I want to be able not to display the section lines AND the their
> numbers when I inlcude that survey into the larger map, I thought that
> adding a user attribute to the section line would be the right way.
>
> Thus, I used a user attribute called label in my th2 file:
>    line section -reverse on -direction both -attr label "one"
>      312.0 327.0
>      334.09 327.0 396.0 327.0 425.0 327.0
>    endline
>
> and I redefined the section line metapost command into in my layout:
> The file NaduelRD5_plan.pdf is an example on what it gives. With that
> solution, I have two problems:
> - the first one is that is I change     -attr label "one"    with
> -attr label "1"     then metapost crashes because ATTR_label is
> intrepreted in that case as a known numeric and not as a string.

Yes, that is intended behaviour. You sometimes need to evaluate
numerical attibutes.

Try the following:

     if known ATTR_label:
       old_lo := labeloffset;
       labeloffset := 2 mm;
       push_label_fill_color(0.7,0.7,0.7);
       p_label.bot(if numeric ATTR_label: decimal ATTR_label else:
ATTR_label fi, (point pnt of Q), angle(thdir(Q,pnt)), 8);
       labeloffset := old_lo;
       pop_label_fill_color;
     fi;

The conversion of numeric to string argument is "decimal ATTR_label"

The example also shows how to change alignment, offset and rotation of
the label.

Unfortunately the rotation (currently) does not work for circled
labels (type 5 in your example) so i used type 8 for a label with
coloured background.

Martin

Reply via email to