[mapserver-users] php mapscript (fwd)
teb
teb at mallit.fr.umn.edu
Wed Aug 22 08:33:00 PDT 2001
------------- Begin Forwarded Message -------------
From: "Aaron Hunt" <hunt at zedxinc.com>
To: <mapserver-info at lists.gis.umn.edu>
Subject: php mapscript
Date: Tue, 21 Aug 2001 16:28:05 -0400
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
I am trying to create a php/mapscript program.
I first create a polygon shape file. Then I apply the shape file
to a map object and display it.
When I do this The new shape file does not display. If I re-run
the program with out rewriting the shape file and using the old
on, it works.
How can I get this to work?
Thank you for any help
Aaron
Ps. Here is the code I am using
$dbname = "/tmp/shape";
$shpFname = "/tmp/shape";
$shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POLYGON);
$dbfFile = dbase_create( $dbname.".dbf", array( array("File",
"C", 50) ));
$lat = array();
$lon = array();
$oShp = ms_newShapeObj(MS_SHAPE_POLYGON);
$oLine = ms_newLineObj();
//Used to parse data from xml and run the data ($lat:$lon)
$fp = popen ("perl t.pl /home/httpd/db/76.xml boundary_20010820",
"r");
while(!feof ($fp))
{
$buffer = fgets($fp , 4096);
chop($buffer);
list ($lat1, $lon1) = split (':', $buffer);
if ($lat1 != "")
{
$oLine->addXY($lon1, $lat1);
}
array_push ($lat, $lat1);
array_push ($lon, $lon1);
}
$oShp->add( $oLine );
$shpFile->addShape($oShp);
dbase_add_record($dbfFile, array("76"));
pclose;
$shpFile->free();
dbase_close($dbfFile);
sort($lat);
sort($lon);
$maxx = $lon[1];
$miny = $lat[1];
$minx = $lon[count($lon) -1];
$maxy = $lat[count($lat) -1];
$map = ms_newMapObj("php.map");
$map->setExtent($minx, $miny, $maxx, $maxy);
$layer = $map->getlayerbyname(field);
$layer->set("data","/tmp/shape");
$img = $map->draw();
$url = $img->saveWebImage(1, 0, 0, 65);
printf("<IMG SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $map->width,
$map->height);
------------- End Forwarded Message -------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20010822/2ff764c1/attachment.htm>
More information about the MapServer-users
mailing list