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

Daniel Morissette morissette at dmsolutions.ca
Tue Nov 11 12:40:03 EST 2003


Murat Isik wrote:
>  
> 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 saw your multiple posts to the list and also noticed the small number 
of replies.  This is often an indication that your question is not clear 
enough for someone to help: either lacking essential information, poorly 
formatted, or just contains too much information to a point where it 
becomes confusing.  You need to help the readers help you: well 
formatted questions most of the time get resolved the same day on this list.

First we need to know:

- Which version of MapServer/MapScript are you using
- I presume you're on Windows and if not then please specify your OS.

It may also help to know:

- If you got a pre-built binary then where did you download it from?
- If you compiled yourself then which options did you enable?  (output 
of mapserv -v or configure options)
- Describe your PHP config: does your PHP have GD/Freetype enabled and 
if yes please verify that the PHP GD and freetype are of the same 
version as the ones used by MapScript

>  
> 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.

Great, so we know we have a working mapfile to start from ...

> 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. 

So MapScript works fine when the labelling is not enabled... also good 
to know.


> 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:
>  

<snipped>

> ADI is the coloumn in dbf which I am trying to use for labelling. After 
> this, mapscript stopped rendering images. 

"stopped rendering images"? Your computer didn't go on strike did it? 
;)  So what did it do instead?  Did it produce a blank image? Did it 
produce any errors? Was there any error/warning on the error_log or if 
you do a view source? Please describe what you got and what you didn't get.

This is very important... without a description of the incorrect 
behavior nobody can help.


> 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:
>  

Which lines did you add? Readers offer you 30 seconds of their time and 
don't have time to compare a 30-lines layer definition to figure which 
line has changed.

> After the advice of Mr. Haseborg from the maillist I added 
> $myMap->drawLabelCache($img) line right before 
> $img->saveWebImage(GIF,1,1,0) line.

Which version of MapServer/MapScript are you using again?
The line $img->saveWebImage(GIF,1,1,0) may not work in any version of 
MapServer/MapScript:

In version 3.6.x it should be:
   $img->saveWebImage(MS_GIF,1,1,0);
In version 4.x the format arguments are gone, instead it uses the format 
specified in the mapfile (of via selectOutputformat()):
   $img->saveWebImage();


> 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?
>  

Normally a mapfile that works in mapserv will also work in php_mapscript 
as is... without any modification.  If it doesn't work then it's either 
a configuration issue on your server (conflict with PHP's GD/freetype 
for instance) or it's something that you do wrong in your script.  The 
best way to identify the source of the problem is to test with a 5-lines 
script.

Does the following script work for you with the mapfile that contains 
all the label stuff and that used to work with mapserv?

<?php
    dl("php_mapscript.so");
    $map =  ms_newMapObj("/path/to/yourmapfile.map");
    $img = $map->draw();
    $url = $map->saveWebImage();
    echo <img src=\"$url\">;
?>



Daniel
-- 
------------------------------------------------------------
  Daniel Morissette               morissette at dmsolutions.ca
  DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------




More information about the mapserver-users mailing list