I'm trying to reproduce what Underdark did here.
I succesfully installed pgrouting and the two required function (nearest neighbour and driving_distance).
cdv_osm_v contains all the openstreetmap points of my region, from which I select only transportation infrastructure.
taa_2po_4pgr and taa_2po_v contain network and nodes extracted by osm2po for my region.
When I try to run this query in pgAdmin3 I got a syntax error at or near "FOR".
The first select works well, and also driving_distance outputs results fine if called separately.
I'm a noob at postgresql/postgis and I don't know how to pass a geometry to nn() to test it separately (and maybe x,y and factor parameters are not so good).
What am I doing wrong?
CREATE TEMPORARY TABLE nodes_costs (vertex_id integer,edge_id integer,cost double precision);
FOR i IN
SELECT the_geom
FROM cdv_osm_v
WHERE highway like 'bus_stop' OR railway like 'station' or amenity like 'bus_station'
LOOP
INSERT INTO nodes_cost
driving_distance(
'SELECT id, source, target, km AS cost
FROM taa_2po_4pgr',
mm(i.the_geom ,0.0001,2,2,'taa_2po_v','id','geom_vertex'), 0.4, false, false);
END LOOP;
SELECT *
FROM taa_2po_v
JOIN
SELECT vertex_id, min(cost) AS costo
FROM nodes_costs
ON
taa_2po_v.id = nodes_costs.vertex_id;
I forgot: posgresql 9.1, postgis 2.0.1, pgrouting 1.0.5 from kyngchaos.