Thanks a lot, Steve.
However, I had tried this out before, but "getResult($)"? I think this is Perl,
no? In PHP this would be different?
Sorry for a dumb question…
Stefan
> The query code underwent major changes between 5.6 and 6.0 and one casualty
> was query processing like you're doing. On the bright side it's much more
> straight forward now. The general steps for a layer-based query is now just:
>
> $layer->queryByRect($map, $rect); # layer is left open after a query operation
>
> for($i=0; $i<$layer->getNumResults(); $i++) {
> $shape = $layer->getShape($layer->getResult($)); # much simpler
> # do something with the shape
> }
>
> I see the MapScript/Swig query docs are woefully out of date. I'll file a
> ticket on that...
>
> Steve
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Stefan Schwarzer
> Sent: Friday, August 03, 2012 6:37 AM
> To: [email protected]
> Subject: [mapserver-users] getShape failing; changes from mapserver 5.6 to 6.0
>
> 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
> _______________________________________________
> mapserver-users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users