Skip to content

Commit 6a5293a

Browse files
author
Jonathan Koehler
committed
removed references to python_osm_tools.
implementation osm api, only get/download
1 parent c06805b commit 6a5293a

8 files changed

+392
-133
lines changed

ee_osmose.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
class ParseError(Exception):
55
def __init__(self, message):
6-
super(message)
6+
self.message = message
77

88

99
class ConflictError(Exception):
1010
def __init__(self, message):
11-
super(message)
11+
self.message = message
1212

1313

1414
class MethodError(LookupError):
1515
def __init__(self, message):
16-
super(message)
16+
self.message = message
1717

1818

1919
class NoneFoundError(ValueError):
2020
def __init__(self, message):
21-
super(message)
21+
self.message = message

osm.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
from OSMPythonTools.api import Api
2-
3-
4-
def get_elem(type, id):
5-
api = Api()
6-
way = api.query('{}/{}'.format(type, id))
7-
return way

osm/a_osm_api.py

+31-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from osm.osm_util import PropElement, Note
2-
from datetime import date
1+
from osm.osm_util import Element, Note, ChangeSet
2+
from datetime import *
33

44

55
class OsmApi:
@@ -20,20 +20,19 @@ def get_api_capabilities(self):
2020
"""
2121
raise NotImplementedError
2222

23-
def get_permissions(self) -> list:
23+
def get_permissions(self) -> set:
2424
"""
2525
current permissions
26-
GET /api/0.6/permissions
2726
"""
2827
raise NotImplementedError
2928

3029
''' changeset '''
3130

32-
def create_changeset(self, dct: dict) -> int:
31+
def create_changeset(self, changeset: ChangeSet) -> int:
3332
"""
3433
PUT /api/0.6/changeset/create
3534
36-
:param dct: Dictionary containing additional tags
35+
:param changeset: Dictionary containing additional tags
3736
3837
:returns: changeset ID
3938
@@ -45,28 +44,20 @@ def create_changeset(self, dct: dict) -> int:
4544
"""
4645
raise NotImplementedError
4746

48-
def get_changeset(self, cid: int, discussion=False) -> dict:
47+
def get_changeset(self, cid: int, discussion: bool = False) -> ChangeSet:
4948
"""
5049
A Call to get a changeset optionally with discussion.
5150
no elements included
5251
53-
GET /api/0.6/changeset/#id?include_discussion=
54-
exclude discussion by <empty> or omitting
55-
56-
:param cid: int
57-
changeset ID
58-
:param discussion: bool
59-
include changeset discussion?
60-
52+
:param cid: changeset ID
53+
:param discussion: include changeset discussion?
6154
:returns: dictionary representation of the changeset
62-
6355
:raises NoneFoundError:
64-
HTTP 404 NOT FOUND
6556
no changeset matching this ID
6657
"""
6758
raise NotImplementedError
6859

69-
def edit_changeset(self, cdt: dict) -> dict:
60+
def edit_changeset(self, changeset: ChangeSet):
7061
"""
7162
PUT /api/0.6/changeset/#id
7263
"""
@@ -86,14 +77,14 @@ def close_changeset(self, cid: int):
8677
"""
8778
raise NotImplementedError
8879

89-
def download_changeset(self, cid: int) -> dict:
80+
def download_changeset(self, cid: int) -> ChangeSet:
9081
"""
9182
GET /api/0.6/changeset/#id/download
9283
"""
9384
raise NotImplementedError
9485

95-
def get_changesets(self, bbox: tuple = None, user='', time1=None, time2=None,
96-
is_open=True, is_closed=True, changesets=None) -> list:
86+
def get_changesets(self, bbox: tuple = None, user: str = '', time1: datetime = None, time2: datetime = None,
87+
is_open: bool = True, is_closed: bool = True, changesets: list = None) -> list:
9788
"""
9889
returns max 100 changesets matching all provided parameters
9990
GET /api/0.6/changesets
@@ -121,31 +112,25 @@ def comm_changeset(self, cid: int, text: str) -> str:
121112
"""
122113
raise NotImplementedError
123114

124-
def sub_changeset(self, cid: int) -> str:
115+
def sub_changeset(self, cid: int) -> ChangeSet:
125116
"""
126117
Subscribes the current authenticated user to changeset discussion
127-
POST /api/0.6/changeset/#id/subscribe
128118
129-
:raises ConflictError:
130-
HTTP 409 CONFLICT
131-
already subscribed
119+
:raises ConflictError: already subscribed
132120
"""
133121
raise NotImplementedError
134122

135-
def unsub_changeset(self, cid: int) -> str:
123+
def unsub_changeset(self, cid: int) -> ChangeSet:
136124
"""
137125
Unsubscribes the current authenticated user from changeset discussion
138-
POST /api/0.6/changeset/#id/subscribe
139126
140-
:raises NoneFoundError:
141-
HTTP 400 NOT FOUND
142-
is not subscribed
127+
:raises NoneFoundError: is not subscribed
143128
"""
144129
raise NotImplementedError
145130

