[mapserver-users] problem creating shapefile

Ludovic Tenant ludovic at siterra.com
Tue May 29 16:50:16 PDT 2001


Hi list !

I'm just beginning using mapscript with Perl on my win2000 environment. I'm
trying to create a very basic shapefile containing 2 points. The script
looks like that :

%types = ( '1' => 'point',
	   '3' => 'arc',
	   '5' => 'polygon',
	   '8' => 'multipoint'
	 );

$shapefile = new shapefileObj('myShape1', 8) or die "Unable to open
shapefile $file";

$point1 = new pointObj();
$point1->{x} = -122.0;
$point1->{y} = 34.0;

$point2 = new pointObj();
$point2->{x} = -116.0;
$point2->{y} = 40.0;

$line = new lineObj();
$line->add($point1);
$line->add($point2);

$shape = new shapeObj(3);
$shape->add($line);

$shapefile->add($shape);

In fact, my problem is that I have a segmentation violation when I try to
add "point2" at the line : $line->add($point2);
If I comment out this line, the shapefile is correctly created with only one
point. Does anyone have an idea about that ?

Thanks,
Ludovic.



More information about the MapServer-users mailing list