addFeature and queryByPoint in PHP mapscript

Camden Daily cdaily at GMAIL.COM
Mon Jan 31 11:43:44 EST 2005


I'm trying to find a way to use queryByPoint against a layer that I've
generated on-the-fly in PHP mapscript.  I've found a number of
previous posts to this list regarding the same error (usually in perl,
not PHP) but I can't find any adequate solution.

I'm adding my points to the layer like this:

  $point = ms_newPointObj();
  $point->setXY($longitude, $latitude);
  $line = ms_newLineObj();
  $line->add($point);
  $shape = ms_newShapeObj(MS_SHAPE_POINT);
  $shape->add($line);
  $shape->values = $values;
  $layer->addFeature($shape);

And the layer works just fine.  It displays on the map perfectly.

When I try to run queryByPoint against this layer, though, my shapes
always end up with a tileindex and shapeindex of -1 from the getResult
call.  getShape of course fails with indexes of -1.

I've tried setting my layer to MS_INLINE, but that doesn't seem to fix
anything.  From the solutions I've seen on the web for people using
perl to do this, it seems that they're doing a $shape->index = x, just
setting the indexes themselves.  Unfortunately, in PHP, the index
property of the shape object is read only.  No matter what I've tried,
I always get a shape and tile index of -1.

I know that I could just generate a shapefile to do this, but my data
will be changing fairly often, and I don't want to have to keep
updating my shapefiles.



More information about the mapserver-users mailing list