drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
692 stars 90 forks source link

Question: Streetnames to Buildings with Nodes with Streetnames inside #674

Open danielengels opened 1 year ago

danielengels commented 1 year ago

In my application I can visiualize the buildings and the streets with the same color. At the moment I am using PostgreSQL to query the data.

To do this, I don't only query buildings with addr:street or addr:place. I also color polygons with a point or line inside the building polygons that have a unique street- or placename. If needed I can supply a SQL that I use.

Now I saw so many advantages in querying this in the overpass apiOverpass API on my own Serverserver because that will lead to more data and less space requirements and it seems to be much faster then everything I do yet on a few osm2psql databases with little areas.

Since it is possible to use map_to_area, I already get very promissing results.


//Alle Punkte, die Strasse oder Adresse haben, aber kein Gebäude sind
(
  //node["addr:street"]["addr:housenumber"][!"building"]({{bbox}});
  //node["addr:place"]["addr:housenumber"][!"building"]({{bbox}});
  node["addr:street"][!"building"]({{bbox}});
  node["addr:place"][!"building"]({{bbox}});
)->.notBuildings;

//Alle Gebäude mit street/place Namen
(
  nwr["building"]["addr:street"]({{bbox}});
  nwr["building"]["addr:place"]({{bbox}});
);
(._;>;); //Multipoligons für die Buildings erweitern
map_to_area; //Alle Gebäude mit street/place Namen in area kopieren
nwr.notBuildings(area)->.pointsInBuildingWithName; //Alle Punkte selektieren, die nicht schon in Gebäuden mit Straßennamen sind
//nwr.pointsInBuildingWithName;
(nwr.notBuildings;-nwr.pointsInBuildingWithName;)->.pointsWithNameInABuildingWithoutName;
node.pointsWithNameInABuildingWithoutName;
out geom;

This query results me every points that have some street or place names that are in a building without a street or place name.

How I can get the buildings that have points inside with the information I need? I found this useful link (special the last one looks interessting), but really understand them. https://github.com/drolbr/Overpass-API/issues/630 & https://github.com/drolbr/Overpass-API/issues/77 & https://overpass-turbo.eu/s/1bkE

Even if I had the information which polygon have street information within nodes inside the polygon, how do I connect the nodes tags with the building information? After reading the docs I understand, I can't set additional tags to the polygons.

So should I get the list of possible interessting street names and map them to the buildings polygons with some spatial calculation on my own? Maybe with turf js?

But then I need to load so many bulding polygon, that I maybe not need, because I just color the buildings with streetname (and housnumbers).

Any ideas/suggestions for me?

Thanks in advance Daniel

PS: Sorry, I am not a osm/postgis or overpass (and english) expert - so I hope I make clear what I want to do ;) I started this question on gis.stackexchange but the post was deleted because it was not "focused enough" and had two question inside.