NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hello,

I have this query,
area["name"="Greater London"];
way(area)["amenity"="restaurant"]->.all;
( .all; - ._; );
(._;);
out geom;

which return me this result

<way id="4270351">
    <bounds minlat="51.6322589" minlon="-0.0381454" maxlat="51.6327917" maxlon="-0.0376948"/>
    <nd ref="25637026" lat="51.6327251" lon="-0.0379737"/>
    <nd ref="25637027" lat="51.6327917" lon="-0.0377806"/>
    <nd ref="25637029" lat="51.6326585" lon="-0.0376948"/>
    <nd ref="25637030" lat="51.6323298" lon="-0.0378665"/>
    <nd ref="25637032" lat="51.6322589" lon="-0.0380668"/>
    <nd ref="25637034" lat="51.6324054" lon="-0.0381454"/>
    <nd ref="25637026" lat="51.6327251" lon="-0.0379737"/>
    <tag k="amenity" v="restaurant"/>
    <tag k="building" v="block"/>
    <tag k="created_by" v="JOSM"/>
  </way>

Is there a way get same but without ND tags? like this:

 <way id="4270351">
    <bounds minlat="51.6322589" minlon="-0.0381454" maxlat="51.6327917" maxlon="-0.0376948"/>
    <tag k="amenity" v="restaurant"/>
    <tag k="building" v="block"/>
    <tag k="created_by" v="JOSM"/>
  </way>

I will get needed lat lon from <bounds>, and in this case i don't want to get ND's because this tags make returned data heavy

asked 26 Jan '18, 14:29

davittorosyan's gravatar image

davittorosyan
51448
accept rate: 0%


the ND-tags are the nodes. If you just want the center of the way, you could use "out center" instead of "out geom".

I'm not sure whether you can get the bounding box without the nodes. Both are part of the "out geom" statement

permanent link

answered 26 Jan '18, 14:34

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

edited 26 Jan '18, 14:36

and if you want all restaurants, you should also adapt your query to search for nodes and relations tagged with "amenity restaurant". So why not use this query instead ?

The query was almost completely constructed with the Wizard from "Overpass Turbo", I just replaced "geom" with "center" in the last line

(26 Jan '18, 14:39) escada

"out center" this is good solution tho have center point for each way, this will save my CPU to calculate center coordinate from <bounds> tag. But my problem little another now, i just don't want receive ND(node) tags, because instead of 5,000 lines XML file i receiving about 30,000(because this ND's very lot in each WAY tag) is there any solution to remove them from way tag but keep < center > tag?

without ND's but with all other tags(inlcuding < center > tag)

(26 Jan '18, 15:37) davittorosyan

did you take the take to look at the data from the query I linked to ? There are no ND tags when you use out center

(27 Jan '18, 19:06) escada

yes, thank you for example, but sorry, I cant use this csv:out format for getting data ... because my parsers working with XML, but main reason, i dont want use out:csv, because each way object can have different parameters, phone, fax, opening_hours etc... but in your example i should predefine fields

[out:csv( ::"id", ::lat, ::lon, name, cuisine, operator, "contact:website", "contact:phone"; true; "|" )];

is there another way to have my wanted format? Or its impossible? thank you

(27 Jan '18, 19:24) davittorosyan

The query I link to returns XML. (see "this query" two comments back)

And as for the output formats, please try the different output statements that are shown in the documentation if the format that you want is not between them, you can perhaps create a feature request.

And otherwise, the extra data can easily be ignored by any decent XML parser. I doubt that your computer cannot handle the extra information in a quick way. 5000 lines of XML is nothing for today's CPUs

(27 Jan '18, 19:36) escada

Thank you for answer, i will check is this solution for me.

(27 Jan '18, 19:58) davittorosyan
showing 5 of 6 show 1 more comments

I don't know how to get rid of the node references (nd) as you ask for output, but I guess that what you want is a kind of csv-like output with the info of the ways for restaurants. In that case, you have the csv output mode.

For your example, you could try with:

[out:csv(
::"id", ::lat, ::lon, name, cuisine, operator, "contact:website", "contact:phone";
    true; "|"
  )];
area["name"="Greater London"];
way(area)["amenity"="restaurant"]->.all;
( .all; - ._; );
(._;);
out center;

If you delete the

; "|"

you will get the fields separated by a tab. You can also substitute the | by another string that suits you better.

You have much more info on that csv mode here, specially about the fields you can add...

I hope this suits you.

permanent link

answered 26 Jan '18, 14:58

edvac's gravatar image

edvac
6652619
accept rate: 15%

edited 26 Jan '18, 15:07

One of stackoverflow OSM developers find the solution, just need write "tags" in OUT:

out tags;

(28 Jan '18, 15:23) davittorosyan

Ah! Good! Didn't know that option :)

(28 Jan '18, 18:10) edvac

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×228
×167
×91
×65

question asked: 26 Jan '18, 14:29

question was seen: 4,403 times

last updated: 28 Jan '18, 18:10

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum