select ways as nodes with way center as node coords

385 views Asked by At

how can I select ways as nodes with way center coords as node coords?

currently my query looks like this:

[out:json];
way
  [amenity=drinking_water]
  ({{bbox}});
out center;

and my data looks like this:

{
  "type": "way",
  "id": 123,
  "center": {
    "lat": 1.23,
    "lon": 4.56
  },
  "nodes": [
    ...
  ],
  "tags": {
    "name": "test"
  }
}

but I need the data formatted like this:

{
  "type": "node",
  "id": 123,
  "lat": 1.23,
  "lon": 4.56,
  "tags": {
    "name": "test"
  }
}

any idea how to convert the data with overpass?

Background:

I like to convert the overpass data to gpi but it seams that gpsbabel can not convert osm ways to waypoints for gpi.

I just get errors like this: osm: Way reference id "123" wasn't listed under nodes!

1

There are 1 answers

5
scai On

I guess the problem here is that gpsbabel doesn't understand center in your response. Instead it tries to read all nodes and their coordinates. But your response doesn't include any nodes, just references to them.

You could modify your query to return all necessary nodes, too, instead of only the way's center:

[out:json];
way
  [amenity=drinking_water]
  ({{bbox}});
(._;>;);
out;

This response should then be parsable by gpsbabel but I'm not sure if it is the response you are looking for.