test_writeshape.phtml

来自「Welcome to MS4W, the no fuss installer f」· PHTML 代码 · 共 57 行

PHTML
57
字号
<?//// This example script shows how MapScript and the PHP DBase module// can be used to create new Shapefile datasets.//// The optional DBase module must be loaded for this to work://  - On Windows, use dl("php3_dbase.dll")//  - On Unix, configure PHP with the --with-dbase switch and recompile it.//// Load MapScriptdl("php_mapscript.so");//----------------------------------------------------------// produce shapefile//----------------------------------------------------------function createPoint( $x, $y, $programId ){    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($programId));}$shpFname = "/tmp/shptest";$shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POINT);$dbfFile = dbase_create( $shpFname.".dbf", array(array("PROG_ID", "N", 5, 0)));createPoint( 12, 34, 111);createPoint( 22, 14, 222);createPoint( 10, 20, 333);echo "Shapes Created.<BR>";//----------------------------------------------------------// done... cleanup//----------------------------------------------------------$shpFile->free();echo "Shape File ($shpFname) closed.<BR>";dbase_close($dbfFile);echo "Dbase file closed.<BR>";?> 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?