[Mapserver-users] How do I use ms_newShapefileObj()?

BONNER S KARGER bskarger at students.wisc.edu
Wed Jul 28 14:32:34 EDT 2004


List:

I am trying to populate a NEW shapefile (that is, uncreated until there is an SQL result for point coordinates), but I get the following error:

Warning: [MapServer Error]: msNewSHPFile(): (testshapefile) in test/setpoint.php-cgi on line 5

Fatal error: Failed to open shapefile testshapefile in test/setpoint.php-cgi on line 5

I am trying to create a new shapefile and populate it with points that are coming in from a MySQL query. The points will display fine on the map, but I want to be able to query them, so I need to create a shapefile and .dbf. I can't get past creating the shapefile, however. 

Here is the php code that is found in the "for loop":
------------------------------------------------
<?php
$value = mysql_fetch_array($result); 
$point = ms_newPointObj();
$point->setXY($value[20],$value[21]);
$newshapefile = ms_newShapefileObj(testshapefile, MS_SHP_POINT);
$newshapefile->addPoint($point);
$point->draw($map, $layer, $img, 0 ,'map image');
$point->free();
?>


I thought that by passing MS_SHP_POINT, it would create a new file. Am I wrong?
Any ideas?

Thanks

Bonner





More information about the mapserver-users mailing list