[mapserver-users] getShape failing; changes from mapserver 5.6 to 6.0

Stefan Schwarzer stefan.schwarzer at unep.org
Fri Aug 3 04:36:41 PDT 2012


Hi there,

I am struggling with a few changes I need to go through in order to make my code working now with mapserver 6.x. This one concerns the query part, when a user clicks on the map and a window with some metadata is being displayed.

An error message occurred:

	"Catchable fatal error: Argument 1 passed to layerObj::getShape() must be an instance of resultObj, integer given"

When I changed the getShape command as indicated here [1], it says:

	"Fatal error: Call to a member function getShape() on a non-object"


This is the code:

	//Query the Map at the point clicked
	if (!$imgbox)
		@$a = $map -> queryByPoint($click_pt, MS_MULTIPLE, -1);
	else
		$a = $map -> queryByRect($click_rt);

	if ($a == MS_SUCCESS)
	{

		$numResults = $Layer -> getNumResults();
		$oLayer = $map -> getLayer($Layer -> index);

		// Open layer's table... take the list of fields to display from 
		// the "HEADERRESULT_FIELDS" metadata in the layer object.
		$oLayer -> open();

		$oRes = $oLayer -> getResult(0);		
		//$oShape = $oLayer -> getShape($oRes->tileindex,$oRes->shapeindex); 	// before
		$oShape = $layer -> getShape($oLayer -> getResult(0));  				// now ??
			
			
		while(list($key, $val) = each($oShape -> values))
		{
		    //echo "<br />x - ".count($selFields)." - ".$key . " = " . $val;
		 	if (($key <> "META_DATA") AND ($key <> "oid") AND ($key <> "id") AND ($key <> "uid"))
		 		$selFields[count($selFields)] = $key;
		}



Not sure what I should put there…

Thanks for any hints,

Stefan


[1] http://mapserver.org/MIGRATION_GUIDE.html


More information about the mapserver-users mailing list