I've set a WMS server using MapServer that pulls data from PostGIS table which is configured with source and target columns for pgRouting. I've stored a function in the database that returns the geometry of the Dijkstra's shortest path and in MapServer I've set a layer that uses Runtime Substitution to query the stored function. I'm also using OpenLayers to render the map on the browser using the
ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost/cgi-bin/mapserv?map=/home/user/mapdata/mapfile.map',
params: {
'LAYERS': 'Roads,Parks,River,Railroads',
'FORMAT' : 'image/png'
}
})
});
Now I want to be able to click on the map and have a routing layer according to the start click and end click. So in OpenLayers I use ol.Feature and on the click on the map I set the features a geometry using setGeometry() function. What I'm confused about is that if I want to pass these values to MapServer I'm pretty sure MapServer would not understand this since the Runtime Substitution mechanism is configured to accept source and target vertexes and OpenLayers' functions would return geometry. Do I need to write a php script that calculates the shortest vertex in of my click and pass these values to MapServer then? I'm confused about it.