I am running a query for Ways by name using a regex. I recurse down to get the nodes and all data returned appears fine with the exception that the one "road" with the one name thats being queried returned multiple ways. Ultimately all the ways attach and is physically the same "road". I am using this as a typeahead for a user to select a "road" and then later I will use that "road" they selected to offer them a list of other Ways that intersect with this "road"... As you can probably see when I run the later query for a list of intersecting Ways i cannot just simply reference just one Way ID from the initial query as there are many Ways that represent what a user would consider the "road" they were looking for... Am I missing anything? Is there any sort of "Parent" way that can be referenced. Why is one road represented as more than one Way? Is it simply a data quality issue that someone needs to merge them or is this by design? Is there any way in the API for me to write my followup query that starts with one of the ways at random but then basically say (in pseudocode)

Give me way # 1234, plus any ways that have the same name as 1234 and share at least one node (meaning they are truly one "Road")
->then return me a list of Ways that intersect with those ways.

I can figure out the query to get the intersections, the more important part is trying to treat the initial way as one single road.

Initially I was thinking I would handle the merge of the Ways in my code and sort of cache a "parent" way that all the individual ways would be children of and then my second query would basically list all the individual ways. Seems like its more complicated for me to do manually and i'm thinking there must be a way to handle this natively in the API...

  • Yes you can do it with the complete statement, although I’m not sure this is suitable for a type ahead scenario, as it creates too much load. Are you running your own server? Having multiple ways for a road is perfectly fine in OSM. – mmd Jun 2 '18 at 20:23
  • Yes have my own server instance running. :-) – snoop168 Jun 2 '18 at 20:31
  • 1
    Sounds good. You may want to take a look at my complete demo, which retrieves all ways with the same name for a given start point: github.com/mmd-osm/complete_demo – mmd Jun 3 '18 at 7:41
  • @mmd : quite impressive demo for that feature! Have a look for example at Germany - Berlin - Grolmanstraße – stephan75 Jun 3 '18 at 20:31

With the help of @mmd it looks like the query to get all ways for the same road is the following:

(._;.result;)->.result;);.result out;

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