[Chameleon] Querying dynamic built layers pt.2
Ken Sanderson
ken at rockies.ca
Wed Mar 16 19:24:17 EST 2005
Hello all. Well thanks to David's post I made some good headway, but
still stuck on how the query widget is responding.
Since the query widget was erroring I decided to see if my code was
working at all. I took the code I posted earlier, which you can find
below, and made it stand alone (used a newly created map object and put
it completely oustide of chameleon) I added the following to the bottom:
*********
$pt2 = ms_newPointObj();
$pt2->setXY($pointsarray[20][2],$pointsarray[20][3]);
$poLayer->queryByPoint($pt2,MS_MULTIPLE,0);
$result = $poLayer->getResult(0);
echo "this is the index:" . $result->shapeindex;
*********
This works as it should, it reads the shapeindex value that I have set.
So back to the chameleon query widget and its error. Its breaking on
line 496 of the map_query.php, specifically:
$oShape = $oLayer->getShape($oResult->tileindex, $oResult->shapeindex);
and the error it sends me is:
Fatal error: [MapServer Error]: msINLINELayerGetShape(): No inline
feature with this index.
If I replace $oResult->shapeindex with a number, say 10 (I know my
search returns 28 records so any value 27 or under will work), the query
responds and the result lists the shapeindex value as -1. I have gone
over the code in map_query.php and it looks like its doing the same
thing as I did in my test script. Create a point object, send point to
querybypoint, get the result, and then use the shapeindex property of
result to retrieve the index.
My thinking is that $oResult->shapeindex is returning a value of -1 or
null which is causing the getShape to fail. The question is why is it
not reading the index value I have set and instead returning the -1?
Any thoughts appreciated.
Ken
> Ken Sanderson wrote:
>>
>> $poLayer = ms_newLayerObj($this->moMapSession->oMap);
>> $poLayer->set("name", "Your Point Summary");
>> $poLayer->set("status", MS_OFF);
>> $poLayer->set("type", MS_LAYER_POINT);
>> $poLayer->set("labelcache", MS_OFF);
>> $poLayer->set("labelmaxscale",30000.0);
>> $poLayer->set("labelminscale",1.0);
>> $poLayer->set("template","ttt_query.html");
>> $poClass = ms_newClassObj($poLayer);
>> $poClass->set("name", "dynamic point summary class");
>> $poClass->label->set("font","sans");
>> $poClass->label->set("type","truetype");
>> $poClass->label->set("size",7);
>> $poClass->label->set("position","auto");
>> $poClass->label->set("force","TRUE");
>> $poClass->label->color->setRGB(0,0,0);
>> $poClass->label->outlinecolor->setRGB(225,240,180);
>> $poClass->label->shadowcolor->setRGB(225,240,180);
>> $poClass->label->set("offsetx",1);
>> $poClass->label->set("offsety",1);
>> $poClass->label->set("buffer",10);
>> $poClass->set("template","ttt_query.html");
>> $poStyle = ms_newStyleObj($poClass);
>> $poStyle->set("symbolname","star");
>> $poStyle->set("size", 15);
>> $poStyle->color->setRGB(250, 160, 5);
>> $poStyle->outlinecolor->setRGB(0,0,0);
>>
>> //go through point array and use each item
>> for ($i=0;$i<count($pointsarray);$i++){
>> $pt = ms_newPointObj();
>> $ln = ms_newLineObj();
>> $shp = ms_newShapeObj(MS_SHAPE_POINT);
>> $pt->setXY($pointsarray[$i][2],$pointsarray[$i][3]);
>> $ln->add($pt);
>> $shp->add($ln);
>> $shp->set("text",$pointsarray[$i][1]);
>> $shp->set("index",$i);
>> $poLayer->addFeature($shp);
>> }
>>
More information about the Chameleon
mailing list