I've managed to get all the SQL queries necessary to get the shortest path with Dijkstra using pgRouting, but now I want to implement them in my website using OpenLayers 3 and GeoServer 2.8.2

The first thing that got in my mind was to use the SQL Views but I don't know whether it's the best solution or if it is possible.

Then I thought about using WPS but I'm not used to it.

So if anyone have already faced the same problem could you help please?


You can use Geoserver with views and using parameters to pass, for example, start and destination points.

The trick is to use GetFeature WFS request and get (one) geojson response to simply create your layer with OL3. All can be done client-side with Javascript and an ajax request.

You may prefer jsonp to allow cross-site AJAX with JSON data. see here

  • Thanks, but I have to execute 10 queries to get the path as I want it, is it possible to execute more than 1 query in an SQL View ? – Hicham Zouarhi Mar 29 '16 at 8:56
  • @Hicham You can use PostgreSQL function, passing parameters to it, where all the process is done, avoiding many queries. – WKT Mar 29 '16 at 9:34
  • I thought about that too, but still didn't try it. although plpgsql is a little bit tricky but I wanted to make sure there wasn't another solution for it. – Hicham Zouarhi Mar 29 '16 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.