[mapserver-users] Mapscript - Adding shape to shapefile

Daniel Morissette morissette at dmsolutions.ca
Wed May 23 17:52:46 EDT 2001


Janet Ciavarelli wrote:
> 
> Hi,
>    I am have a script where I create a point and then try to add the point to a shapefile. I keep getting the following error on the 'add' method for the shapefile Obj. Does anyone see what's wrong with my 'add' method in the code below?
> 

Janet, 

In MapScript, a shapeObj constituted of 1 or more lineObj, which are in
turn constituted of a number of pointObj.  So I think that to solve your
problem you need to add your point into a lineObj, and then add the
lineObj into the shapeObj ... and then pass the shape to the
shapefileObj->add method... i.e. try this:


 $shapefile = new shapefileObj('potholes',$mapscript::MS_SHP_POINT);

 $point = new pointObj();
 $point->{x} = $ar{mapx};
 $point->{y} = $ar{mapy};

 $line = new lineObj;
 $line->add($point);

 $shape = new shapeObj($mapscript::MS_SHP_POINT);
 $shape->add($line);

 $shapefile->add($shape);   

 $shapefile = '';

-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------
  Don't put for tomorrow what you can do today, because if 
      you enjoy it today you can do it again tomorrow.



More information about the mapserver-users mailing list