[mapserver-users] shape->draw problem

Bistrais, Bob Bob.Bistrais at maine.gov
Wed Jan 25 07:28:20 PST 2012


Hi Alan,

I worked with the nextShape() a little bit as follows:

	for ($i=0; $i<=($oLayer_master->getNumResults() - 1); $i++) {
		while($oShape = $oLayer_master->nextShape()){
			$oResult = $oLayer_master->getResult($i);
			$oLayer_master->open();
			$oShape = $oLayer_master->getShape($oResult);
			$oShape->draw($oMap,$oLayer_shape,$oImage);
			$oLayer_master->close();
		}
	}

That appears to have fixed the error message I was getting, but it still
does not draw results (it should).

You brought up a good point regarding the query.  Here is the query
language, at least what I could find (it's worth noting I did not write
the application, but am now responsible to maintain it):

	$query = $_GET['qpub'];
	$query = '("[PUBCODE]" = "'.$_GET['qpub'].'")';
	$oLayer_master->queryByAttributes("PUBCODE", $query,
MS_MULTIPLE);
	pubExtent2($oLayer_master, $oMap);



-----Original Message-----
From: Alan Boudreault [mailto:aboudreault at mapgears.com] 
Sent: Sunday, January 22, 2012 5:41 PM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] shape->draw problem

Hi Bob,

I do not see any query in your code. Not sure why numresults return a 
non-zero value. Check the example of the getShape() or nextShape() 
functions in the documentation:

http://mapserver.org/mapscript/php/index.html#layerobj

Alan

On 12-01-20 03:55 PM, Bistrais, Bob wrote:
> I'm upgrading an application from Mapserver 5.6 to 6.0.1, PHP
MapScript.
> I'm having a problem with one section of code where it gives a
> shape->draw command. In MS 5.6, the Shape was derived from a
getFeature
> method, but in MS 6 this had to be changed to a getShape. The next
> command is to draw the shape. This returns the following error:
>
> Fatal error: Uncaught exception 'MapScriptException' in
> C:\ms4w_303\apps\mgs\htdocs\drawMap_detail_spatial.php:101 Stack
trace:
> #0 C:\ms4w_303\apps\mgs\htdocs\drawMap_detail_spatial.php(101):
> shapeObj->draw(Object(mapObj), Object(layerObj), Object(imageObj)) #1
> {main} thrown in
C:\ms4w_303\apps\mgs\htdocs\drawMap_detail_spatial.php
> on line 101
>
> Here is the code leading up to the error:
>
> $oLayer_shape = $oMap->getLayerByName("master");
>
> for ($i=0; $i<=($oLayer_master->getNumResults() - 1); $i++) {
>
> $oResult = $oLayer_master->getResult($i);
>
> $oLayer_master->open();
>
> // $oShape = $oLayer_master->getFeature($oResult->shapeindex,-1); -Old
> getFeature method-commented out and replaced on next line:
>
> $oShape = $oLayer_master->getShape($oResult);
>
> $oShape->draw($oMap,$oLayer_shape,$oImage); -fails on this line
>
> $oLayer_master->close();
>
> }
>
> I do believe I'm retrieving a valid shape. What's even more confusing,
> I've had to replace the getFeature with getShape in other parts of the
> application and it seems to work.
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


-- 
Alan Boudreault
http://www.mapgears.com/




More information about the MapServer-users mailing list