[pgrouting-users] pgr_costresult to geometry

Stephen Woodbridge woodbri at swoodbridge.com
Tue Dec 10 07:39:23 PST 2013

On 12/10/2013 10:18 AM, Petros Apotsos wrote:
> Dear list,
> I am sure this has been answered already, but I am new to this list (and
> pgRouting altogether) and haven't been able to find a suitable answer.
> The question is:
> I am using the 2nd version of the function pgr_trsp to do sequential
> routing between GPS signals on a road network. How can I convert the
> pgr_costresult to a useful geometry type (LINESTRING would be great)?

To get the set of geometries associated with the result set is a simple 

select a.*, b.the_geom
   from pgr_trsp(...) a, myedgetable b
  where a.id2=b.id;

> Bonus questions:
> -What type EXACTLY is the result of this function? Is it a SELECT list?
> An array?

It is a select list more commonly know as a "set of records" or a "set 
of pgr_costresult"

> -Why the heck doesn't pgRouting produce (or include respective functions
> to do so) geometry results, but rather this kind of results. In most
> cases (if not all) it comes down to actually needing such an output.

Because it is trivial to get the geometry using the join above and our 
goal for 2.0 was to clean up and remove lots of code that was not 
general purpose and and well tested or supported. We are looking at 
complaints and question and may add some convenience functions in the 
future but we in general want to take a minimalistic approach in this 
regard and help people learn a little SQL like above when there are 
simple SQL solutions to common problems.

Please ask questions if you get stuck we are happy to help.


> Thank you all in advance,
> *Petros Apotsos*
> Rural & Surveying Engineer
> Technical Chamber of Greece Registry Number 96798
> Τ: 2310 220345
> F: 2310 220346
> Ermou 18A, Postal Code 54624
> Thessaloniki, GREECE
> __________ Information from ESET Smart Security, version of virus
> signature database 9154 (20131210) __________
> The message was checked by ESET Smart Security.
> http://www.eset.com
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users

More information about the Pgrouting-users mailing list