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

Murat Isik muratisik at megatek.com.tr
Tue Nov 11 17:08:30 EST 2003


Hello,
Thanks for answering:)
I am sorry for multiple posts, maybe I paniced a little. I hope you and the
list accept my apoligies....
I am running mapserver/mapscript on RedHat 9.0. I was no more than a linux
newbei when I started the mapserver study so I chose to install mapserver
and mapscript by rpms:

mapserver-3.6.0-4
php-mapscript-3.6.0-4

I found the rpms from major rpm download sites, like rpmfind and easyrpms.
My mapserv -v output is:

MapServer version 3.6.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=TTF INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=SHAPEFILE

My phpinfo_mapscript output is:

MapScript Version ($Revision: 1.104 $ $Date: 2002/04/24 20:37:32 $)
MapServer version 3.6.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=TTF INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=SHAPEFILE

As for the "stopped rendering", the web page only has the part that is until
the start of the php code, like the title or the logo gif. The source of the
web page only has the page title and the url of the page logo. When I check
the temporary folder into which images are written, I see no images are
produced. On the web page, there were no error messages. Unfortunately, I
dont know how to use the error_log :(

The lines I added to the mapfile for mapscript choose the streets by their
value in the second column which is ID (numeric) and I choose all by /./

CLASSITEM 'ID'
  CLASS
       EXPRESSION /./
  COLOR 66 34 249
  END

I applied your test with the following php code:

<HEAD>
<TITLE>TEST</TITLE>
</HEAD>
<CENTER>
<?php
    dl("php_mapscript.so");
    $map =  ms_newMapObj("demonew.map");
    $img = $map->draw();
  #  $map->drawLabelCache($img);
    $url = $img->saveWebImage(GIF,1,1,0);

?>
<INPUT TYPE="image" SRC="<?php echo $url; ?>">

Once again, the web page displays no images, no images produced in temp
directory and web page source ends at <CENTER>. Also tried it with
drawLabelCache on, getting the same result :(

Have a nice day...

Murat Isik





----- Original Message -----
From: "Daniel Morissette" <morissette at dmsolutions.ca>
To: "Murat Isik" <muratisik at megatek.com.tr>
Cc: <mapserver-users at lists.gis.umn.edu>
Sent: Tuesday, November 11, 2003 7:40 PM
Subject: Re: [Mapserver-users] cant label streets in mapscript -- please
help


> 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