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 *
3
3
4
4
5
5
class OsmApi :
@@ -20,20 +20,19 @@ def get_api_capabilities(self):
20
20
"""
21
21
raise NotImplementedError
22
22
23
- def get_permissions (self ) -> list :
23
+ def get_permissions (self ) -> set :
24
24
"""
25
25
current permissions
26
- GET /api/0.6/permissions
27
26
"""
28
27
raise NotImplementedError
29
28
30
29
''' changeset '''
31
30
32
- def create_changeset (self , dct : dict ) -> int :
31
+ def create_changeset (self , changeset : ChangeSet ) -> int :
33
32
"""
34
33
PUT /api/0.6/changeset/create
35
34
36
- :param dct : Dictionary containing additional tags
35
+ :param changeset : Dictionary containing additional tags
37
36
38
37
:returns: changeset ID
39
38
@@ -45,28 +44,20 @@ def create_changeset(self, dct: dict) -> int:
45
44
"""
46
45
raise NotImplementedError
47
46
48
- def get_changeset (self , cid : int , discussion = False ) -> dict :
47
+ def get_changeset (self , cid : int , discussion : bool = False ) -> ChangeSet :
49
48
"""
50
49
A Call to get a changeset optionally with discussion.
51
50
no elements included
52
51
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?
61
54
:returns: dictionary representation of the changeset
62
-
63
55
:raises NoneFoundError:
64
- HTTP 404 NOT FOUND
65
56
no changeset matching this ID
66
57
"""
67
58
raise NotImplementedError
68
59
69
- def edit_changeset (self , cdt : dict ) -> dict :
60
+ def edit_changeset (self , changeset : ChangeSet ) :
70
61
"""
71
62
PUT /api/0.6/changeset/#id
72
63
"""
@@ -86,14 +77,14 @@ def close_changeset(self, cid: int):
86
77
"""
87
78
raise NotImplementedError
88
79
89
- def download_changeset (self , cid : int ) -> dict :
80
+ def download_changeset (self , cid : int ) -> ChangeSet :
90
81
"""
91
82
GET /api/0.6/changeset/#id/download
92
83
"""
93
84
raise NotImplementedError
94
85
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 :
97
88
"""
98
89
returns max 100 changesets matching all provided parameters
99
90
GET /api/0.6/changesets
@@ -121,31 +112,25 @@ def comm_changeset(self, cid: int, text: str) -> str:
121
112
"""
122
113
raise NotImplementedError
123
114
124
- def sub_changeset (self , cid : int ) -> str :
115
+ def sub_changeset (self , cid : int ) -> ChangeSet :
125
116
"""
126
117
Subscribes the current authenticated user to changeset discussion
127
- POST /api/0.6/changeset/#id/subscribe
128
118
129
- :raises ConflictError:
130
- HTTP 409 CONFLICT
131
- already subscribed
119
+ :raises ConflictError: already subscribed
132
120
"""
133
121
raise NotImplementedError
134
122
135
- def unsub_changeset (self , cid : int ) -> str :
123
+ def unsub_changeset (self , cid : int ) -> ChangeSet :
136
124
"""
137
125
Unsubscribes the current authenticated user from changeset discussion
138
- POST /api/0.6/changeset/#id/subscribe
139
126
140
- :raises NoneFoundError:
141
- HTTP 400 NOT FOUND
142
- is not subscribed
127
+ :raises NoneFoundError: is not subscribed
143
128
"""
144
129
raise NotImplementedError
145
130
146
131
''' Element '''
147
132
148
- def create_element (self , elem : PropElement , cid : int ) -> int :
133
+ def create_element (self , elem : Element , cid : int ) -> int :
149
134
"""
150
135
creates new element of specified type
151
136
PUT /api/0.6/[node|way|relation]/create
@@ -170,25 +155,21 @@ def create_element(self, elem: PropElement, cid: int) -> int:
170
155
"""
171
156
raise NotImplementedError
172
157
173
- def get_element (self , etype : str , eid : int ) -> PropElement :
158
+ def get_element (self , etype : str , eid : int ) -> Element :
174
159
"""
175
160
GET /api/0.6/[node|way|relation]/#id
176
161
177
162
: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
183
165
"""
184
166
raise NotImplementedError
185
167
186
- def edit_element (self , elem : PropElement , cid : int ) -> int :
168
+ def edit_element (self , elem : Element , cid : int ) -> int :
187
169
"""
188
170
PUT /api/0.6/[node|way|relation]/#id
189
171
190
172
:returns: New version Number
191
-
192
173
:raises NoneFoundError:
193
174
HTTP 400 BAD REQUEST
194
175
When there are errors parsing the XML -> ParseError
@@ -209,12 +190,11 @@ def edit_element(self, elem: PropElement, cid: int) -> int:
209
190
"""
210
191
raise NotImplementedError
211
192
212
- def delete_element (self , elem : PropElement ) -> int :
193
+ def delete_element (self , elem : Element ) -> int :
213
194
"""
214
195
DELETE /api/0.6/[node|way|relation]/#id
215
196
216
197
:returns: new version number
217
-
218
198
:raises NoneFoundError:
219
199
HTTP 400 BAD REQUEST
220
200
When there are errors parsing the XML -> ParseError
@@ -246,7 +226,7 @@ def history_element(self, etype: str, eid: int) -> list:
246
226
"""
247
227
raise NotImplementedError
248
228
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 :
250
230
"""
251
231
Return specified version of element
252
232
GET /api/0.6/[node|way|relation]/#id/#version
@@ -257,6 +237,7 @@ def get_elements(self, etype: str, lst_eid: list) -> list:
257
237
"""
258
238
multiple elements as specified in the list of eid
259
239
GET /api/0.6/[nodes|ways|relations]?#parameters
240
+ todo write doku
260
241
"""
261
242
raise NotImplementedError
262
243
@@ -266,16 +247,16 @@ def get_relation_of_element(self, etype: str, eid: int) -> list:
266
247
"""
267
248
raise NotImplementedError
268
249
269
- def get_ways_of_node (self , etype : str , eid : int ) -> list :
250
+ def get_ways_of_node (self , eid : int ) -> list :
270
251
"""
271
- GET /api/0.6/node/#id/ways
252
+ use only on node elements
253
+ :returns: ways directly using this node
272
254
"""
273
255
raise NotImplementedError
274
256
275
257
def get_element_bbox (self , bbox : tuple ) -> list :
276
258
"""
277
259
:returns: all Elements with minimum one Node within this BoundingBox
278
- GET /api/0.6/map:
279
260
280
261
"""
281
262
raise NotImplementedError
@@ -506,7 +487,8 @@ def reopen_note(self, nid: int, text: str):
506
487
raise NotImplementedError
507
488
508
489
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 :
510
492
"""
511
493
GET /api/0.6/notes/search?q=<SearchTerm>&limit=&closed=&username=&user=&from=&to=&sort=&order=
512
494
@@ -523,6 +505,7 @@ def search_note(self, text: str, limit: int = 100, closed: int = 7, username: st
523
505
:raises ValueError: HTTP 400 BAD REQUEST
524
506
When any of the limits are crossed
525
507
"""
508
+ raise NotImplementedError
526
509
527
510
def rss_notes (self , bbox ) -> str :
528
511
"""
@@ -531,3 +514,4 @@ def rss_notes(self, bbox) -> str:
531
514
:param bbox: (lonmin, latmin, lonmax, latmax)
532
515
:return:
533
516
"""
517
+ raise NotImplementedError
0 commit comments