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

I was reading some parts of the doc of this c++ lib, and was wondering if there was a way to query the osm server to get the result (for example) of this query in json:

 [out:json][timeout:25]; // gather
 results (   // query part for:
 “type=route and route=bus”  
 relation["type"="route"]["route"="bus"]({{bbox}});
 );

asked 04 Apr '19, 18:46

Clement's gravatar image

Clement
11112
accept rate: 0%

edited 05 Apr '19, 10:54

scai's gravatar image

scai ♦
33.3k21309459


Libosmium does not have a networking component, it doesn't talk to any servers. If you want to process the result of the overpass query in your question with libosmium then you'd have to use a different library to execute the HTTP query and then you could feed the response into libosmium for parsing. However, you would not use JSON output for that but raw OSM output - libosmium reads OSM, not JSON.

Libosmium provides you with a framework that would allow you to easily extract all bus routes from a country-wide OSM file or even the planet file, without having to query any servers. The osmium command line utility, which is built with the libosmium library, has a "tags-filter" mode that can do what you want.

permanent link

answered 04 Apr '19, 19:01

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

2

On Linux and MacOS (but not on Windows), you can give a URL to libosmium instead of a file name and it will use curl in the background to get the data for you. It is still better to use a HTTP library, because the libosmium-internal way doesn't tell you about errors, but for quick-and-dirty code it is rather convenient.

(05 Apr '19, 08:28) Jochen Topf

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:

×38
×10

question asked: 04 Apr '19, 18:46

question was seen: 1,841 times

last updated: 05 Apr '19, 10:54

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