[mapserver-users] RE: dynamically allocated points for MAP w/ PHP

E Perik erwin at perik.nu
Wed Apr 3 16:25:13 EST 2002


Just found an earlier example:

http://mapserver.gis.umn.edu/wilma/mapserver-users/0203/msg00293.html

In general the same as previous mail

-----Original Message-----
From: Scott D Cogan [mailto:cogansco at msu.edu] 
Sent: Wednesday, April 03, 2002 10:28 PM
To: Consult IT!, E. Perik; mapserver-users at lists.gis.umn.edu
Subject: dynamically allocated points for MAP w/ PHP

what is wrong with this PHP code?  i am trying to create a layer of
points
using mapscript.  i had this working previously, then somehow deleted
the
file.  now i cant figure it out again:

if ($init==1) {
// recreate the site layer
  $shpFname = "C:\\Program Files\\Apache\\htdocs\\mich\\data\\shptest";
  $shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
  $def =  array(array("PROG_ID", "N", 5, 0));
  $dbfFile = dbase_create($shpFname . ".dbf", $def);
  createPoint( 14, 34, 111);
  createPoint( 33, 14, 222);
  createPoint( 10, 20, 333);
// done... cleanup
  $shpFile->free();
  dbase_close($dbfFile);
}


function createPoint($x, $y, $name){
    GLOBAL $shpFile, $dbfFile;
    // Create shape
    $oShp = ms_newShapeObj(MS_SHP_POINT);
    $oLine = ms_newLineObj();
    $oLine->addXY($x, $y);
    $oShp->add( $oLine );
    $shpFile->addShape($oShp);
    // Write attribute record
    dbase_add_record($dbfFile, array($name));
}




More information about the mapserver-users mailing list