Hi all,

Here is an interesting problem that I could use some suggestions and/or sample code for. I have a street network where all the street segments are noded at intersections. What I need to extract is all the blocks in the coverage. A "block" is the smallest polygon bounded by segments that does not have any segment crossing it. It could have a cul-de-sac protruding into its interior as long as it does not divide the polygon in two.

I could create a node adjacency list, but I'm not sure if that helps me.

I'm thinking that each edge needs to be tagged with a right and left polygon id, then you can create polygons by grouping on the id.

while (current = get_edge_without_rl_pid) {
  if current.right_side_edge has no pid {
    get new_pid as this_pid
    get other edges from end
    find right most edge
    if edge has id then {
      update all new_pid to id
      mark new_pid as unused
      this_pid = id
    }
    else
      mark both edges as this_pid
  }
  if current.left_side_edge has no pid {
    get new_pid as this_pid
    get other edges from end
    find left most edge
    if edge has id then {
      update all new_pid to id
      mark new_pid as unused
      this_pid = id
    }
    else
      mark both edges as this_pid
  }
}

Does this seem like it would work?
Anyone interested in turning this into plpgsql?

It might be better to recursively pick an edge and recursively walk connected right most edges back onto itself marking the edges as you go. At some point you may still have edges not included in any of the above that can only be marked by walking the left most edges.

Thoughts?

-Steve W
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to