Skip to content

Commit 1051aba

Browse files
committed
version 0.5.0
1 parent f9e21ab commit 1051aba

File tree

6 files changed

+116
-240
lines changed

6 files changed

+116
-240
lines changed

README.md

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
![travis-build-badge](https://travis-ci.org/mvexel/overpass-api-python-wrapper.svg?branch=master)
8+
9+
10+
Install it
11+
==========
12+
13+
`pip install overpass`
14+
15+
## Usage
16+
17+
Simplest example:
18+
19+
```python
20+
import overpass
21+
api = overpass.API()
22+
response = api.Get('node["name"="Salt Lake City"]')
23+
```
24+
25+
Note that you don't have to include any of the output meta statements.
26+
The wrapper will, well, wrap those.
27+
28+
You will get your result as a dictionary, which represents the
29+
JSON output you would get [from the Overpass API
30+
directly](http://overpass-api.de/output_formats.html#json>). So you
31+
could do this for example:
32+
33+
```python
34+
print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
35+
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637), (u'Salt Lake City', 1615721573)]```
36+
37+
You can specify the format of the response. By default, you will get GeoJSON using the `responseformat` parameter. Alternatives are plain JSON (`json`) and OSM XML (`xml`), as ouput directly by the Overpass API.
38+
39+
```python
40+
response = api.Get('node["name"="Salt Lake City"]', responseformat="xml")
41+
```
42+
43+
### Parameters
44+
45+
46+
The API object takes a few parameters:
47+
48+
#### endpoint
49+
50+
The default endpoint is `http://overpass-api.de/api/interpreter` but
51+
you can pass in another instance:
52+
53+
```python
54+
api = overpass.API(endpoint=http://overpass.myserver/interpreter)
55+
```
56+
57+
#### timeout
58+
59+
The default timeout is 25 seconds, but you can set it to whatever you
60+
want.
61+
62+
```python
63+
api = overpass.API(timeout=600)
64+
```
65+
66+
#### debug
67+
68+
Setting this to `True` will get you debug output.
69+
70+
### Simple queries
71+
72+
In addition to just send your query and parse the result, the wrapper
73+
provides shortcuts for often used map queries. To use them, just pass
74+
them like to normal query to the API.
75+
76+
#### MapQuery
77+
78+
This is a shorthand for a `complete ways and
79+
relations <http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Completed_ways_and_relations>`__
80+
query in a bounding box (the 'map call'). You just pass the bounding box
81+
to the constructor:
82+
83+
```python
84+
map_query = overpass.MapQuery(50.746,7.154,50.748,7.157)
85+
response = api.Get(map_query)```
86+
87+
#### WayQuery
88+
89+
This is shorthand for getting a set of ways and their child nodes that
90+
satisfy certain criteria. Pass the criteria as a Overpass QL stub to the
91+
constructor:
92+
93+
```python
94+
way_query = overpass.WayQuery('[name="Highway 51"]')
95+
response = api.Get(way_query)```
96+
97+
## Testing
98+
99+
Using `nose`.
100+
101+
`py.test`
102+
103+
## FAQ
104+
105+
### I need help or have an idea for a feature
106+
107+
Create a [new
108+
issue](https://github.com/mvexel/overpass-api-python-wrapper/issues>).
109+
110+
### Where did the CLI tool go?
111+
112+
I decided that it does not belong in this repo. If you still want it, get version 0.4.0 or below.

README.rst

-180
This file was deleted.

overpass/cli.py

-30
This file was deleted.

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
geojson==1.3.1
22
requests==2.8.1
33
wheel==0.24.0
4-
click==6.2
54
nose==1.3.7

setup.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from setuptools import setup, find_packages
33

44
# Get the long description from the relevant file
5-
with codecs_open('README.rst', encoding='utf-8') as f:
5+
with codecs_open('README.md', encoding='utf-8') as f:
66
long_description = f.read()
77

88
setup(
99
name='overpass',
1010
packages=['overpass'],
11-
version='0.3.1',
11+
version='0.5.0',
1212
description='Python wrapper for the OpenStreetMap Overpass API',
1313
long_description=long_description,
1414
author='Martijn van Exel',
@@ -26,12 +26,8 @@
2626
'Topic :: Scientific/Engineering :: GIS',
2727
'Topic :: Utilities',
2828
],
29-
install_requires=['click', 'requests>=2.3.0', 'geojson>=1.0.9'],
29+
install_requires=['requests>=2.3.0', 'geojson>=1.0.9'],
3030
extras_require={
3131
'test': ['pytest'],
32-
},
33-
entry_points="""
34-
[console_scripts]
35-
overpass=overpass.cli:cli
36-
"""
32+
}
3733
)

tests/test_cli.py

-21
This file was deleted.

0 commit comments

Comments
 (0)