add point to a shapefile

Stephen Lime steve.lime at dnr.state.mn.us
Fri Jul 14 17:30:41 EDT 2000


Remember, a shape is made up of lines (parts) that are in turn made up of
points. So, you need to do something like this:

  $part = new lineObj();
  $shape = new shapeObj();

  $point->{x} = $x;
  $point->{y} = $y;

  $part->add($point);
  $shape->add($part);

  $shapefile->add($shape);

I might add a "addPoint" method to the shapefileObj to simplify life...

Steve


Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Michael Anderson" <m_anderson14 at hotmail.com> 07/14/00 11:01AM >>>
Hello,

I am trying to add points to a shapefile and am having problems. When I make 
a new shapeObj and try to add the coordinates with this line:
$pt->{x} = 456848.34843;
I get this error "Undefined subroutine &mapscript::shapeObj_x_set called at 
...".

So I tried making $pt a pointObj() instead. I can set it's coordinates, but 
the add method of shapefileObjs expects a shapeObj instead of a pointObj.

So my question is, how do I set the x,y coordinates of a shapeObj that 
represents a point. This is my first day with Perl so I apologize if the 
answer is obvious.

Thanks.

Mike Anderson
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com 





More information about the mapserver-users mailing list