On further investigation, it looks like the query statement is the cause
of trouble.  There appears to be some change in syntax in MS 6.x.

I've been trying to re-write it, but to no avail.  Can anyone provide an
example for a query statement for a shapefile data source, something
like this:

$value = "some value";
$query = '("[MYITEM]" = "' . $value . '")';

-In particular, what should be or should not be quoted?


-----Original Message-----
From: Bistrais, Bob 
Sent: Wednesday, January 25, 2012 10:28 AM
To: Alan Boudreault; [email protected]
Subject: RE: [mapserver-users] shape->draw problem

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:[email protected]] 
Sent: Sunday, January 22, 2012 5:41 PM
To: [email protected]
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
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


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


_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to