[OpenLayers-Users] PostgreSQL dynamic layer

David William Bitner bitner at gyttja.org
Thu Nov 2 08:36:17 EST 2006


You might want to try using the MapServer direct layer:
http://openlayers.org/dev/examples/mapserver.html

Then set up your data string in your mapfile to use variable substitution to
contain your session id
(read the mapserver manual for variable sub and for the postgis data
statement syntax as this is coming from my head)
so your data string would be something like
DATA "the_geom from (select * from my table where mysessionid=%SESSIONID%)
as foo using unique oid using srid 4326"

Then in openlayers you would add a parameter to your layer string:
{layers:'mylayer',sessionid:'234255464564'}

You could then use MergeNewParams (see
http://openlayers.org/dev/examples/wmst.html for example) to change your
sessionid as you add new routes to the table.

As I said, take this as a general road map and check the docs, I can
guarantee I butchered some syntax,

bitner
On 11/2/06, Moser Adrian <Adrian.Moser at bs.ch> wrote:
>
> Hi list,
>
> I already posted this question once but couldn't solve the problem.
> I'm implementing a routing application based on PostgreSQL/PostGIS. The
> routes are stored temporarily in a Postgres table together with the current
> session-ID. I then included this table in a Mapserver Layer which I want to
> show with OpenLayers. The problem is that could be different routes in the
> table and I just want to display the one belonging to the current session.
> There is a parameter expression that can be set in the .map file but I
> need to do this dynamically.
>
> Mapserver Layer:
>
> LAYER
>       NAME path
>       CONNECTIONTYPE POSTGIS
>       CONNECTION "user=xxx password=xxx dbname=xxx host=localhost
> port=5432"
>       DATA "the_geom from routingrouten"
>
>       PROJECTION
>         "init=epsg:4326"
>       END
>       STATUS ON
>       TYPE LINE
>
>       CLASS
>         NAME 'path'
>               STYLE
>           COLOR 0 255 0
>           WIDTH 3
>         END
>       END
>       METADATA
>         "wms_title" "path"
>       END
> END
>
> JavaScript function:
>
> function showRoute(sessId) {
>   //Berechente Route anzeigen
>   wms_path = new OpenLayers.Layer.WMS("path",
>     '
> http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/nafmomNeu/map/nafmom.map
> ',
>     {LAYERS: 'path', format: 'png', transparent: 'true'},{'buffer':1});
>   map.addLayer(wms_path);
> }
>
> Is there a possibility to do this?
>
> I noticed that if I display a route (currently all routes are displayed)
> and the recalculate the route with slightly other start and end point an
> display it OpenLayers still shows the old route. It display to show a cached
> tile. How can I solve this problem?
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
************************************
David William Bitner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20061102/66c86730/attachment.html


More information about the Users mailing list