[mapserver-users] No fill after creating a shapeObj

Daniel Morissette morissette at dmsolutions.ca
Wed May 22 09:41:05 EDT 2002


I assume that after creating the shapefile you add it to a layer on the
fly and then nothing shows up in the layer?

You should check a few things:

1- Make sure that you close the DBF and SHP files before using them in
   a layer:

    $shpFile->free();
    dbase_close($dbfFile);

2- Make sure you use MapServer 3.6 since 3.5 may have had some problems
with closing the SHP file depending on your version of PHP.

Daniel


"Arthur, John" wrote:
> 
> What am I doing wrong?  The following example will create a shape (line),
> but it will not be filled.  I works if I use similar code for dynamic
> layers, but fails to fill if I write it to a shp file.  Thanks for your
> help.
> 
> example:--------------------------------------------------
> 
> $shpFile = ms_newShapeFileObj( $shpFname, MS_SHP_POLYGON);
> $dbfFile = dbase_create( $shpFname.".dbf", <!-- My field array here -->);
> $oShp = ms_newShapeObj(MS_SHAPE_POLYGON);
> $oLine = ms_NewLineObj();
> $mid_h=90;
> $beg_h=$mid_h+(($horizontal/2)-$horizontal);
> $midbeg_h=$mid_h+((($horizontal/2)+($horizontal/4))-$horizontal);
> $midend_h=$mid_h+((($horizontal/4)*5)-$horizontal);
> $end_h=$mid_h+((($horizontal/2)*3)-$horizontal);
> 
> $oLine->addXY($x, $y);
> $oLine->addXY($x + 0.015 * 0.4 *
> cos((($orientation*-1)+$beg_h)*3.14159265/180), $y + 0.015 * 0.4 *
> sin((($orientation*-1)+$beg_h)*3.14159265/180));
> $oLine->addXY($x + 0.015 * 0.4 *
> cos((($orientation*-1)+$midbeg_h)*3.14159265/180), $y + 0.015 * 0.4 *
> sin((($orientation*-1)+$midbeg_h)*3.14159265/180));
> $oLine->addXY($x + 0.015 * 0.4 *
> cos((($orientation*-1)+$mid_h)*3.14159265/180), $y + 0.015 * 0.4 *
> sin((($orientation*-1)+$mid_h)*3.14159265/180));
> $oLine->addXY($x + 0.015 * 0.4 *
> cos((($orientation*-1)+$midend_h)*3.14159265/180), $y + 0.015 * 0.4 *
> sin((($orientation*-1)+$midend_h)*3.14159265/180));
> $oLine->addXY($x + 0.015 * 0.4 *
> cos((($orientation*-1)+$end_h)*3.14159265/180), $y + 0.015 * 0.4 *
> sin((($orientation*-1)+$end_h)*3.14159265/180));
> $oLine->addXY($x, $y);
> 
> $oShp->add($oLine);
> 
> $oShp->add( $oLine );
> $shpFile->addShape($oShp);
> 
> dbase_add_record($dbfFile, <!-- My field array here -->);
> 
> John Arthur
> RF Technician
> Office:   (757) 490-7221
> Cellular: (757) 692-1515
> Email: john.arthur at voicestream.com
> VoiceStream Wireless
> Global Wireless by
> ···T···Mobile·



More information about the mapserver-users mailing list