[mapserver-users] querybypoint a postgis db with php mapscript

MirMatin mirmatin at gmail.com
Fri Jan 30 06:53:27 EST 2009


Hi Stefan,
Did you get a work out of the problem. I am having the same problem and want
to find some solution.

Looking forward to your response

Regards,

Mir Matin


Stefan Schwarzer wrote:
> 
> 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
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/querybypoint-a-postgis-db-with-php-mapscript-tp1971499p2244449.html
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list