queryByPoint() on a dynamic layer
Mark Brooks
mark_brooks at NCSU.EDU
Fri Jan 20 17:18:27 PST 2006
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?
--
Mark Brooks
Environmental Meteorologist
State Climate Office of North Carolina
Box 7236, NC State University
Raleigh, NC 27695-7236
E-mail: mark_brooks at ncsu.edu
Phone: 919.515.1446
Fax: 919.515.1441
More information about the MapServer-users
mailing list