[pgrouting-users] Function to result routes/costs from single_origin to multi-destinations

AUS - Eyad b00038807 at aus.edu
Sat Nov 15 00:12:29 PST 2014


Thank you Daniel, and All..

 

I rephrased the code and adjusted it accordingly:

 

select

    id,

    the_geom,

    (pgr_kdijkstraCost(

    'SELECT id, source, target, st_length(geom) as cost FROM schema.cvl',

    1, array[98, 100, 220, 320, 650], false, false

  )) as cost

from schema.cvl_vertices_pgr WHERE id=1

 

Here I could calculate the costs of different destinations from the source_point#1, but I still seek advices, as follows:

 

1)      Is there a way to automatically insert all the destination/target points in the array? I tried ‘SELECT id FROM schema.cvl_vertices_pgr’, but didn’t work!

2)      I transferred the vector and points features from AutoCAD. How can I control the units (i.e. I used meters in CAD but it seems to be millimeters here – e.g. Cost to point#98 = 112959.0)

3)      I tried the same contents of the function on “pgr_kdijkstraPath” but it didn’t work! What could be the problem?

 

Regards,

 

Eyad

 

 

From: pgrouting-users-bounces at lists.osgeo.org [mailto:pgrouting-users-bounces at lists.osgeo.org] On Behalf Of Daniel Kastl
Sent: Monday, November 10, 2014 4:11 AM
To: pgRouting users mailing list
Subject: Re: [pgrouting-users] Function to result routes/costs from single_origin to multi-destinations

 

 

 

On Mon, Nov 10, 2014 at 3:42 AM, AUS - Eyad <b00038807 at aus.edu> wrote:

While applying the following tutorial: http://anitagraser.com/2011/02/09/creating-catchment-areas-with-pgrouting-and-qgis/ utilizing vector network which has been tested (and demonstrated functionality) for shortest path application, it returned the following message:

Hi, 

 

I think the tutorial was written before pgRouting 2.0 was released.

It may require some changes.

 

 

 

LAST COMMENT.. If you know another code/method that helps in multi-routing from one point to list of targets to result routes and costs from single-origin (source) to multi-destinations (targets), please provide guidance.. origins and destinations are in a single points feature (i.e. cvl_vertices_pgr), whereas routes calculation shall take place in lines feature (i.e. cvl).


	
	

 

 

If you need 1 -> n shortest path queries, then you could try pgr_kDijkstra:

http://docs.pgrouting.org/2.0/en/src/kdijkstra/doc/index.html#pgr-kdijkstra

 

Best regards,

Daniel

 

 

 

-- 

Georepublic UG & Georepublic Japan
eMail:  <mailto:daniel.kastl at georepublic.de> daniel.kastl at georepublic.de
Web:  <http://georepublic.info> http://georepublic.info

 

 

 

Original Message:

 

While applying the following tutorial: http://anitagraser.com/2011/02/09/creating-catchment-areas-with-pgrouting-and-qgis/ utilizing vector network which has been tested (and demonstrated functionality) for shortest path application, it returned the following message:

Query returned successfully: 1013 rows affected, 199 ms execution time

but returned no table as output!

The code I used is:

create table catchment_1 as select id, the_geom, (select sum(cost) from ( SELECT * FROM pgr_dijkstra( 'SELECT id, source, target, st_length(geom) as cost FROM schema.cvl', 1, 320, false, false )) as foo ) as cost from schema.cvl_vertices_pgr 

I also tried passing "id" to the function instead of "320" as per the tutorial but got the following msg:

ERROR: function pgr_dijkstra(unknown, integer, bigint, boolean, boolean) does not exist SQL state: 42883

Although, pgr_dijkstra is working well with other codes.. so, it's one of the recognized functions in my installed pgRouting layer

I'm using QGIS 2.0.1 and pgRouting pg93-binaries-2.4.0

 

In order to gradually test the code, I started by the inner SELECT then went up step by step.. I got result table for each step until I reached the highest SELECT in the structure.. I got a table showing the cost for each point_id. the special result is a point feature.. but what drew my attention in the result table is that all costs are exactly the same '32430.028' whereas the points are non-regularly distributed.. This means that I just needed to remove 'create table catchment_1 as' to get a result table, but still the cost values do not seem to make sense.

 

LAST COMMENT.. If you know another code/method that helps in multi-routing from one point to list of targets to result routes and costs from single-origin (source) to multi-destinations (targets), please provide guidance.. origins and destinations are in a single points feature (i.e. cvl_vertices_pgr), whereas routes calculation shall take place in lines feature (i.e. cvl).


	
	

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20141115/7cdcdcfc/attachment.html>


More information about the Pgrouting-users mailing list