Opened 22 years ago

Closed 21 years ago

Last modified 21 years ago

#245 closed defect (fixed)

Undefined class->label font size handling from php inconsistent with .map file

Reported by: bear@… Owned by: dmorissette
Priority: high Milestone:
Component: MapScript-PHP Version: 4.0
Severity: normal Keywords:
Cc:

Description

If a LABEL from an annotation layer in a .map file has no SIZE attribute, the
annotations will still be rendered with a very small font (size 1?). On the
other hand, if the layer/class is created from php_mapscript and the
$class->label->size is not defined, the annotations will not be rendered at all.

LAYER
  NAME "tekstparc"
  DATA tekstparc
  MAXSCALE 5000
  STATUS DEFAULT
  TYPE ANNOTATION
  LABELITEM "CAT_ID"
  CLASSITEM "CAT_ID"
  CLASS
    COLOR -1 -1 -1
    LABEL
      COLOR 40 40 80
      SHADOWCOLOR -1 38 38
      TYPE TRUETYPE
      ANTIALIAS TRUE
      FONT verdana
#      SIZE 10
      POSITION CC
      PARTIALS TRUE
      BUFFER 2
    END
  END
END

$lay = ms_newLayerObj($map);
$lay->set("data", "tekstulice");
$lay->set('type', MS_LAYER_ANNOTATION);
$lay->set('maxscale',5000);
$lay->set('status', MS_ON);
$lay->set('labelitem', "TEXTSTRING");
$lay->set('classitem', "TEXT_ANGLE");
$lay->set('labelangleitem', "TEXT_ANGLE");
$lclass = ms_newClassObj($lay);
$lclass->label->set('shadowsizex', 1);
$lclass->label->set('shadowsizey', 1);
$lclass->label->set('angle', 45.0);
$lclass->label->set('type', MS_TRUETYPE);
$lclass->label->set('font', "verdana");
#$lclass->label->set('size', 10);        # bez ovoga NE RADI !
$lclass->label->set('antialias', MS_TRUE);
$lclass->label->set('partials', MS_FALSE);
$lclass->label->set('buffer', 2);
$lclass->label->set('position', MS_UR);

Change History (3)

comment:1 by assefa, 21 years ago

The explanation to this is pretty simple :

 when reading the map file, if a class has a Label object, after It has been
initialized (using the initClass function), the size and sizescaled are reset to
a default value ( class->label.sizescaled = class->label.size = MS_MEDIUM;). In
initClass the values are set to -1

  php mapscript uses also the initClass function and the values are
set by default to -1 but there is no specific setting of the size.

 I am not sure why the default values for the size are -1 and not MS_MEDIUM. I
am not going to change that since It may have other side effects.
 What I will do is in the php mapscript, if the set method is called on the
labelobj, I will reset the size value to MS_MEDIUM (if it is equal to -1). 

 If no objection to that I will commit the changes.

comment:2 by assefa, 21 years ago

Resolution: fixed
Status: newclosed
Fixed as described in #1.

comment:3 by dmorissette, 21 years ago

Cc: steve.lime@… added
Unfortunately this doesn't fix the problem for SWIG-based MapScript.  

Steve: what would you think of setting class->label.size = MS_MEDIUM by default 
in initClass() since this is what ends up happening anyway when reading a 
mapfile.  Right now there is a comment that says 'no default' in the code when 
the value is set to -1.
Note: See TracTickets for help on using tickets.