[Mapserver-users] Re: Mapserver-users digest, Vol 1 #486 - 14 msgs

blaise bpicinbono at worldonline.fr
Sat Apr 10 13:56:54 EDT 2004


Hi Ken-ichi,

I use the following code to add points to layers (parts coming from the 
gmap demo).
(with MapServer 3.6.2, it may be a little different with 4.0 ? )
The strange thing is that you have to go by :
$aLine = ms_newLineObj();
to add a point..., but it works.
You should find some help in it.
Blaise
ps : by the way, are you using MacOs X ? Do you have the Safari web 
browser ?
I am looking for somebody with Safari on MacOs X that could check if the 
Rosa applet
can work (see any MapServer demo with the Rosa Applet), thanks.

code :...

//------ main --------
// $udl = name-of-layer (without 'shp' or 'dbf')
$oClickGeo=ClickGeo($nClickPixX,$dfWidthPix,$dfMinX, 
$dfMaxX,$nClickPixY,$dfHeightPix,$dfMinY, $dfMaxY);
$id=0;
point_add($oClickGeo,$udl,$id);


/********************************************************/
/*           function ClickGeo                          */
/********************************************************/
function 
ClickGeo($snClickPixX,$sdfWidthPix,$sdfMinX,$sdfMaxX,$snClickPixY,$sdfHeightPix,$sdfMinY,$sdfMaxY)
{
GLOBAL $gpoMap;
$snClickGeoX = GMapPix2Geo($snClickPixX,0,$sdfWidthPix,$sdfMinX,$sdfMaxX,0);
$snClickGeoY = 
GMapPix2Geo($snClickPixY,0,$sdfHeightPix,$sdfMinY,$sdfMaxY,1);
$soClickGeo = ms_newPointObj();
$soClickGeo->setXY($snClickGeoX,$snClickGeoY);
return($soClickGeo);
}

/********************************************************/
/*     function point_add(point,layername,id)           */
/* add the point to the layer(*.shp) with the id(*.dbf) */
/********************************************************/
function point_add($sp,$sln,$sid)
{
GLOBAL $gpoMap;
GLOBAL $debugmsg;

$aLine = ms_newLineObj();
$varx=$sp->{x};
$vary=$sp->{y};
$aLine->addXY($varx,$vary);
$stmp="/$sln";
$shapepath=$gpoMap->{shapepath};
$shpFileName="$shapepath"."$stmp";
$shpFile = ms_newShapefileObj($shpFileName,-2);
$dbFile = dbase_open($shpFileName,2);
$c[0]=$sid;  // add all your database datas..
dbase_add_record($dbFile,$c);
$aShp = ms_newShapeObj(MS_SHP_POINT);
$aShp->add($aLine);
$shpFile->addShape($aShp);
$aLine->free();
$shpFile->free();
dbase_close($dbFile);
}




More information about the mapserver-users mailing list