[mapserver-users] The right tool for the job

Colin Wetherbee cww at denterprises.org
Wed Feb 20 14:28:30 EST 2008


Brent Fraser wrote:
>   The short answer is yes, MapServer is a good choice.

Excellent.

>     The longer answer:  You can use Mapserver as a CGI syle
> application or use a server-side scripting language such as
> perl (see the MapScript section of the Mapserver how-to:
> http://ms.gis.umn.edu/docs/howto/) to access MapServer
> functions.

I suppose MapScript is basically just a language that is platform 
independent, but when I was first reading about it yesterday and found 
the following link to "Perl Examples", I was disheartened.

http://mapserver.gis.umn.edu/docs/howto/perl_examples

A few lines about error handling weren't exactly what I was hoping to 
find there.

There is some Perl code in the comments at the bottom of the following 
URL that might be a good replacement for that page.

http://mapserver.gis.umn.edu/docs/howto/mapscript_querying/

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?

http://mapserver.gis.umn.edu/docs/howto/phpmapscript-byexample

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.

>   Make sure you read the New User page:
> http://mapserver.gis.umn.edu/new_users.
> 
>   Since you've got your source data already organized, and
> Mapserver will supply the server-side functionality (except
> for any Perl Mapscript coding you might want to do), likely
> most of your effort will be on the client-side interface.
> You'll need to select a toolkit if you plan on using a
> browser:
>     1. code your own html (and perhaps Javascript)
>     2. html + dbox/jbox
>     3. OpenLayers
>     4. other...

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?

I may include a time stamp, too, so I can expire map files after some 
length of inactivity.

Does this sound about right?

Thanks for your help. :)

Colin


More information about the mapserver-users mailing list