Is it possible to query a PostGIS database from a browser where I set the extents of the map?
I have previously queried a PostGIS database from the browser and, separately, used mapserver to display a raster using a WMS query. Now I'm wondering if I can join these two separate pieces together. The part that I am not understanding is how to insert the query into the Mapserver code. For example, if my mapserver layer piece is as follows:
LAYER # start layer CONNECTIONTYPE postgis NAME "roads CONNECTION "user=username password=**** dbname=databasename host=hostdb.com port=5434" DATA "geom from tablename where ST_Intersects(geom, mapextents)" STATUS ON TYPE LINE CLASS STYLE COLOR 0 0 0 END END END # end layer
How can I dynamically supply the value of mapextents to the Mapserver file? I have considered the
.map piece usually to be static but perhaps this is incorrect.
An example of the type of query that I want to perform is as follows:
SELECT ST_Clip(r.rast, 'POLYGON((-8293673 4952790,-8137619 4952790,-8137619 5036076, -8293673 5036076,-8293673 4952790))'::geometry) FROM raster AS r WHERE ST_Intersects(r.rast, 'POLYGON((-8293673 4952790,-8137619 4952790,-8137619 5036076, -8293673 5036076,-8293673 4952790))'::geometry)
Secondly, where should I be storing the
.map file? At the moment I have them in a web readable folder but I know this is not a good strategy once I need to store a password.