drolbr / Overpass-API

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

How to out Lat/Lon to CSV using the 'make' feature? #588

Closed DaveF63 closed 3 years ago

DaveF63 commented 4 years ago

Hi How do I out Lat/Lon to CSV using the 'make' feature?

Specifically in this example if it were adapted to only return amenity=pharmacy nodes:

https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#Wiki_table_generator_.28since_0.7.54.29

drolbr commented 3 years ago

See line 26 of

[out:csv(_row;false)];

make out _row = "{|class=wikitable    "; out;
make out _row = "|-                   "; out;
make out _row = "! Regional Key       "; out;
make out _row = "! (Lat Lon)          "; out;
make out _row = "! Name               "; out;
make out _row = "! Total              "; out;
make out _row = "! Nodes              "; out;
make out _row = "! Ways               "; out;
make out _row = "! Relations          "; out;

//All areas with regional key (German: "Regionalschlüssel") starting with 057
area["de:regionalschluessel"~"^05774"];

// Count the pharmacies in each area
foreach->.regio(
  // Collect all Nodes, Ways and Relations wth amenity=pharmacy in the current area
  ( node(area.regio)[amenity=pharmacy];
    way(area.regio)[amenity=pharmacy];
    rel(area.regio)[amenity=pharmacy];) -> .r;

  make out _row = "|-"; out;
  make out _row = "| " + regio.set(t[ "de:regionalschluessel"]) + 
                  " || " + r.set("(" + lat() + " " + lon() + ")") +
                  " || " + regio.set(t["name"]) + 
                  " || " + (r.count(nodes) + r.count(ways) + r.count(relations)) + 
                  " || " + r.count(nodes) + 
                  " || " + r.count(ways) +
                  " || " + r.count(relations); 
  out;

);
make out _row = "|}"; out;