[Mapserver-users] addPoint problems

Ken-ichi Ueda kueda at wso.williams.edu
Fri Apr 2 19:38:31 PST 2004


Hi folks.  I'm new to MapServer and phpMapScript and I've run into a 
roadblock with ShapefileObj's addPoint() function.  I add the point, 
add a record to the dbf (w/ almost no data), there are no errors, and 
the reported number of shapes in the file increases by one, but the new 
point isn't displayed.  I've perused the list archives and haven't 
found anything like this.  Can anyone give me any advice?  This may all 
stem from some deep ignorance of the true and potentially infernal 
nature of shapefiles.  I've included my version info and code below if 
it helps.  This is all in Mac OS 10.3.

MapServer Version
MapServer version 4.0 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ 
SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER INPUT=TIFF INPUT=EPPL7 INPUT=JPEG 
INPUT=SHAPEFILE

  PHP MapScript Version
  ($Revision: 1.177 $ $Date: 2003/07/30 19:01:31 $)


		$my_point = ms_newpointObj();
	 
	$my_point->setXY($HTTP_POST_VARS["mapa_x"],$HTTP_POST_VARS["mapa_y"]);

		//add the point
		$targetFile = ms_newShapefileObj( "/path/to/file", -2 );
		$temp = $targetFile->addPoint( $my_point );
		echo "<p>result: $temp\n";//test
		echo "<p>result: " . $targetFile->numshapes;//test
		echo "<p>result: " . $targetFile->type;//test
		echo "<p>result: " . $targetFile->source;//test

		$targetFile->free();
		
		//add the dbf record
		$dbf = dbase_open( "/path/to/file.dbf", 2 );
		
		$attr = array( "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "newpt", "", 
"", "", "", "", "", "", "", "", "", "", "", "" );
		
		if( !dbase_add_record( $dbf, $attr ) ) echo "<h2>Add Record 
Failed!</h2>";
		dbase_pack( $dbf );

Thanks in advance.

-Ken-ichi




More information about the MapServer-users mailing list