[Mapserver-users] Problem with Perl Mapscript

AMC Story s9646183 at sms.ed.ac.uk
Thu Jul 3 07:41:52 EDT 2003


Hi everyone,

Following my question about using JavaScript/MapScript to develop the standard 
MapServer interface, I've now decided to try to use both, and have got the Perl 
MapScript module working on our apache server.

My problem is that most of the documentation and examples are for PHP 
MapScript.  Having only a list of constructors/methods etc for each object type 
is helpful to a point, but this doesn't tell me how I should be putting them 
together to get something to actually work!  I've been trying to convert the 
PHP MapScript by Example HOWTO into perl, using Steve Lime's mapquakes.pl as a 
guide.

My first problem is that perl mapscript doesn't seem to have a direct 
equivalent of the saveWebImage method.  Is this correct?  In the absence of 
such a method, I've been trying to use the saveImage method, but here I seem to 
be running into problems.  If you look at the way I've called the method (see 
code below), then maybe you could suggest what I'm doing wrong.  

In the first case (ie. using mapscript::msSaveImage(...)), I get the error 
message "Type error in argument 1 of msSaveImage. Expected _p_gdImagePtr..." 
when I run the program at the command line.  In the second case, using $image-
>saveImage(..), I get the following usage message "Usage: imageObj_saveImage
(self,filename,type,transparent,interlace,quality);".  This has confused me 
because this isn't the argument list given in the documentation.

If anyone has some simple, step by step examples of how to build up 
applications using Perl MapScript I'd be really interested in having a look.

Many thanks,
Ali 



#!/usr/local/bin/perl -w
#
#playing around with mapscript
#

#use mapscript;
use CGI qw(:standard);
use mapscript;

$cgi = new CGI;

$map_file = "/usr/local/apache/local-bin/s9646183/mapscript/quakes.map";
$image_path = "/usr/local/apache/htdocs/tmp/";
$image_url = "/tmp/";
$image_id = $$ . time() . ".png";

$map = new mapscript::mapObj($map_file);
$image = $map->prepareImage();
$layer = $map->getLayerByName('countries');
$layer->draw($map, $image);
mapscript::msSaveImage($image, $image_path.$image_id, $map->{imagetype}, $map->
{transparent}, $map->{interlace}, $map->{imagequality});
#$image->saveImage($image, $image_path.$image_id, $mapscript::MS_PNG, $map->
{transparent}, $map->{interlace}, $map->{imagequality});

print $cgi->header();
print $cgi->start_html(-title=>'Map 1: Perl Mapscript Test');

print "<p>This is just a test</p>";
print "<center><input type=\"image\" name=\"map\" src=\"". $image_url . 
$image_id ."\"><br>";

print $cgi->end_html();



More information about the mapserver-users mailing list