[mapserver-users] Last point does not show in a dynamic layer
David Boggio
david.boggio at manobi.sn
Wed Sep 18 17:04:01 PDT 2002
Hello list,
This is my first post. I’m new to Mapserver. Hope this problem has not
been discussed earlier.
I want to generate a dynamic layer, based on a SQL query.
I managed to query the MySQL database, and display the points on the
map.
But the last point of the query result array is not displayed. I tried
to change the sorting order, and I always notice the same problem. Is it
really the problem or is there another one I did not see?
Below is a part of the code and the function I use to build the layer.
I used part of Jan Mantkowski’s code (thanks) by correcting a small
mistake : you can’t parse the same MySQL query result twice (using
mysql_fetch_array), because when you have reached the end of the query
result, the result array variable is empty, and your script has nothing
to draw anymore. So you can either requery the database before you parse
the result array again, or try to parse it only once (best).
Thanks for your ideas on my pb.
David Boggio
Dakar, Senegal.
//function to draw the points dynamic layer
function AddConnectionLayer($Map,$image)
{
$layer = $Map->getLayerByName("Connections");
$layer->set('status', MS_ON);
$projInObj = ms_newprojectionobj("proj=latlong,ellps=WGS84");
$projOutObj =
ms_newprojectionobj("proj=merc,lat_ts=0,units=m,ellps=clrk80,no_defs");
$link = mysql_connect("localhost", "root", "") or die("Could not
connect");
$sql="SELECT DISTINCTROW logs.connexions.user_id, logs.users.nom,
admin.lieux.NomLieu, admin.lieux.Lon, admin.lieux.Lat FROM
logs.connexions LEFT JOIN logs.users ON
(logs.users.user_id=logs.connexions.user_id) LEFT JOIN admin.lieux ON
(logs.users.idlieu= admin.lieux.CodeLieu) ORDER BY Lon DESC";
$res=mysql_query($sql);
while($ligne=mysql_fetch_array($res))
{
$x=$ligne["Lon"];
$y=$ligne["Lat"];
$name=$ligne["user_id"];
$pt = ms_newPointObj();
$pt->setXY($x,$y);
$pt = $pt->project($projInObj, $projOutObj);
$pt->draw($Map, $layer, $image, 0, $name);
$pt->free;
}
mysql_free_result($res);
}
//Part of the map file
LAYER
NAME "Connections"
TYPE POINT
STATUS OFF
CLASS
NAME "Connects"
SYMBOL 'dot'
OUTLINECOLOR 0 0 0
COLOR 0 0 0
END
END
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.386 / Virus Database: 218 - Release Date: 09/09/2002
More information about the MapServer-users
mailing list