I love bad news. Although it can be just a mistake of mine, it really behaves like a bug (I think so).
My previous topic has commented about the new self-incremented shapeObj.index property of MapServer 5.x and this one will focus at some implications I may have found - actually, I really don't know whether this is a bug or not. By the way...
First, take a look at the piece of code that follows, taken from an open source
library (thanks to Edmar Moretti):
function pegaValores($mapa,$layer,$item,$numerico=false)
{
...
if (@$layer-›queryByrect($mapa-›extent) == MS_SUCCESS)
{
$layer-›open();
$res_count = $layer-›getNumresults();
...
for ($i=0;$i‹$res_count;$i++)
{
$result = $layer-›getResult($i);
$shp_index = $result-›shapeindex;
$shape = $layer-›getshape(-1, $shp_index);
...
I've ommited some statements, but pay attention at the functions getResult() and getShape(). What if we would try the same thing above in the brand new MapServer release?
I tried that (in C#) and * surprise * got the follow:
results.getResult(0)
{OSGeo.MapServer.resultCacheMemberObj}
classindex: 0
shapeindex: 1
tileindex: -1
results.getResult(1)
{OSGeo.MapServer.resultCacheMemberObj}
classindex: 1
shapeindex: 1
tileindex: -1
results.getResult(2)
{OSGeo.MapServer.resultCacheMemberObj}
classindex: 0
shapeindex: 1
tileindex: -1
The classindex property of each result are OK but what about the shapeindex? Doesn't it should be evaluated with 1, 2, 3, etc?
Thus, when I try to do a queryByRect (or whatever), in general I always get the same feature - the one I've firstly added to the layer.
Is this a bug? I really don't know, but it smells kind of strange for me.
I've tried to investigate a little bit closer and spent some time digging the mapquery.c file. I took a look at the
int msQueryByRect(mapObj *map, int qlayer, rectObj rect)
method and I didn't find any reference that would may evaluate the shape.index property, although the shape.classindex I did so.
I'll recompile MapServer source code next week without the index = index + 1 statement. Maybe I find out something. Cheers.