osmapi.way

Way operations for the OpenStreetMap API.

This module provides pythonic (snake_case) methods for working with OSM ways.

  1"""
  2Way operations for the OpenStreetMap API.
  3
  4This module provides pythonic (snake_case) methods for working with OSM ways.
  5"""
  6
  7from typing import Any, TYPE_CHECKING, cast
  8from xml.dom.minidom import Element
  9
 10from . import dom, parser
 11
 12if TYPE_CHECKING:
 13    from .OsmApi import OsmApi
 14
 15
 16class WayMixin:
 17    """Mixin providing way-related operations with pythonic method names."""
 18
 19    def way_get(self: "OsmApi", way_id: int, way_version: int = -1) -> dict[str, Any]:
 20        """
 21        Returns way with `way_id` as a dict:
 22
 23            #!python
 24            {
 25                'id': id of way,
 26                'tag': {} tags of this way,
 27                'nd': [] list of nodes belonging to this way
 28                'changeset': id of changeset of last change,
 29                'version': version number of way,
 30                'user': username of user that made the last change,
 31                'uid': id of user that made the last change,
 32                'timestamp': timestamp of last change,
 33                'visible': True|False
 34            }
 35
 36        If `way_version` is supplied, this specific version is returned,
 37        otherwise the latest version is returned.
 38
 39        If the requested element has been deleted,
 40        `OsmApi.ElementDeletedApiError` is raised.
 41
 42        If the requested element can not be found,
 43        `OsmApi.ElementNotFoundApiError` is raised.
 44        """
 45        uri = f"/api/0.6/way/{way_id}"
 46        if way_version != -1:
 47            uri += f"/{way_version}"
 48        data = self._session._get(uri)
 49        way = cast(Element, dom.OsmResponseToDom(data, tag="way", single=True))
 50        return dom.dom_parse_way(way)
 51
 52    def way_create(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
 53        """
 54        Creates a way based on the supplied `way_data` dict:
 55
 56            #!python
 57            {
 58                'nd': [] list of nodes,
 59                'tag': {} dict of tags,
 60            }
 61
 62        Returns updated `way_data` (without timestamp):
 63
 64            #!python
 65            {
 66                'id': id of node,
 67                'nd': [] list of nodes,
 68                'tag': {} dict of tags,
 69                'changeset': id of changeset of last change,
 70                'version': version number of way,
 71                'user': username of last change,
 72                'uid': id of user of last change,
 73                'visible': True|False
 74            }
 75
 76        If no session is provided to authenticate the request,
 77        `OsmApi.AuthenticationMissingError` is raised.
 78
 79        If the supplied information contain an existing node,
 80        `OsmApi.OsmTypeAlreadyExistsError` is raised.
 81
 82        If there is no open changeset,
 83        `OsmApi.NoChangesetOpenError` is raised.
 84
 85        If there is already an open changeset,
 86        `OsmApi.ChangesetAlreadyOpenError` is raised.
 87
 88        If the changeset is already closed,
 89        `OsmApi.ChangesetClosedApiError` is raised.
 90        """
 91        return self._do("create", "way", way_data)
 92
 93    def way_update(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
 94        """
 95        Updates way with the supplied `way_data` dict:
 96
 97            #!python
 98            {
 99                'id': id of way,
100                'nd': [] list of nodes,
101                'tag': {},
102                'version': version number of way,
103            }
104
105        Returns updated `way_data` (without timestamp):
106
107            #!python
108            {
109                'id': id of node,
110                'nd': [] list of nodes,
111                'tag': {} dict of tags,
112                'changeset': id of changeset of last change,
113                'version': version number of way,
114                'user': username of last change,
115                'uid': id of user of last change,
116                'visible': True|False
117            }
118
119        If no session is provided to authenticate the request,
120        `OsmApi.AuthenticationMissingError` is raised.
121
122        If there is no open changeset,
123        `OsmApi.NoChangesetOpenError` is raised.
124
125        If there is already an open changeset,
126        `OsmApi.ChangesetAlreadyOpenError` is raised.
127
128        If the changeset is already closed,
129        `OsmApi.ChangesetClosedApiError` is raised.
130        """
131        return self._do("modify", "way", way_data)
132
133    def way_delete(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
134        """
135        Delete way with `way_data`:
136
137            #!python
138            {
139                'id': id of way,
140                'nd': [] list of nodes,
141                'tag': dict of tags,
142                'version': version number of way,
143            }
144
145        Returns updated `way_data` (without timestamp):
146
147            #!python
148            {
149                'id': id of way,
150                'nd': [] list of nodes,
151                'tag': dict of tags,
152                'changeset': id of changeset of last change,
153                'version': version number of way,
154                'user': username of last change,
155                'uid': id of user of last change,
156                'visible': True|False
157            }
158
159        If no session is provided to authenticate the request,
160        `OsmApi.AuthenticationMissingError` is raised.
161
162        If there is no open changeset,
163        `OsmApi.NoChangesetOpenError` is raised.
164
165        If the changeset is already closed,
166        `OsmApi.ChangesetClosedApiError` is raised.
167        """
168        return self._do("delete", "way", way_data)
169
170    def way_history(self: "OsmApi", way_id: int) -> dict[int, dict[str, Any]]:
171        """
172        Returns dict with version as key:
173
174            #!python
175            {
176                1: dict of way version 1,
177                2: dict of way version 2,
178                ...
179            }
180
181        If the requested element can not be found,
182        `OsmApi.ElementNotFoundApiError` is raised.
183        """
184        uri = f"/api/0.6/way/{way_id}/history"
185        data = self._session._get(uri)
186        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
187        result: dict[int, dict[str, Any]] = {}
188        for way in ways:
189            way_data = dom.dom_parse_way(way)
190            result[way_data["version"]] = way_data
191        return result
192
193    def way_relations(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
194        """
195        Returns a list of dicts of relation data containing way `way_id`:
196
197            #!python
198            [
199                {
200                    'id': id of Relation,
201                    'member': [
202                        {
203                            'ref': ID of referenced element,
204                            'role': optional description of role in relation
205                            'type': node|way|relation
206                        },
207                        {
208                            ...
209                        }
210                    ]
211                    'tag': {} dict of tags,
212                    'changeset': id of changeset of last change,
213                    'version': version number of Way,
214                    'user': username of user that made the last change,
215                    'uid': id of user that made the last change,
216                    'visible': True|False
217                },
218                {
219                    ...
220                },
221            ]
222
223        The `way_id` is a unique identifier for a way.
224        """
225        uri = f"/api/0.6/way/{way_id}/relations"
226        data = self._session._get(uri)
227        relations = cast(
228            list[Element], dom.OsmResponseToDom(data, tag="relation", allow_empty=True)
229        )
230        result: list[dict[str, Any]] = []
231        for relation in relations:
232            relation_data = dom.dom_parse_relation(relation)
233            result.append(relation_data)
234        return result
235
236    def way_full(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
237        """
238        Returns the full data for way `way_id` as list of dicts:
239
240            #!python
241            [
242                {
243                    'type': node|way|relation,
244                    'data': {} data dict for node|way|relation
245                },
246                { ... }
247            ]
248
249        The `way_id` is a unique identifier for a way.
250
251        If the requested element has been deleted,
252        `OsmApi.ElementDeletedApiError` is raised.
253
254        If the requested element can not be found,
255        `OsmApi.ElementNotFoundApiError` is raised.
256        """
257        uri = f"/api/0.6/way/{way_id}/full"
258        data = self._session._get(uri)
259        return parser.parse_osm(data)
260
261    def ways_get(self: "OsmApi", way_id_list: list[int]) -> dict[int, dict[str, Any]]:
262        """
263        Returns dict with the id of the way as a key for
264        each way in `way_id_list`:
265
266            #!python
267            {
268                '1234': dict of way data,
269                '5678': dict of way data,
270                ...
271            }
272
273        `way_id_list` is a list containing unique identifiers for multiple ways.
274        """
275        way_list = ",".join([str(x) for x in way_id_list])
276        uri = f"/api/0.6/ways?ways={way_list}"
277        data = self._session._get(uri)
278        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
279        result: dict[int, dict[str, Any]] = {}
280        for way in ways:
281            way_data = dom.dom_parse_way(way)
282            result[way_data["id"]] = way_data
283        return result
class WayMixin:
 17class WayMixin:
 18    """Mixin providing way-related operations with pythonic method names."""
 19
 20    def way_get(self: "OsmApi", way_id: int, way_version: int = -1) -> dict[str, Any]:
 21        """
 22        Returns way with `way_id` as a dict:
 23
 24            #!python
 25            {
 26                'id': id of way,
 27                'tag': {} tags of this way,
 28                'nd': [] list of nodes belonging to this way
 29                'changeset': id of changeset of last change,
 30                'version': version number of way,
 31                'user': username of user that made the last change,
 32                'uid': id of user that made the last change,
 33                'timestamp': timestamp of last change,
 34                'visible': True|False
 35            }
 36
 37        If `way_version` is supplied, this specific version is returned,
 38        otherwise the latest version is returned.
 39
 40        If the requested element has been deleted,
 41        `OsmApi.ElementDeletedApiError` is raised.
 42
 43        If the requested element can not be found,
 44        `OsmApi.ElementNotFoundApiError` is raised.
 45        """
 46        uri = f"/api/0.6/way/{way_id}"
 47        if way_version != -1:
 48            uri += f"/{way_version}"
 49        data = self._session._get(uri)
 50        way = cast(Element, dom.OsmResponseToDom(data, tag="way", single=True))
 51        return dom.dom_parse_way(way)
 52
 53    def way_create(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
 54        """
 55        Creates a way based on the supplied `way_data` dict:
 56
 57            #!python
 58            {
 59                'nd': [] list of nodes,
 60                'tag': {} dict of tags,
 61            }
 62
 63        Returns updated `way_data` (without timestamp):
 64
 65            #!python
 66            {
 67                'id': id of node,
 68                'nd': [] list of nodes,
 69                'tag': {} dict of tags,
 70                'changeset': id of changeset of last change,
 71                'version': version number of way,
 72                'user': username of last change,
 73                'uid': id of user of last change,
 74                'visible': True|False
 75            }
 76
 77        If no session is provided to authenticate the request,
 78        `OsmApi.AuthenticationMissingError` is raised.
 79
 80        If the supplied information contain an existing node,
 81        `OsmApi.OsmTypeAlreadyExistsError` is raised.
 82
 83        If there is no open changeset,
 84        `OsmApi.NoChangesetOpenError` is raised.
 85
 86        If there is already an open changeset,
 87        `OsmApi.ChangesetAlreadyOpenError` is raised.
 88
 89        If the changeset is already closed,
 90        `OsmApi.ChangesetClosedApiError` is raised.
 91        """
 92        return self._do("create", "way", way_data)
 93
 94    def way_update(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
 95        """
 96        Updates way with the supplied `way_data` dict:
 97
 98            #!python
 99            {
100                'id': id of way,
101                'nd': [] list of nodes,
102                'tag': {},
103                'version': version number of way,
104            }
105
106        Returns updated `way_data` (without timestamp):
107
108            #!python
109            {
110                'id': id of node,
111                'nd': [] list of nodes,
112                'tag': {} dict of tags,
113                'changeset': id of changeset of last change,
114                'version': version number of way,
115                'user': username of last change,
116                'uid': id of user of last change,
117                'visible': True|False
118            }
119
120        If no session is provided to authenticate the request,
121        `OsmApi.AuthenticationMissingError` is raised.
122
123        If there is no open changeset,
124        `OsmApi.NoChangesetOpenError` is raised.
125
126        If there is already an open changeset,
127        `OsmApi.ChangesetAlreadyOpenError` is raised.
128
129        If the changeset is already closed,
130        `OsmApi.ChangesetClosedApiError` is raised.
131        """
132        return self._do("modify", "way", way_data)
133
134    def way_delete(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
135        """
136        Delete way with `way_data`:
137
138            #!python
139            {
140                'id': id of way,
141                'nd': [] list of nodes,
142                'tag': dict of tags,
143                'version': version number of way,
144            }
145
146        Returns updated `way_data` (without timestamp):
147
148            #!python
149            {
150                'id': id of way,
151                'nd': [] list of nodes,
152                'tag': dict of tags,
153                'changeset': id of changeset of last change,
154                'version': version number of way,
155                'user': username of last change,
156                'uid': id of user of last change,
157                'visible': True|False
158            }
159
160        If no session is provided to authenticate the request,
161        `OsmApi.AuthenticationMissingError` is raised.
162
163        If there is no open changeset,
164        `OsmApi.NoChangesetOpenError` is raised.
165
166        If the changeset is already closed,
167        `OsmApi.ChangesetClosedApiError` is raised.
168        """
169        return self._do("delete", "way", way_data)
170
171    def way_history(self: "OsmApi", way_id: int) -> dict[int, dict[str, Any]]:
172        """
173        Returns dict with version as key:
174
175            #!python
176            {
177                1: dict of way version 1,
178                2: dict of way version 2,
179                ...
180            }
181
182        If the requested element can not be found,
183        `OsmApi.ElementNotFoundApiError` is raised.
184        """
185        uri = f"/api/0.6/way/{way_id}/history"
186        data = self._session._get(uri)
187        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
188        result: dict[int, dict[str, Any]] = {}
189        for way in ways:
190            way_data = dom.dom_parse_way(way)
191            result[way_data["version"]] = way_data
192        return result
193
194    def way_relations(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
195        """
196        Returns a list of dicts of relation data containing way `way_id`:
197
198            #!python
199            [
200                {
201                    'id': id of Relation,
202                    'member': [
203                        {
204                            'ref': ID of referenced element,
205                            'role': optional description of role in relation
206                            'type': node|way|relation
207                        },
208                        {
209                            ...
210                        }
211                    ]
212                    'tag': {} dict of tags,
213                    'changeset': id of changeset of last change,
214                    'version': version number of Way,
215                    'user': username of user that made the last change,
216                    'uid': id of user that made the last change,
217                    'visible': True|False
218                },
219                {
220                    ...
221                },
222            ]
223
224        The `way_id` is a unique identifier for a way.
225        """
226        uri = f"/api/0.6/way/{way_id}/relations"
227        data = self._session._get(uri)
228        relations = cast(
229            list[Element], dom.OsmResponseToDom(data, tag="relation", allow_empty=True)
230        )
231        result: list[dict[str, Any]] = []
232        for relation in relations:
233            relation_data = dom.dom_parse_relation(relation)
234            result.append(relation_data)
235        return result
236
237    def way_full(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
238        """
239        Returns the full data for way `way_id` as list of dicts:
240
241            #!python
242            [
243                {
244                    'type': node|way|relation,
245                    'data': {} data dict for node|way|relation
246                },
247                { ... }
248            ]
249
250        The `way_id` is a unique identifier for a way.
251
252        If the requested element has been deleted,
253        `OsmApi.ElementDeletedApiError` is raised.
254
255        If the requested element can not be found,
256        `OsmApi.ElementNotFoundApiError` is raised.
257        """
258        uri = f"/api/0.6/way/{way_id}/full"
259        data = self._session._get(uri)
260        return parser.parse_osm(data)
261
262    def ways_get(self: "OsmApi", way_id_list: list[int]) -> dict[int, dict[str, Any]]:
263        """
264        Returns dict with the id of the way as a key for
265        each way in `way_id_list`:
266
267            #!python
268            {
269                '1234': dict of way data,
270                '5678': dict of way data,
271                ...
272            }
273
274        `way_id_list` is a list containing unique identifiers for multiple ways.
275        """
276        way_list = ",".join([str(x) for x in way_id_list])
277        uri = f"/api/0.6/ways?ways={way_list}"
278        data = self._session._get(uri)
279        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
280        result: dict[int, dict[str, Any]] = {}
281        for way in ways:
282            way_data = dom.dom_parse_way(way)
283            result[way_data["id"]] = way_data
284        return result

Mixin providing way-related operations with pythonic method names.

def way_get( self: osmapi.OsmApi.OsmApi, way_id: int, way_version: int = -1) -> dict[str, typing.Any]:
20    def way_get(self: "OsmApi", way_id: int, way_version: int = -1) -> dict[str, Any]:
21        """
22        Returns way with `way_id` as a dict:
23
24            #!python
25            {
26                'id': id of way,
27                'tag': {} tags of this way,
28                'nd': [] list of nodes belonging to this way
29                'changeset': id of changeset of last change,
30                'version': version number of way,
31                'user': username of user that made the last change,
32                'uid': id of user that made the last change,
33                'timestamp': timestamp of last change,
34                'visible': True|False
35            }
36
37        If `way_version` is supplied, this specific version is returned,
38        otherwise the latest version is returned.
39
40        If the requested element has been deleted,
41        `OsmApi.ElementDeletedApiError` is raised.
42
43        If the requested element can not be found,
44        `OsmApi.ElementNotFoundApiError` is raised.
45        """
46        uri = f"/api/0.6/way/{way_id}"
47        if way_version != -1:
48            uri += f"/{way_version}"
49        data = self._session._get(uri)
50        way = cast(Element, dom.OsmResponseToDom(data, tag="way", single=True))
51        return dom.dom_parse_way(way)

Returns way with way_id as a dict:

#!python
{
    'id': id of way,
    'tag': {} tags of this way,
    'nd': [] list of nodes belonging to this way
    'changeset': id of changeset of last change,
    'version': version number of way,
    'user': username of user that made the last change,
    'uid': id of user that made the last change,
    'timestamp': timestamp of last change,
    'visible': True|False
}

If way_version is supplied, this specific version is returned, otherwise the latest version is returned.

If the requested element has been deleted, OsmApi.ElementDeletedApiError is raised.

If the requested element can not be found, OsmApi.ElementNotFoundApiError is raised.

def way_create( self: osmapi.OsmApi.OsmApi, way_data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
53    def way_create(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
54        """
55        Creates a way based on the supplied `way_data` dict:
56
57            #!python
58            {
59                'nd': [] list of nodes,
60                'tag': {} dict of tags,
61            }
62
63        Returns updated `way_data` (without timestamp):
64
65            #!python
66            {
67                'id': id of node,
68                'nd': [] list of nodes,
69                'tag': {} dict of tags,
70                'changeset': id of changeset of last change,
71                'version': version number of way,
72                'user': username of last change,
73                'uid': id of user of last change,
74                'visible': True|False
75            }
76
77        If no session is provided to authenticate the request,
78        `OsmApi.AuthenticationMissingError` is raised.
79
80        If the supplied information contain an existing node,
81        `OsmApi.OsmTypeAlreadyExistsError` is raised.
82
83        If there is no open changeset,
84        `OsmApi.NoChangesetOpenError` is raised.
85
86        If there is already an open changeset,
87        `OsmApi.ChangesetAlreadyOpenError` is raised.
88
89        If the changeset is already closed,
90        `OsmApi.ChangesetClosedApiError` is raised.
91        """
92        return self._do("create", "way", way_data)

Creates a way based on the supplied way_data dict:

#!python
{
    'nd': [] list of nodes,
    'tag': {} dict of tags,
}

Returns updated way_data (without timestamp):

#!python
{
    'id': id of node,
    'nd': [] list of nodes,
    'tag': {} dict of tags,
    'changeset': id of changeset of last change,
    'version': version number of way,
    'user': username of last change,
    'uid': id of user of last change,
    'visible': True|False
}

If no session is provided to authenticate the request, OsmApi.AuthenticationMissingError is raised.

If the supplied information contain an existing node, OsmApi.OsmTypeAlreadyExistsError is raised.

If there is no open changeset, OsmApi.NoChangesetOpenError is raised.

If there is already an open changeset, OsmApi.ChangesetAlreadyOpenError is raised.

If the changeset is already closed, OsmApi.ChangesetClosedApiError is raised.

def way_update( self: osmapi.OsmApi.OsmApi, way_data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
 94    def way_update(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
 95        """
 96        Updates way with the supplied `way_data` dict:
 97
 98            #!python
 99            {
100                'id': id of way,
101                'nd': [] list of nodes,
102                'tag': {},
103                'version': version number of way,
104            }
105
106        Returns updated `way_data` (without timestamp):
107
108            #!python
109            {
110                'id': id of node,
111                'nd': [] list of nodes,
112                'tag': {} dict of tags,
113                'changeset': id of changeset of last change,
114                'version': version number of way,
115                'user': username of last change,
116                'uid': id of user of last change,
117                'visible': True|False
118            }
119
120        If no session is provided to authenticate the request,
121        `OsmApi.AuthenticationMissingError` is raised.
122
123        If there is no open changeset,
124        `OsmApi.NoChangesetOpenError` is raised.
125
126        If there is already an open changeset,
127        `OsmApi.ChangesetAlreadyOpenError` is raised.
128
129        If the changeset is already closed,
130        `OsmApi.ChangesetClosedApiError` is raised.
131        """
132        return self._do("modify", "way", way_data)

Updates way with the supplied way_data dict:

#!python
{
    'id': id of way,
    'nd': [] list of nodes,
    'tag': {},
    'version': version number of way,
}

Returns updated way_data (without timestamp):

#!python
{
    'id': id of node,
    'nd': [] list of nodes,
    'tag': {} dict of tags,
    'changeset': id of changeset of last change,
    'version': version number of way,
    'user': username of last change,
    'uid': id of user of last change,
    'visible': True|False
}

If no session is provided to authenticate the request, OsmApi.AuthenticationMissingError is raised.

If there is no open changeset, OsmApi.NoChangesetOpenError is raised.

If there is already an open changeset, OsmApi.ChangesetAlreadyOpenError is raised.

If the changeset is already closed, OsmApi.ChangesetClosedApiError is raised.

def way_delete( self: osmapi.OsmApi.OsmApi, way_data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
134    def way_delete(self: "OsmApi", way_data: dict[str, Any]) -> dict[str, Any] | None:
135        """
136        Delete way with `way_data`:
137
138            #!python
139            {
140                'id': id of way,
141                'nd': [] list of nodes,
142                'tag': dict of tags,
143                'version': version number of way,
144            }
145
146        Returns updated `way_data` (without timestamp):
147
148            #!python
149            {
150                'id': id of way,
151                'nd': [] list of nodes,
152                'tag': dict of tags,
153                'changeset': id of changeset of last change,
154                'version': version number of way,
155                'user': username of last change,
156                'uid': id of user of last change,
157                'visible': True|False
158            }
159
160        If no session is provided to authenticate the request,
161        `OsmApi.AuthenticationMissingError` is raised.
162
163        If there is no open changeset,
164        `OsmApi.NoChangesetOpenError` is raised.
165
166        If the changeset is already closed,
167        `OsmApi.ChangesetClosedApiError` is raised.
168        """
169        return self._do("delete", "way", way_data)

Delete way with way_data:

#!python
{
    'id': id of way,
    'nd': [] list of nodes,
    'tag': dict of tags,
    'version': version number of way,
}

Returns updated way_data (without timestamp):

#!python
{
    'id': id of way,
    'nd': [] list of nodes,
    'tag': dict of tags,
    'changeset': id of changeset of last change,
    'version': version number of way,
    'user': username of last change,
    'uid': id of user of last change,
    'visible': True|False
}

If no session is provided to authenticate the request, OsmApi.AuthenticationMissingError is raised.

If there is no open changeset, OsmApi.NoChangesetOpenError is raised.

If the changeset is already closed, OsmApi.ChangesetClosedApiError is raised.

def way_history( self: osmapi.OsmApi.OsmApi, way_id: int) -> dict[int, dict[str, typing.Any]]:
171    def way_history(self: "OsmApi", way_id: int) -> dict[int, dict[str, Any]]:
172        """
173        Returns dict with version as key:
174
175            #!python
176            {
177                1: dict of way version 1,
178                2: dict of way version 2,
179                ...
180            }
181
182        If the requested element can not be found,
183        `OsmApi.ElementNotFoundApiError` is raised.
184        """
185        uri = f"/api/0.6/way/{way_id}/history"
186        data = self._session._get(uri)
187        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
188        result: dict[int, dict[str, Any]] = {}
189        for way in ways:
190            way_data = dom.dom_parse_way(way)
191            result[way_data["version"]] = way_data
192        return result

Returns dict with version as key:

#!python
{
    1: dict of way version 1,
    2: dict of way version 2,
    ...
}

If the requested element can not be found, OsmApi.ElementNotFoundApiError is raised.

def way_relations(self: osmapi.OsmApi.OsmApi, way_id: int) -> list[dict[str, typing.Any]]:
194    def way_relations(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
195        """
196        Returns a list of dicts of relation data containing way `way_id`:
197
198            #!python
199            [
200                {
201                    'id': id of Relation,
202                    'member': [
203                        {
204                            'ref': ID of referenced element,
205                            'role': optional description of role in relation
206                            'type': node|way|relation
207                        },
208                        {
209                            ...
210                        }
211                    ]
212                    'tag': {} dict of tags,
213                    'changeset': id of changeset of last change,
214                    'version': version number of Way,
215                    'user': username of user that made the last change,
216                    'uid': id of user that made the last change,
217                    'visible': True|False
218                },
219                {
220                    ...
221                },
222            ]
223
224        The `way_id` is a unique identifier for a way.
225        """
226        uri = f"/api/0.6/way/{way_id}/relations"
227        data = self._session._get(uri)
228        relations = cast(
229            list[Element], dom.OsmResponseToDom(data, tag="relation", allow_empty=True)
230        )
231        result: list[dict[str, Any]] = []
232        for relation in relations:
233            relation_data = dom.dom_parse_relation(relation)
234            result.append(relation_data)
235        return result

Returns a list of dicts of relation data containing way way_id:

#!python
[
    {
        'id': id of Relation,
        'member': [
            {
                'ref': ID of referenced element,
                'role': optional description of role in relation
                'type': node|way|relation
            },
            {
                ...
            }
        ]
        'tag': {} dict of tags,
        'changeset': id of changeset of last change,
        'version': version number of Way,
        'user': username of user that made the last change,
        'uid': id of user that made the last change,
        'visible': True|False
    },
    {
        ...
    },
]

The way_id is a unique identifier for a way.

def way_full(self: osmapi.OsmApi.OsmApi, way_id: int) -> list[dict[str, typing.Any]]:
237    def way_full(self: "OsmApi", way_id: int) -> list[dict[str, Any]]:
238        """
239        Returns the full data for way `way_id` as list of dicts:
240
241            #!python
242            [
243                {
244                    'type': node|way|relation,
245                    'data': {} data dict for node|way|relation
246                },
247                { ... }
248            ]
249
250        The `way_id` is a unique identifier for a way.
251
252        If the requested element has been deleted,
253        `OsmApi.ElementDeletedApiError` is raised.
254
255        If the requested element can not be found,
256        `OsmApi.ElementNotFoundApiError` is raised.
257        """
258        uri = f"/api/0.6/way/{way_id}/full"
259        data = self._session._get(uri)
260        return parser.parse_osm(data)

Returns the full data for way way_id as list of dicts:

#!python
[
    {
        'type': node|way|relation,
        'data': {} data dict for node|way|relation
    },
    { ... }
]

The way_id is a unique identifier for a way.

If the requested element has been deleted, OsmApi.ElementDeletedApiError is raised.

If the requested element can not be found, OsmApi.ElementNotFoundApiError is raised.

def ways_get( self: osmapi.OsmApi.OsmApi, way_id_list: list[int]) -> dict[int, dict[str, typing.Any]]:
262    def ways_get(self: "OsmApi", way_id_list: list[int]) -> dict[int, dict[str, Any]]:
263        """
264        Returns dict with the id of the way as a key for
265        each way in `way_id_list`:
266
267            #!python
268            {
269                '1234': dict of way data,
270                '5678': dict of way data,
271                ...
272            }
273
274        `way_id_list` is a list containing unique identifiers for multiple ways.
275        """
276        way_list = ",".join([str(x) for x in way_id_list])
277        uri = f"/api/0.6/ways?ways={way_list}"
278        data = self._session._get(uri)
279        ways = cast(list[Element], dom.OsmResponseToDom(data, tag="way"))
280        result: dict[int, dict[str, Any]] = {}
281        for way in ways:
282            way_data = dom.dom_parse_way(way)
283            result[way_data["id"]] = way_data
284        return result

Returns dict with the id of the way as a key for each way in way_id_list:

#!python
{
    '1234': dict of way data,
    '5678': dict of way data,
    ...
}

way_id_list is a list containing unique identifiers for multiple ways.