Mapfile creation including PostGIS layer with changing table (view) name?

Ei Fujioka efujioka at DUKE.EDU
Fri May 11 07:05:07 PDT 2007


Hi Jan,

Here is another possibility.

You may want to try parameters in mapfiles.

For example, if you want to parameterize the view name, add to the query 
string a key and value pair something like:
   view=view_name
where view is the key and view_name is the actual name of the view.

The layer definition in the mapfile should look like:
(Essential part only)

LAYER
   NAME "yourlayer"
   METADATA
    ...
   END
   CONNECTION "..."
   CONNECTIONTYPE POSTGIS		
   DATA "_geom from (SELECT your_columns FROM %view%) USING UNIQUE
   oid   USING SRID=-1"
END	

Note that the parameter is referred to as %view% in the mapfile.
Also you can use parameters in WHERE clause.

If you need a session id that is given by PHP or something, you can 
create a small code that just gets the session id and redirects to 
Mapserver with the session id in the query string.


Hope this helps.

Ei


Jan Peters-Anders wrote:
> Hello list,
> 
> I have a question concerning the following problem:
> 
> I have a webapplication that creates (via an SQL query) a view in my PostGres database. Then I display this view via mapserver. Mapfile code looks as follows:
> 
> -----8<-----------------------
> LAYER
>    NAME firmen_psql
>    TYPE POINT
>    STATUS ON
>    CONNECTION "user=blabla password=bla dbname=foo host=localhost port=5432"
>    CONNECTIONTYPE postgis
>    DATA "the_geom from v_iis_over"
> -----8<-----------------------
> 
> That works perfectly. Now I want to have multiple users query the database, creating views according to e.g. a session id, e.g:
> 
> "v_iis_over_[sessionId]"
> 
> Now my problem is, that I would need different mapfiles containing the different table (view) names to accomplish a correct display of the query results for each user. Is it e.g. possible to hand over the new (view) id via an http request? Or do I have to create a new mapfile each time a new session is created?
> 
> Any suggestions are greatly appreciated.
> 
> Thank you very much in advance again
> 
> Jan Peters-Anders
> 
> 

-- 
======================
   Ei Fujioka
   Research Associate
   Duke University

   (919) 613-8021
   efujioka at duke.edu
======================



More information about the MapServer-users mailing list