[pgrouting-users] pgr_costresult to geometry

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)?

Bonus questions:

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

-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.

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

On Wed, Dec 11, 2013 at 12:18 AM, Petros Apotsos <petrosapotsos@gmail.com>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)?

Hi Petros,

This chapter in the workshop might answer your question:
http://workshop.pgrouting.org/chapters/wrapper.html#return-route-with-network-geometry

Bonus questions:

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

The result type is a "set of records":
http://docs.pgrouting.org/2.0/en/src/common/doc/types/cost_result.html#type-cost-result

You can use the result like a SELECT result.

-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 there is such a variety of network data and each data might have
different column names, projections, etc.. For Dijkstra algorithm you even
don't need a geometry. Your network could be something totally abstract.

So pgRouting tries to make as less assumptions as possible.
In the previous version there were several "wrapper" functions, but it was
extra work to maintain them.
It's really easy to link your result with the original table, so once you
know how it works, you will hopefully agree. :wink:

Hope this helped.
Regards.
Daniel

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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

--
Georepublic UG & Georepublic Japan
eMail: daniel.kastl@georepublic.de
Web: http://georepublic.de

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 join:

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.

-Steve

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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users