Query all places and their streets

63 Views Asked by At

I want to build a registry of places (city, town, village) and their street names (limited to germany). My first attempt was to get all places and then query for the streets like this:

[out:json];
area[name="Bremen"];
node[place~"city|town|village"](area);
out;

But this will not work because names are not unique. E.g. there is a town and also a village named Bremen (and even some in USA) and you can't mix that up if you want proper results. Next I tried this:

[out:json];

// Find all nodes representing cities
area[name="Bremen"]->.a;
node(area.germany)[place~"city|town|village"];

// For each city node, find the streets within a certain radius
foreach {
    // Query for streets within a radius of 5000 meters from each city node
    way(around:5000)[highway][name];
    /*added by auto repair*/
    (._;>;);
    /*end of auto repair*/
    out;
}

But this just gives me streets in the radius even if they do not belong to the city. Should I go with the first attempt and post-process the data (e.g. cluster the nodes for cities with ambiguous names geographically)? Is there a better way or query to archive it?

0

There are 0 best solutions below