[Mapserver-users] cant label streets in mapscript -- please help

Frieso ter Haseborg ter-haseborg at sf-datentechnik.de
Tue Nov 11 12:38:46 EST 2003


Hi,
 
for better debugging you perhaps should simplify your mapfile as far as
possible. Only one layer, one class, one label-object, no expressions if
not really needed, just to get rid of any possible side effects. 
 
For example a label-definition like
LABEL
    COLOR 0 0 0
END
should do for a label to be drawn.
 
But I'm not sure if the mapfile is really your problem. Next step would
be to reduce your php to the important. Try first to draw one point,
with label. Just write a testscript to only do this little thing. And
then post this snippet, if it doesn't work, not your whole application.
;-)
 
Best regards,
Frieso
 
 

-----Original Message-----
From: Murat Isik [mailto:muratisik at megatek.com.tr]
Sent: Tuesday, November 11, 2003 3:59 PM
To: Daniel Morissette
Cc: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] cant label streets in mapscript -- please
help


Good days Mr. Morissette,
 
I hope it is okey if I ask you a question about mapscript labelling and
also cc this question to maillist (as you have asked me to do before)
 
I have tried to label a streets layer in mapserver and succeeded in a
reasonbale way, names are not perfectly written but I guess it all takes
some playing around with MINSIZE and/or other values. I will do that.
Before doing that, I tried to do the same thing in my php/mapscript
which used to run the same mapfile minus the labelling part. I copied
the mapserver-mapfile's labelled street layer and replaced it into the
place of the same non-labelled street layer in mapscript-mapfile. This
is the non-labeled layer of mapscript:
 
LAYER
  NAME ERENKOY_ORNEKSOKAK_PL_polyline
  GROUP sokaklar
  TYPE line
  DATA ERENKOY_ORNEKSOKAK_PL_polyline
  STATUS ON
  CLASSITEM 'ID'
  CLASS
        EXPRESSION /./
   COLOR 66 34 249
  END
 
END

I removed the above and put this in its place (which worked with
mapserver):
 
LAYER
  NAME ERENKOY_ORNEKSOKAK_PL_polyline
  TYPE LINE
  GROUP sokaklar
  STATUS ON
  DATA ERENKOY_ORNEKSOKAK_PL_polyline
  LABELITEM "ADI"
  CLASS
    NAME "ADI"
    COLOR 161 02 110
    LABEL
      TYPE truetype
#      FORCE true
      FONT arial
      COLOR 0 0 0
        ANGLE AUTO
 #     BACKGROUNDCOLOR 250 250 250 
      POSITION AUTO
        SIZE 0
        MINSIZE 2
      SIZE 6
    END
  END
END

ADI is the coloumn in dbf which I am trying to use for labelling. After
this, mapscript stopped rendering images. Then hopelessly, I added a few
more lines to mapscript mapfile and it restarted to render maps but with
no labels. So the layer definition became:
 
LAYER
  NAME ERENKOY_ORNEKSOKAK_PL_polyline
  TYPE line
  GROUP sokaklar
  STATUS ON
  DATA ERENKOY_ORNEKSOKAK_PL_polyline
    CLASSITEM 'ID'
      CLASS
       EXPRESSION /./
      COLOR 66 34 249
      END
   # LABELCACHE OFF
    LABELITEM 'ADI'
      CLASS
   NAME 'ADI'
    #EXPRESSION /./
   COLOR 161 02 110
    LABEL
      TYPE truetype
#      FORCE true
      FONT arial
      COLOR 0 0 0
       ANGLE AUTO
  #   BACKGROUNDCOLOR 250 250 250 
      POSITION AUTO
        SIZE 0
        MINSIZE 2
      SIZE 8
   END
  END
END

After the advice of Mr. Haseborg from the maillist I added
$myMap->drawLabelCache($img) line right before
$img->saveWebImage(GIF,1,1,0) line.
Still no labels were written. This the point I am stuck at. I have read
a lot of mail archieves but found no results....
 
Is there anything else to be added to the php code or mapfile? How can I
get the labelling to work with mapscript?
 
(It is killing me to be a php-newbei and mapscript-newbei at the same
time...)
 
Thanks in advance:)
 
Have a nice day
 
Murat Isik





More information about the mapserver-users mailing list