queryByPoint() on a dynamic layer

Mark Brooks mark_brooks at NCSU.EDU
Sat Jan 21 07:38:03 PST 2006


Nicol,

Thanks for the reply.  I'm running mapserver version 4.6.1 which should
not be afflicted with the bug you referenced.  Maybe I'm not correctly
adding the dynamic points to the layer?

Mark


Nicol Hermann wrote:
> Hi Mark,
> 
> what version of mapserver do you use?
> Your description sound to me like bug 806
> (http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=806)
> which was fixed on 2005-03-07. Is it possible that you use an older
> version of mapserver? 
> 
> Nicol
> 
> Am Freitag, den 20.01.2006, 20:18 -0500 schrieb Mark Brooks:
> 
>>I'm trying to queryByPoint on a dynamic point layer.  The points in the 
>>layer are added from a mysql database.  When I queryByPoint on this 
>>dynamic layer, the resulting shapeindex and tileindex are both -1, which 
>>is not what is expected.
>>
>>Here is how I ADD the points to the layer:
>>$query = mysql_query(" mysql query...  ");
>>while ($site = mysql_fetch_assoc($query)){
>>    // this draws the dynamic point
>>    $mypoint = ms_newPointObj()
>>    $mypoint -> setXY($site['lon'],$site['lat']);
>>    $mypoint->draw($map,$layer,$image,0,'name');
>>
>>    // this adds the feature to the layer so that it
>>    // can be queried.  No results are found from a query
>>    // by only drawing it above.
>>    // Probably not the most efficient and perhaps
>>    // where I'm going wrong?
>>    $mypoint_shape = ms_newShapeObj(MS_SHAPE_POINT);
>>    $mypoint_line = ms_newLineObj();
>>    $mypoint_line->add($mypoint);
>>    $mypoint_shape->add($mypoint_line);
>>    $stations_layer->addFeature($mypoint_shape);
>>}
>>
>>
>>Then later in my php script, this is how I query:
>>// get coordinates to query
>>$myclick = ms_newPointObj();
>>$myclick -> setXY($geo_lon,$geo_lat);  // set the click point
>>
>>// do the query
>>$layer -> queryByPoint($myclick,MS_MULTIPLE,100);
>>for ($i=0; $i<$layer->getNumResults(); $i++){
>>    $result = $layer->getResult($i);
>>    // output below shows 'shapeindex' and 'tileindex' are both -1
>>    print_r($result);
>>}
>>
>>
>>What am I doing wrong?  If I queryByPoint on any static layer, tileindex 
>>and shapeindex are good values.  But on this dynamic layer, they are 
>>always -1.  Any ideas?



More information about the MapServer-users mailing list