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

Scott D Cogan cogansco at msu.edu
Wed Apr 3 12:27:50 PST 2002


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