How to get/use a Query Result for further processing?

Eric Bridger eric at GOMOOS.ORG
Fri Aug 20 11:38:14 PDT 2004


On Fri, 2004-08-20 at 13:47, Renato F. Salas wrote:
> Hi, I'm just new to MapServer/PostGIS. I've setup the tutorial and have
> a running application using the CGI-BIN mapserver executable.
>
> As far as I know I can only make queries and display the results on a
> Template with the appropriate tags that just point to the columns on the
> table where the geometries (the_geom) data resides.
>
> What I would like to do is to get the result somehow (just the ID of
> the_geom) for doing something else, like generating a SELECT on a
> related table using PostgreSQL/PostGIS to show, say, all the reported
> cases in that particular point, with pictures, sounds, and more stuff
> not available in the geom table. For doing that I'd probably use a
> scripting language like ASP or PHP.
>
> I think this should be a trivial scenario but I can't find any
> documentation on the web. I would like to avoid using PHP/Mapscript just
> to keep it simple.  Any ideas would be appreciated.

It's not such a trivial scenario because it is mapserver which is
parsing the template on the server, substituting your database values
into the various [column_name] tags then returning HTML.  There is no
mechanism to get PHP or JSP to then parse the page as well (as far as I
know).  That leaves you with using client side techniques e.g.
Javascript or an IFRAME src e.g. a javascript function like:
onload=redirect_page([key_val_column]) which could call another script
with the key value passed.

Another approach is that your PostGIS DATA statement can contain a
subquery which joins the table with your geometries with any other
tables with the values you want.

DATA "the_geom from (select the_geom, the_other_value from geom_table
join other_table on (key = other_key)) using unique oid using SRID=-1"

Eric



More information about the MapServer-users mailing list