[mapserver-users] generate shape file

Daniel Morissette morissette at dmsolutions.ca
Sat Dec 15 13:26:09 EST 2001


Hussain,

Your code attempts to write lines/polylines (MS_SHP_ARC), but you set
only one point (x,y pair) per line... that may well be the source of
your problems... you need at least two points to define a line or a
polyline.

Daniel


Shaik Anwar Hussain wrote:
> 
> Hi List,
> 
>               Does any one know whats the wrong in this code,
> 
>               this code  generating the shape file but when i open the shape
> file in arcview i am not getting the lines.
> 
> <?php
> 
> dl("php_mapscript.dll");
> dl("php_dbase.dll");
> 
> function createshape( $x, $y, $programId )
> {
>     GLOBAL $shpFile,$dbfFile;
>     $oShp = ms_newShapeObj(MS_SHP_ARC);
>     $oLine = ms_newLineObj();
>     $oLine->addXY($x, $y);
>     $oShp->add( $oLine );
>     $shpFile->addShape($oShp);
>     dbase_add_record($dbfFile, array($programId));
> }
> 
> $shpFname = 'C:\Program Files\Apache Group\Apache\htdocs\php\test5';
> $shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_ARC);
> $dbfFile = dbase_create($shpFname.".dbf", array(array("PROG_ID","N",5,0)));
> 
> createshape( 12, 34, 111);
> createshape( 22, 14, 222);
> createshape( 10, 20, 333);
> 
> echo "Shapes Created.<BR>";
> 
> $shpFile->free();
> echo "Shape File ($shpFname) closed.<BR>";
> 
> dbase_close($dbfFile);
> echo "Dbase file closed. <br>";
> 
> ?>
> 
> i am using php 4.0/mapscript 3.4 module.
> 
> Please try to look this problem.
> 
> Thanks for ur time,
> Hussain



More information about the mapserver-users mailing list