Currently i have created the layer in Geoserver by configuring a native SQL statement, there i am getting the route geometry details from DB by following query

   SELECT ST_MakeLine(route.geom) FROM (
    SELECT geom FROM pgr_fromAtoB('ways', %x1%, %y1%, %x2%, %y2%
  ) ORDER BY seq) AS route

this will give me linestring but along with this i want some other details i.e name of the node etc for that i just modified the query as

 SELECT ST_MakeLine(route.geom),text(route.name) FROM (
    SELECT geom,name FROM pgr_fromAtoB('ways', %x1%, %y1%, %x2%, %y2%
  ) ORDER BY seq) AS route

name above is nothing but the name of the route and text() will returns me the name if each route.But this gives syntax error.How to overcome this issue?


The problem you will have by using ST_MakeLine(route.geom) is, that this function aggregates all geometries into one geometry, but you can't do this for the street name attribute for example, because the street name will probably change from road to road.

So if you want to make more attributes available through Geoserver you can't use ST_MakeLine. Instead you can just use

SELECT * FROM pgr_fromAtoB('ways', %x1%, %y1%, %x2%, %y2%)

But in this case your request will return more than one single linestring and you need to modify the way your route is rendered for example.

| improve this answer | |

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.