I have a Shapefile (consisting of European major roads) with about 250.000 Segments which I have to simplify for pgrouting. But I can't seem to find a way to do that properly.
This is what it looks like:
and this is what it should look like:
I somehow have to remove every Point of the Lines which is connected to less than 3 Lines (being not an intersection) while preserving the topological connections between the remaining points. If anybody has an idea, it would be greatly appreciated!
Best regards
EDIT: I tried to implement the idea of @dkastl and managed to get only the unneccessary nodes (nodes with only 2 adjacent linestrings) from my network with the code below (network generation taken from underdark's blog http://underdark.wordpress.com/2011/02/07/a-beginners-guide-to-pgrouting/):
SELECT * FROM
(SELECT tmp.id as gid, node.the_geom FROM
(SELECT id, count(*) FROM network
JOIN node
ON (start_id = id OR end_id = id) AND (end_id = id OR start_id = id)
GROUP BY id ORDER BY id) as tmp
JOIN node ON (tmp.id = node.id)
WHERE tmp.count = 2) as unn_node;
So, all I now have to do is the merging of the lines. However, I have no clue how. I imagine it has to be a loop which for every row of the result of above query gets the adjacent lines and merges them. Then it would rebuild the network completely and repeat the process until the query above returns an empty result.
No comments:
Post a Comment