[pgrouting-users] Create network with nodes at least every 50m

Adam Lawrence alaw005 at gmail.com
Sun Aug 24 18:09:31 PDT 2014


Hi,

Thank you Stephen/Ian for your advice. I have spent the morning on this and
have tried rewriting my function (below) using ST_Dump and
pgr_createTopology. This seems to generate records but each entry seems to
have the same source and target (I also need to calculate the distance to
apply pgrouting). The networkreach functions might be useful if these could
be applied at both ends, and a little beyond my ability to understand. Any
ideas on what am I doing wrong below?

Regards
Adam



-- Create noded network from existing network but with regular spacing
between nodes
CREATE OR REPLACE FUNCTION createSpacedNodeNetwork(edgeTableName text,
geomFieldName text, spacing double precision)
RETURNS TABLE (
    id integer,
            source bigint,
            target bigint,
            distance double precision,
            the_geom geometry
) AS
$BODY$
DECLARE
-- nothing to declare here
geom1 geometry;
BEGIN

-- Create a temporary table for the network whilst we process it
-- DROP on commit so we do not get problems reusing it again in this session
DROP TABLE IF EXISTS temp_edge_table;
CREATE TABLE temp_edge_table (
    id serial,
            source bigint,
            target bigint,
            distance double precision,
            the_geom geometry
); -- ON COMMIT DROP;

-- Segementise and insert into temp table, note use of ST_Dump to split
multipart
EXECUTE 'INSERT INTO temp_edge_table(the_geom) SELECT
(ST_Dump(ST_Segmentize(' || geomFieldName || ', ' || spacing || '))).geom
FROM ' || edgeTableName;

-- Now create topography

PERFORM  pgr_createTopology('temp_edge_table', 0.00001, 'the_geom', 'id');


--Return temp table results to calling function
RETURN QUERY SELECT * FROM temp_edge_table;
END;
$BODY$
LANGUAGE plpgsql;

DROP TABLE IF EXISTS roads_spacednodes;
SELECT * INTO roads_spacednodes FROM
createSpacedNodeNetwork('roads','geom',0.050);

SELECT * FROM roads_spacednodes order by source, target, id;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20140825/f51c2bac/attachment.html>


More information about the Pgrouting-users mailing list