146131
''' Element '''
147132

148-
def create_element(self, elem: PropElement, cid: int) -> int:
133+
def create_element(self, elem: Element, cid: int) -> int:
149134
"""
150135
creates new element of specified type
151136
PUT /api/0.6/[node|way|relation]/create
@@ -170,25 +155,21 @@ def create_element(self, elem: PropElement, cid: int) -> int:
170155
"""
171156
raise NotImplementedError
172157

173-
def get_element(self, etype: str, eid: int) -> PropElement:
158+
def get_element(self, etype: str, eid: int) -> Element:
174159
"""
175160
GET /api/0.6/[node|way|relation]/#id
176161
177162
:returns: Element containing all available data.
178-
179-
:raises NoneFoundError:
180-
HTTP 404 NOT FOUND
181-
:raises LockupError:
182-
HTTP 410 GONE
163+
:raises NoneFoundError: No Element with such id
164+
:raises LockupError: Deleted Element
183165
"""
184166
raise NotImplementedError
185167

186-
def edit_element(self, elem: PropElement, cid: int) -> int:
168+
def edit_element(self, elem: Element, cid: int) -> int:
187169
"""
188170
PUT /api/0.6/[node|way|relation]/#id
189171
190172
:returns: New version Number
191-
192173
:raises NoneFoundError:
193174
HTTP 400 BAD REQUEST
194175
When there are errors parsing the XML -> ParseError
@@ -209,12 +190,11 @@ def edit_element(self, elem: PropElement, cid: int) -> int:
209190
"""
210191
raise NotImplementedError
211192

212-
def delete_element(self, elem: PropElement) -> int:
193+
def delete_element(self, elem: Element) -> int:
213194
"""
214195
DELETE /api/0.6/[node|way|relation]/#id
215196
216197
:returns: new version number
217-
218198
:raises NoneFoundError:
219199
HTTP 400 BAD REQUEST
220200
When there are errors parsing the XML -> ParseError
@@ -246,7 +226,7 @@ def history_element(self, etype: str, eid: int) -> list:
246226
"""
247227
raise NotImplementedError
248228

249-
def history_version_element(self, etype: str, eid: int, version: int = None) -> PropElement:
229+
def history_version_element(self, etype: str, eid: int, version: int = None) -> Element:
250230
"""
251231
Return specified version of element
252232
GET /api/0.6/[node|way|relation]/#id/#version
@@ -257,6 +237,7 @@ def get_elements(self, etype: str, lst_eid: list) -> list:
257237
"""
258238
multiple elements as specified in the list of eid
259239
GET /api/0.6/[nodes|ways|relations]?#parameters
240+
todo write doku
260241
"""
261242
raise NotImplementedError
262243

@@ -266,16 +247,16 @@ def get_relation_of_element(self, etype: str, eid: int) -> list:
266247
"""
267248
raise NotImplementedError
268249

269-
def get_ways_of_node(self, etype: str, eid: int) -> list:
250+
def get_ways_of_node(self, eid: int) -> list:
270251
"""
271-
GET /api/0.6/node/#id/ways
252+
use only on node elements
253+
:returns: ways directly using this node
272254
"""
273255
raise NotImplementedError
274256

275257
def get_element_bbox(self, bbox: tuple) -> list:
276258
"""
277259
:returns: all Elements with minimum one Node within this BoundingBox
278-
GET /api/0.6/map:
279260
280261
"""
281262
raise NotImplementedError
@@ -506,7 +487,8 @@ def reopen_note(self, nid: int, text: str):
506487
raise NotImplementedError
507488

508489
def search_note(self, text: str, limit: int = 100, closed: int = 7, username: str = None, user: int = None,
509-
start: date = None, end: date = None, sort: str = 'updated_at', order: str = 'newest') -> list:
490+
start: datetime = None, end: datetime = None,
491+
sort: str = 'updated_at', order: str = 'newest') -> list:
510492
"""
511493
GET /api/0.6/notes/search?q=<SearchTerm>&limit=&closed=&username=&user=&from=&to=&sort=&order=
512494
@@ -523,6 +505,7 @@ def search_note(self, text: str, limit: int = 100, closed: int = 7, username: st
523505
:raises ValueError: HTTP 400 BAD REQUEST
524506
When any of the limits are crossed
525507
"""
508+
raise NotImplementedError
526509

527510
def rss_notes(self, bbox) -> str:
528511
"""
@@ -531,3 +514,4 @@ def rss_notes(self, bbox) -> str:
531514
:param bbox: (lonmin, latmin, lonmax, latmax)
532515
:return:
533516
"""
517+
raise NotImplementedError

0 commit comments

Comments
 (0)