Assign Data to a point for query with mapscript?

Lowell Filak lfilak at MEDINACO.ORG
Wed Sep 1 23:12:35 EDT 2004


The following message was sent by Eric Bridger <eric at GOMOOS.ORG> on Wed,
1 Sep 2004 15:51:47 -0400.

> On Wed, 2004-09-01 at 14:28, sandnarrows wrote:
> > Hello all. I am using mapscript to create a layer object and add a
> > series of points that get displayed on the map. Everything is working
> > fine. The layer shows up in the legend, points on the map where they
> > should be, etc. Is there a way to add data to the points that can be
> > returned when the user performs a query?
> >
> > Searching through the archives I see several examples of using Xbase to
> > create/edit dbf files. I don't really want to create a file, the
> > information will only exist as long as the user session.
>
> The only data you can get back from a query is the shapeindex. If you
> are adding the points to your layer dynamically e.g.
> $layer->addFeature($shape);
>
> You should have done a $shape->{index} = $id; first.  That $id can be
> any numeric value. When you do a:
> $layer->queryByPoint();
> ....
> $result->getResult(0);
> $id = $result->{shapeindex};
> The id will be the one you set above. That can be used to retrieve your
> other values, from some lookup table or some database.
>
> There is a Perl example of this approach here:
> http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples42ex1
>
> Eric

As usual, Eric is right on the mark. One side note, I think it best to
make sure you keep the index you set unique if you're not simply using a
sequential numbering scheme.

Lowell

Lowell



More information about the mapserver-users mailing list