[mapserver-users] inconsistent PHP/Mapscript non-object error
Mark Giesbrecht
mgiesbrecht at geoarctic.com
Wed Apr 3 12:46:14 PST 2002
Hi All,
My setup:
IIS 5.0
PHP 4.06 as cgi
PHP/Mapscript
I've come across the wierdest of problems with a php script on two
different IIS 5.0 machines. In my script, with no parameters passed, it
displays a simple map. I then flag labels on, zoom to different
extents, and the map still displays (on both machines). The problem
lies with one machine, where I try to turn specific layers on with a php
isset/switch combination, the script bails with an error with:
Call to a member function on a non-object in
C:\MYWEB\newsite\gedcomap\mapscript\postmap.php on line 164
My line 164 is:
$img->saveImage('',MS_GIF, 1, 1, 75);
Now, it is obvious in the error that the $img object no longer exists,
but for the life of me can't explain why it works on one machine, and
not the other.
Any thoughts, ideas?
<?php
header("Content-type: image/gif");
// Load MapScript module.
dl("php_mapscript_35.dll");
//
// Load MapServer .map file
//
$map = ms_newMapObj("../locationsprj.map");
//Determine zoom extents
if (isset($zoom))
{
switch ($zoom)
{
case "ALL": //World extents
$map->setextent( -20000000.000, -8449750.000, 19900000.000,
16451325.000);
break;
case "WCANADA":
$map->setextent( -15604189.866491, 5728697.158015,-10734609.241998,
10005187.834654);
break;
case "ECANADA":
$map->setextent( -11447573.326271, 3978110.696705, -4032667.8763,
10005187.834654);
break;
case "NCANADA":
$map->setextent( -16519817.840106, 7203994.832244, -1429834.819113,
15456095.305808);
break;
case "NAMERICA":
$map->setextent( -19382823.018345, -188395.722636, -4553012.118403,
12835220.260005);
break;
case "SAMERICA":
$map->setextent( -14217739.307468, -8744055.857217, 612071.592474,
4279560.125423);
break;
case "ASIA":
$map->setextent( 7441033.846743, 356826.088735, 16937316.265127,
8696510.007443);
break;
case "EUROPE":
$map->setextent( -1130748.06457, 4116806.988907, 3292177.993307,
11401043.334607);
break;
case "AFRICA":
$map->setextent( -2407541.653016, -3764271.132892, 7220725.892471,
4691322.801285);
break;
case "SEASIA":
$map->setextent( 10536970.90259, -7490309.75465, 20813769.684129,
1534827.636829);
break;
case "MEAST":
$map->setextent( 3382237.573671, 1250936.253511, 7414905.449971,
5092445.862826);
break;
}
} else {
//to the whole world
$map->setextent( -20000000.000, -8449750.000, 19900000.000,
16451325.000);
}
if (isset($LABELSON))
{
$cntryLayer = $map->getLayerByName("country");
switch($LABELSON)
{
case "true":
$cntryLayer->set("labelitem", "CNTRY_NAME");
break;
case "false":
$cntryLayer->set("labelitem", "NOLABEL");
break;
}
}
if (isset($GEDCO))
{
$jobLayer = $map->getLayerByName("jobs");
$jobLayer->set("classitem", "TYPE");
switch ($GEDCO)
{
case "OIL":
$clsjobLayer = $jobLayer->getClass(0);
$jobLayer->set("status", "1");
$clsjobLayer->setexpression(" 'O' ");
$clsjobLayer->set("color", $map->addcolor(255, 173, 0));
break;
case "MINING":
$clsjobLayer = $jobLayer->getClass(0);
$jobLayer->set("status", "1");
$clsjobLayer->setexpression(" 'X' ");
break;
//Create a new class object, display both O and X
case "OIL-MINING":
$clsjobLayer = $jobLayer->getClass(0);
$jobLayer->set("status", "1");
$clsjobLayer->setexpression(" 'X' ");
//Mining = X; Oil = O;
$clsMiningLayer = ms_newClassObj($jobLayer);
$clsMiningLayer->setexpression(" 'O' ");
$clsMiningLayer->set("color", $map->addcolor(255, 173, 0));
$clsMiningLayer->set("size", 10);
$clsMiningLayer->set("symbol", 2);
$clsMiningLayer->set("name", "");
$clsMiningLayer->set("outlinecolor", $map->addcolor(128, 128, 128));
break;
}
}
if (isset($SIS))
{
$omniLayer = $map->getLayerByName("sis");
$omniLayer->set("classitem", "PROG");
switch ($SIS)
{
case "OMNI":
$omniLayer->set("status", "1");
$clsomniLayer = $omniLayer->getClass(0);
$clsomniLayer->setexpression(" 'OMNI' ");
break;
case "VISTAWIN":
$omniLayer->set("status", "1");
$clsomniLayer = $omniLayer->getClass(0);
$clsomniLayer->setexpression(" 'VISTAWIN' ");
$clsomniLayer->set("color", $map->addcolor(128, 0, 128));
break;
//Same as above; create a new class object (1), and display both OMNI
and VISTAWIN, with
//VISTAWIN as a new colour
case "OMNI-VISTAWIN":
//Show the regular layer
$clsomniLayer = $omniLayer->getClass(0);
$clsomniLayer->setexpression(" 'OMNI' ");
$omniLayer->set("status", "1");
//Create new class
$clsVistaLayer = ms_newClassObj($omniLayer);
$clsVistaLayer->setexpression(" 'VISTAWIN' ");
$clsVistaLayer->set("color", $map->addcolor(128, 0, 128));
$clsVistaLayer->set("size", 10);
$clsVistaLayer->set("symbol", 2);
$clsVistaLayer->set("name", "");
$clsVistaLayer->set("outlinecolor", $map->addcolor(128, 128, 128));
break;
}
}
//Finalize the output
$img = $map->draw();
$img->saveImage('',MS_GIF, 1, 1, 75);
?>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mgiesbrecht.vcf
Type: text/x-vcard
Size: 346 bytes
Desc: Card for Mark Giesbrecht
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020403/bc8e7076/attachment.vcf>
More information about the MapServer-users
mailing list