Hello,
I've tried to get mapserver up and running with GDAL to display a raster
image from a php webpage but have been largely unsuccessful.  This post will
be relatively long as I describe all that I've tried to do to get it
working.  My development platform is Fedora Core 6.

First I tried all the needed packages obtained from the Fedora
repositories.  I ran in to issues with php and gd not cooperating.  So I
downloaded php from and built from source (v5.2.1).

After php was installed and operational, I tried to get mapserver running (
v4.10.1).  After I successfully built (with config options --without-pdf
--with-httpd=/usr/sbin/httpd --with-php=/usr/local/src/php-5.2.1 --with-proj
--with-gdal), I copied the php_mapscript.so file to the php modules
direcotry.  I started receiving errors along the lines of no output format
for GTIFF ( I appologies for the vagueness, but I didn't write it down and I
don't remember what it specifically was).

Next, I downloaded from source GDAL and built it (with config options
--with-png --with-jpeg --with-gif --with-libtiff --with-hdf4 --with-hdf5
--with-jasper --with-mysql).  Then I did a make install and rebuild
mapserver with the option --with-gdal=/usr/local/bin/gdal-config.  I also
copied over the new php_mapscript.  At this point, I am still unable to draw
a singular raster image with mapserver.  My exact error message is:

*Warning*: [MapServer Error]: msDrawMap(): Failed to draw layer named
'TestLayer'. in */var/www/html/ryan/test.php* on line *9*

*Warning*: [MapServer Error]: msDrawRaster(): (/usr/share/images/test.png)
in */var/www/html/ryan/test.php* on line *9*

I've tried an older version of GDAL (1.4.0) with the same results.  gdalinfo
correctly opens and displays info on my image file, resolution and type
(png).

Here is my php file:
<?php

$map_path="/var/www/html/ryan/map/";

dl('php_mapscript.so');

$map = ms_newMapObj($map_path."test.map");
//$map->selectOutputFormat("image/png");
$image=$map->draw();
$image_url=$image->saveWebImage();

?>

<HTML>
   <HEAD>
       <TITLE>Test</TITLE>
   </HEAD>
   <BODY>
       <IMG SRC=<?php echo $image_url; ?> >
   </BODY>
</HTML>

and here is my mapfile:
Map
   Name TESTMAPFILE
   Status On
   Imagetype PNG
   Size 800 600
   Extent -82 40 -80 42 #example location
   Units dd

   Web
       Imagepath "/var/www/html/ryan/map/"
       Imageurl "/ryan/map/"
   End

   Layer
       Name "TestLayer"
       Type Raster
       Status On
       Data "/usr/share/images/test.png"
   End

   OutputFormat
       Name png
       Driver "GD/PNG"
       Mimetype "image/png"
       ImageMode RGB
       Extension "png"
   End

End

I am at the end of my rope trying to get this to work.  If anyone can
provide any direction, I would greatly appreciate any insight.

Thanks,
Ryan

Reply via email to