[mapserver-users] querybypoint a postgis db with php mapscript
Stefan Schwarzer
stefan.schwarzer at grid.unep.ch
Tue Aug 26 06:16:33 PDT 2008
Hi there,
I guess there is something I am doing wrong. I think that since I
moved from shapefiles to postgis, my query (bypoint/byrect) doesn't
work anymore. Is there anything I have to change? I am kind of
frustrated, because if looked around everywhere to find the problem;
this issue has cost me hours over hours, but nothing in sight
My code looks like this:
//Set the layers status ON (b/c it might not be...)
$Layer -> set("status", 1);
$ImgWidth = $map -> width;
$ImgHeight = $map -> height;
$x = (($ptX / $ImgWidth) * ($ext3 - $ext1)) + $ext1;
$y = $ext4 - (($ptY / $ImgHeight) * ($ext4 - $ext2));
$x1 = (($extent_px0 / $ImgWidth) * ($ext3 - $ext1)) + $ext1;
$y1 = $ext4 - (($extent_px1 / $ImgHeight) * ($ext4 - $ext2));
$x2 = (($extent_px2 / $ImgWidth) * ($ext3 - $ext1)) + $ext1;
$y2 = $ext4 - (($extent_px3 / $ImgHeight) * ($ext4 - $ext2));
$click_pt = ms_newPointObj();
$click_pt -> setXY($x, $y);
$click_rt = ms_newRectObj();
$click_rt -> setextent($x1, $y2, $x2, $y1);
//Query the Map at the point clicked
if (!$imgbox)
$a = $map -> queryByPoint($click_pt, MS_MULTIPLE, -1);
else
$a = $map -> queryByRect($click_rt);
And my mapfile like this:
LAYER
NAME floods_killed
STATUS ON
CONNECTIONTYPE postgis
CONNECTION 'user=xxx password=xxx dbname=xxxx'
TYPE POLYGON
DATA "the_geom FROM
(
SELECT
c.the_geom,
c.name,
COALESCE(d.value, -9999) AS value,
d.id_country AS uid
FROM
floods_killed AS d
RIGHT JOIN
countries AS c ON c.id = d.id_country
WHERE
d.year_start = 2007 AND
c.id = d.id_country
) AS foo USING UNIQUE uid USING srid=4326"
LABELITEM value
CLASSITEM 'value'
CLASS
NAME ''
EXPRESSION ([value]=-10001)
TEMPLATE 'empty space'
END # CLASS
CLASS
NAME 'Units: Number of People'
EXPRESSION ([value]=-110003)
TEMPLATE 'units as title in legend'
END # CLASS
Thanks for any hints!
Stef
More information about the MapServer-users
mailing list