[mapserver-users] How to use Perl with Mapscript (was Re: The right tool for the job)

Brent Fraser bfraser at geoanalytic.com
Wed Feb 20 15:05:06 EST 2008


Colin,

> Other than those pages, I couldn't find much that would
really help me
> learn about MapScript and Perl.  Maybe I'll just follow
along with the
> PHP example at the following URL and hope the API is
similar.  It looks
> like the Perl MapScript module follows MapScript's C API;
perhaps the
> PHP module does, too?

I'm not a Mapscript user but I believe that is true.
Mapscript comes with serveral language bindings (including
Perl) and they are all automatically generated , so I would
expect they are the same (allowing for language
differences).

> Is there a MapScript API reference buried somewhere that I
could read?
> And, also, a map file API reference?  I'm really quite
lost when it
> comes to map files.

On the New Users page there are links to the MapScript API
(Section 2).  the map file reference is under the
"Documentation" -> references link, but it's tough to build
a working map file from scratch using just the doc.

I would HIGHLY RECOMMEND the advice in Section 5.2 Get the
Demo Running.  Looking at (and tweaking) the map file in the
demo will be  a big help in understanding what can be done.

> >   Make sure you read the New User page:
> > http://mapserver.gis.umn.edu/new_users.

>
> I would like my first step to be putting a static image on
a web site.
> The image would be generated by Perl and returned to the
browser as a
> simple image/png.
>
> The method I have in mind follows.
>
> Each user has a set of airports and routes with which they
are
> concerned.  This set of airports and routes could change
as frequently
> as every 30 seconds.  So, for each map generation request,
I would
> dynamically create a map file and store it as TEXT in my
PostgreSQL
> database, along with some unique ID.  Then, I would output
an <img />
> tag to the browser that includes the unique ID of this
> dynamically-generated map file:
>
> <img src="/foo/mapImage.pl?id=1234" />
>
> mapImage.pl sees id=1234, pulls map file 1234 out of the
database, uses
> the MapServer back-end to generate a map, then outputs
this map as an
> image/png.  I think mapImage.pl ends up being pretty
simple: create a
> mapserver object, pipe the map file text to it, and get
the png it
> generates.  Is that it, or am I thinking too narrowly
here?
>

Depends.  You could just use Perl+Mapscript to general the
png file then and there.  I think if you use MapScript there
is no requirement to have map file; all the elements a
supplied by making function calls in Perl to mapscript then
asking for the graphic to be generated (but the scripting
users would know more about that).

Brent



More information about the mapserver-users mailing list