Skip to content

Commit 330ed80

Browse files
committed
re-adding RST doc (generated using pandoc from md file), fixes mvexel#67
1 parent cc72e13 commit 330ed80

File tree

4 files changed

+142
-58
lines changed

4 files changed

+142
-58
lines changed

.gitignore

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,13 @@
1-
*~
2-
*.swp
31
.DS_Store
4-
5-
# Byte-compiled / optimized / DLL files
2+
.pytest_cache/
63
**/__pycache__/
74
*.py[cod]
8-
9-
# C extensions
10-
*.so
11-
12-
# Distribution / packaging
13-
.Python
14-
env/
15-
build/
16-
develop-eggs/
175
dist/
18-
downloads/
6+
build/
197
eggs/
208
.eggs/
21-
lib/
22-
lib64/
23-
parts/
24-
sdist/
25-
var/
269
*.egg-info/
27-
.installed.cfg
2810
*.egg
29-
30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
3711
pip-log.txt
38-
pip-delete-this-directory.txt
39-
40-
# Unit test / coverage reports
41-
htmlcov/
42-
.tox/
43-
.coverage
44-
.cache
45-
nosetests.xml
46-
coverage.xml
47-
48-
# Translations
49-
*.mo
50-
*.pot
51-
52-
# Django stuff:
53-
*.log
54-
55-
# Sphinx documentation
5612
docs/_build/
57-
58-
# PyBuilder
59-
target/
60-
61-
Pipfile.lock
62-
63-
.vscode/
13+
Pipfile.lock

.pytest_cache/v/cache/lastfailed

Lines changed: 0 additions & 1 deletion
This file was deleted.

.pytest_cache/v/cache/nodeids

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.rst

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
Overpass API python wrapper
2+
===========================
3+
4+
This is a thin wrapper around the OpenStreetMap `Overpass
5+
API <http://wiki.openstreetmap.org/wiki/Overpass_API>`__.
6+
7+
|Build Status|
8+
9+
Install it
10+
==========
11+
12+
``pip install overpass``
13+
14+
Usage
15+
-----
16+
17+
Simplest example:
18+
19+
.. code:: python
20+
21+
import overpass
22+
api = overpass.API()
23+
response = api.get('node["name"="Salt Lake City"]')
24+
25+
``response`` will be a dictionary representing the JSON output you would
26+
get `from the Overpass API
27+
directly <https://overpass-api.de/output_formats.html#json>`__.
28+
29+
Note that the Overpass query passed to ``get()`` should not contain any
30+
``out`` or other meta statements.
31+
32+
Another example:
33+
34+
.. code:: python
35+
36+
>>> print [(
37+
... feature['properties']['name'],
38+
... feature['id']) for feature in response["features"]]
39+
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637)]
40+
41+
You can find more examples in the ``examples/`` directory of this
42+
repository.
43+
44+
Response formats
45+
~~~~~~~~~~~~~~~~
46+
47+
You can set the response type of your query using ``get()``\ ’s
48+
``responseformat`` parameter to GeoJSON (``geojson``, the default),
49+
plain JSON (``json``), CSV (``csv``), and OSM XML (``xml``).
50+
51+
.. code:: python
52+
53+
response = api.get('node["name"="Salt Lake City"]', responseformat="xml")
54+
55+
Parameters
56+
~~~~~~~~~~
57+
58+
The API object takes a few parameters:
59+
60+
``endpoint``
61+
^^^^^^^^^^^^
62+
63+
The default endpoint is ``https://overpass-api.de/api/interpreter`` but
64+
you can pass in another instance:
65+
66+
.. code:: python
67+
68+
api = overpass.API(endpoint=https://overpass.myserver/interpreter)
69+
70+
``timeout``
71+
^^^^^^^^^^^
72+
73+
The default timeout is 25 seconds, but you can set it to whatever you
74+
want.
75+
76+
.. code:: python
77+
78+
api = overpass.API(timeout=600)
79+
80+
``debug``
81+
^^^^^^^^^
82+
83+
Setting this to ``True`` will get you debug output.
84+
85+
Simple queries
86+
~~~~~~~~~~~~~~
87+
88+
In addition to just sending your query and parse the result, the wrapper
89+
provides shortcuts for often used map queries. To use them, just pass
90+
them like to normal query to the API.
91+
92+
MapQuery
93+
^^^^^^^^
94+
95+
This is a shorthand for a `complete ways and
96+
relations <https://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Recursing_up_and_down:_Completed_ways_and_relations>`__
97+
query in a bounding box (the ‘map call’). You just pass the bounding box
98+
to the constructor:
99+
100+
.. code:: python
101+
102+
MapQuery = overpass.MapQuery(50.746,7.154,50.748,7.157)
103+
response = api.get(MapQuery)
104+
105+
WayQuery
106+
^^^^^^^^
107+
108+
This is shorthand for getting a set of ways and their child nodes that
109+
satisfy certain criteria. Pass the criteria as a Overpass QL stub to the
110+
constructor:
111+
112+
.. code:: python
113+
114+
WayQuery = overpass.WayQuery('[name="Highway 51"]')
115+
response = api.get(WayQuery)
116+
117+
Testing
118+
-------
119+
120+
Using ``pytest``.
121+
122+
``py.test``
123+
124+
FAQ
125+
---
126+
127+
I need help or have an idea for a feature
128+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129+
130+
Create a `new
131+
issue <https://github.com/mvexel/overpass-api-python-wrapper/issues>`__.
132+
133+
Where did the CLI tool go?
134+
~~~~~~~~~~~~~~~~~~~~~~~~~~
135+
136+
The command line tool was deprecated in version 0.4.0.
137+
138+
.. |Build Status| image:: https://travis-ci.org/mvexel/overpass-api-python-wrapper.svg?branch=master
139+
:target: https://travis-ci.org/mvexel/overpass-api-python-wrapper

0 commit comments

Comments
 (0)