[mapserver-users] Add points to shape

Lowell Filak lfilak at medinaco.org
Thu May 16 08:44:12 EDT 2002


I don't believe mapscript is intended to edit the associated dbf files.
For instance if you look at the DBFInfo object you will see that it ONLY reads information rather than writes information.
At first this may seem strange but actually it makes sense for mapscript to not reinvent the wheel when there are other modules available for editting dbf files.
You will need to "use XBase;" in order to add records to the dbf file for the points you add.
Lowell F.

The following message was sent by "Guillaume Sueur" <guillaume.sueur at khi2.fr> on Thu, 16 May 2002 10:11:06 +0200.

> Hi there,
> I'm trying to build up an application able to add points to a shape using
> mapscript. I'm using these two methods :
> 
> function creerPoint($Xpt,$Ypt)
> {
>   GLOBAL      $gpoMap;
> 
>   $flnShapefile = "c:\inetpub\wwwroot\ipso_facto\htdocs\data\logipro";
>   $objShapefile = ms_newShapeFileObj( $flnShapefile, MS_SHP_POINT);
>   $oLayer = $gpoMap->getlayerbyname(BIENS);
> 
>   //methode 1
>   //$point = ms_newPointObj();
>   //$point->setXY($Xpt,$Ypt);
>   //$objShapefile->addPoint($point);
>   //$objShapefile->free;
> 
>   //methode 2
>   $point = ms_newPointObj();
>   $point->setXY($Xpt,$Ypt);
>   $line = ms_newlineObj();
>   $shape = ms_newshapeObj(MS_SHAPE_POINT);
>   $line->add($point);
>   $shape->add($line);
>   $objShapefile->addshape($shape);
>   $objShapefile->free;
> }
> 
> Both methods are doing the same : they add a point in the shape file, but no
> line in the dbf file, so the layer is corrupted and can't be opened.
> Addfeature seems to do the same.
> 
> Any idea ?
> 
> Thanks
> 
> ----------------------------------------------------
> Guillaume SUEUR - guillaume.sueur at geosignal.fr
> Ingénieur développement
> GEOSIGNAL
> 25bis, avenue Marcel DASSAULT
> BP 5836
> 31505 TOULOUSE CEDEX
> ------------------------------------------------------




More information about the mapserver-users mailing list