Closed JLErvin closed 7 years ago
Well, if you run the function with *
instead of seq, node, edge, cost
, you will see all columns returned and the error should go away.
SELECT * FROM pgr_kdijkstraPath(
'SELECT gid as id, source, target,length as cost FROM ways',
100, array[10,20], false,false
);
pgr_kdijkstraPath
returns different set of attributes than pgr_dijkstra
.
I am still getting an error:
ERROR: Error, columns 'source', 'target' must be of type int4, 'cost' must be of type float8
Hello @JLErvin
I see you are using pgRouting Version 2.1. You must have your reasons of doing that. I strongly recommend that you use the latest version, currently is V2.4.
this is wrong:
SELECT seq, node, edge, cost
FROM pgr_kdijkstraPath(
'SELECT gid as id, source, target,length as cost FROM ways',
100, array[10,20], false,false);
In version 2.0 & 2.1:
columns 'source', 'target' must be of type int4
Please read the kdijkstra dpcumentation and the pgr_costResult3 documentation The pgr_kdijkstraPath and pgr_kdijkstraCost are deprecated since v2.2, see the changelog
On V2.1, you can use the pgr_dijkstra(one to many) instead of pgr_kdijkstraPath
So instead of this:
SELECT * FROM pgr_kdijkstraPath(
'SELECT gid::INTEGER as id, source::INTEGER, target::INTEGER, length::FLOAT as cost
FROM ways',
100, array[10,20], false,false
);
use this:
SELECT * FROM pgr_dijkstra(
'SELECT gid as id, source, target, length as cost FROM ways',
100, array[10,20], directed:=false
);
I am closing this issue because pgr_kdijkstraPath
was deprecated on V2.2 and the current version is V2.4.
Hello,
I am able to get pgRouting to work with pgr_dijkstra. In my psql database I can successfully run:
SELECT seq, node, edge, cost FROM pgr_dijkstra('SELECT gid as id, source, target,length as cost FROM ways',100, 500, false);
However, I do not just want to calculate the distance between two nodes. I want to be able to take one node, and find the nearest node from a set of destination nodes. I have tried to use pgr_kdijkstraPath to no avail. Here is the code that does not work.
SELECT seq, node, edge, cost FROM pgr_kdijkstraPath('SELECT gid as id, source, target,length as cost FROM ways',100, array[10,20], false,false);
This returns the following result:
ERROR: column "node" does not exist"
This is confusing, because it does not seem like there should be any difference between the two.
I am currently running: PostgresSQL 9.5.6 PostGIS 2.3.3 pgRouting 2.1.0 Ubuntu 16.04