[Mapserver-users] create and display point obj on the fly

Lionel Bargeot l.bargeot at educagri.fr
Mon Feb 3 17:07:21 EST 2003


Le lun 03/02/2003 à 21:47, Lionel Bargeot a écrit :
> Has someone already tryed to do something like this ? Have i to create a
> shapfile of each result and then display it ? Can I produce a map of
> point without create/use a shapefile ?
> 
So I decided to create a temporary shapefile with each point of my query
result on my database. 

//I create my shapefile like this in a temporary directory :
$shapefile_temp=ms_newShapefileObj("../data/$shapetempname",
MS_SHP_POINT);

// then I add each point from my query in the shapfile :
for ($i = 0; $i < $iNbr; $i++) {
	$Lign = pg_fetch_array($Res, $i); 
	$pointobj = ms_newPointObj();
	$pointobj->setXY($Lign["x"],$Lign["y"],1);
	$shapefile_temp->addPoint($pointobj);
	$pointobj->free();
}
// then I close shapefileObj to write it on the disk :
$shapefile_temp->free();

then I try to create a layer and a class with this shapefile. But there
is an error message about the dbf file. I have a look in my tmp
directory, and then I find a .shp, a .shx, but no .dbf.
I simply create manualy (touch unix command) an empty dbf file with the
right name and then it works. So my  question is : have I to create
manually an empty dbf file or is there somewhere an option I missed that
provides a mean to create a dbf file with shp and shx ?

thanks for all

Lionel

-- 
AgrogeomaTIC
CNERTA-ENESAD, 4 rue champs-prevois, batiment grand-champs, 21000 Dijon
03.80.77.28.49
http://stb.educagri.fr





More information about the mapserver-users mailing list