[Mapserver-users] Re: Implementing querying functionality using Perl MapScript
Lowell Filak
lfilak at medinaco.org
Tue Jul 15 10:24:49 PDT 2003
To get & install XBase (& DBI):
Either:
1) perl -MCPAN -e shell;
2) install DBD::XBase
3) install Bundle::DBI
or:
1) Download
http://search.cpan.org/CPAN/authors/id/J/JA/JANPAZ/DBD-XBase-0.234.tar.gz
2) Download http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.37.tar.gz
3) Do "tar -xf xxxxxx.tar.gz --ungzip" for each.
4) Do "perl Makefile.PL; make; make test; make install" for each.
As far as DBFInfo goes:
Don't use it.
To access the attributes in the DBF after you have the shape index:
If the DBF file includes a field with the record number in it you can
use the combination of XBase & DBI to do an SQL
"SELECT attribute FROM dbffile WHERE recno = '$shapeindex'".
Note: The record number field I'm referring to is NOT a standard DBF field.
If the DBF file does not include a field with the record number in it
you must use XBase and loop through each record with a counter starting
at 0 until you read a record and the counter is equal to the $shapeindex.
HTH
Lowell
The following message was sent by AMC Story <s9646183 at sms.ed.ac.uk> on
Tue, 15 Jul 2003 12:30:07 +0100 (BST).
> Thanks, I'll try to be a bit more specific this time :)
>
> Basically, I'd like to be able to select a point object from the map,
and then
> display a new pop-up box, which would give the user all the
information about
> that point feature which is stored in the dbf file, and perhaps also
include a
> map in this pop up window which would highlight the selected feature in a
> different colour or with a different symbol. Not quite sure how to do
the pop-
> up box thing yet, but I seem to remember some tips on this in the
archive, so
> I'll look at that once I've figured out how to do the basics.
>
> So far, I've got to the point where I can display the shapeindex of the
> selected point,
>
> ie. $rec_no = $result_feature->{shapeindex};
>
> but I'm now struggling to work out how to access the attributes of the
feature
> in the dbf file with that record number. In some of the examples, the
XBase
> module is used. I don't seem to be able to access this (and I've
tried xdb and
> Xbase too) but I could possibly get it installed if it's necessary.
>
> I was wondering though whether I could use methods of the DBFInfo
class or some
> of the miscellaneous functions such as msDBFReadStringAttribute which
I saw
> listed on the Perl MapScript Reference some time ago, but which now
seem to
> have disappeared. Are these still supported, and is there any
documentation
> somewhere for them?
>
> If using the XBase module is the only/best way to go, could someone
please give
> me the corrent name and version number of the module I should be
looking for,
> or even better, where I might get it?
>
> Thanks very much,
> Ali
>
>
> Quoting pkishor_98 <pkishor at geoanalytics.com>:
>
> > --- In mapserver-users at yahoogroups.com, AMC Story <s9646183 at s...>
> > wrote:
> > > Hi there everyone,
> > >
> > > I've been using Perl MapScript to develop the interface
> > > of my application, and am now wanting to implement the
> > > querying functionality that I had going with
> > > the old mapserver CGI version, but now with MapScript.
> >
> > could you elaborate more on --
> >
> > - what have you already developed with Perl/Mapscript; and
> > - what you mean by "querying functionality"
> >
> > Until you do that, I am going to assume you mean identifying a feature
> > based on the user's mouse-click.
> >
> > > I was wondering if there are any examples of the code
> > > needed to do this, as I can't seem to find
> > > anything more than very brief (and apparently incorrect!)
> > > snippets in the
> > > archives.
> >
> > which archives did you look at? There are several very nice examples
> > on the wiki, and in the Perl/Mapscript docs. The best, most complete
> > example is the mapquakes.pl script. It shows you the building blocks.
> >
> > Briefly... you capture the mouse clicks and use them to create the new
> > map envelope and generate a new image. If you are querying... you once
> > again use the mouse clicks to get the shapeindex and then get its
> > associated attribute data from either the <shape>.dbf or a related
> > external database table. Keep in mind, the mouse clicks would be
> > imagespace, and will have to be converted to geographic space before
> > doing anything with them.
> >
> > There are definitely fewer ready-to-use, code capsules for
> > Perl/Mapscript, and some of us have talked about remedying the
> > situation. Most Perl/Mapscript users, however, have found the existing
> > examples quite helpful in guiding them and setting them on the correct
> > path to developing their own code. Each application is different, and
> > it is hard to provide a demo that will work for everyone.
> >
> > Please look at the above mentioned examples on the wiki, and then if
> > you have specific questions come and ask us. One of us will be able to
> > help you.
> >
> >
> >
> > _______________________________________________
> > Mapserver-users mailing list
> > Mapserver-users at lists.gis.umn.edu
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> >
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list