I'm trying to make a matrix that shows the cost from a node to the rest of the nodes in a network.
The final result I'm looking for is not the cost, but only know if a car can or can not reach each vertex.
I've made a test in a small area of my network, and it seems to work perfectly. I get the cost from a node to the rest, and if can't reach it, only leaves the value as NULL
, then I can set this value to false.
The problem is where I try to extend this methodology to the rest of the network, I get an error showing that the target vertex was not found
.
Why is pgRouting saying this, if I'm doing the same analysis?
The steps I've followed are:
--creating topology
ALTER TABLE "3prueba" ADD COLUMN "source" integer;
ALTER TABLE "3prueba" ADD COLUMN "target" integer;
SELECT pgr_createTopology('3prueba', 0.00001, 'geom', 'id');
--(I already have the cost field)
--indexes
CREATE INDEX vials3_source_indx ON calles("source");
CREATE INDEX vials3_target_indx ON calles("target");
--and
create table "3catchment82" as
select
id,
the_geom,
(select sum(cost) from (
SELECT * FROM pgr_dijkstra('
SELECT id AS id,
source::int4 AS source,
target::int4 AS target,
coste::float8 AS cost
FROM "3prueba" where mostrar = 1
', --<-- show only roads
82, --<-- specify node
id::int4,
false,
false)) as foo ) as cost
from "3prueba_vertices_pgr"
This are the steps I've followed.
The main idea is get the costs only for the roads with the field "mostrar=1", as I show in the image. If the road is closed (mostrar=0) it can not reach the node. So, the red road is closed, and can not reach nodes 58, 59, 5...
After this,I'll change the roads. So, I can get a matrix when some roads are closed, other matrix when other roads are closed, etc.
When I apply this analysis to the rest of the network, I get the error.
Any Idea of what am I doing wrong, or what would be the correct way to do this?
After @underdark advice, it seems to work.
I've run the model applying a high cost to the 'closed' roads, and seems to be ok.
I've seen that there are 3 types of output:
In green: nodes that the source reaches.
In red: nodes that source do not reach.
In orange: nodes disconnected. The values was NULL.