1

I want to get all parts of a given street.

I use a query like: Select * from planet_osm_lines where name = 'mystreet'

As a result I get all the LineStrings that are part of a street with the given name, but somehow I have to group the LineStrings to form the correct MultiLinestrings, because there could be other streets with the name "mystreet".

Does someone know how to get this information?

  • 3
    You could check iteratively if line segments touch each other by using "ST_StartPoint" and "ST_EndPoint" or "ST_Touches". If so, then merge the lines and you should be able to group them. – zehpunktbarron Feb 19 '15 at 12:25
  • that sounds like a possible way, thank you. But isn't this information maybe stored in any Relationship or something like this? – Shachty Feb 19 '15 at 13:03
  • 2
    Streets ade not modelled as relations in OSM. What C.B. suggests is the best that you can do. – user30184 Feb 19 '15 at 13:37
1

You could use ST_LineMerge http://postgis.net/docs/ST_LineMerge.html

First you need join all your ways into one MultiLineString using ST_DUMP http://postgis.net/docs/ST_Dump.html and ST_Multy

Afterwards use ST_LineMerge to get a set of Linestrings of maximum length sewed from segments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.