mirror of
https://github.com/enzet/map-machine.git
synced 2025-04-29 18:27:19 +02:00
Clean up OSM reading.
This commit is contained in:
parent
36fb64a978
commit
846d935bbe
1 changed files with 14 additions and 14 deletions
|
@ -147,13 +147,13 @@ class OSMNode(Tagged):
|
||||||
tags,
|
tags,
|
||||||
int(attributes["id"]),
|
int(attributes["id"]),
|
||||||
np.array((float(attributes["lat"]), float(attributes["lon"]))),
|
np.array((float(attributes["lat"]), float(attributes["lon"]))),
|
||||||
attributes["visible"] if "visible" in attributes else None,
|
attributes.get("visible", None),
|
||||||
attributes["changeset"] if "changeset" in attributes else None,
|
attributes.get("changeset", None),
|
||||||
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
||||||
if "timestamp" in attributes
|
if "timestamp" in attributes
|
||||||
else None,
|
else None,
|
||||||
attributes["user"] if "user" in attributes else None,
|
attributes.get("user", None),
|
||||||
attributes["uid"] if "uid" in attributes else None,
|
attributes.get("uid", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -164,7 +164,7 @@ class OSMNode(Tagged):
|
||||||
:param structure: input structure
|
:param structure: input structure
|
||||||
"""
|
"""
|
||||||
return cls(
|
return cls(
|
||||||
structure["tags"] if "tags" in structure else {},
|
structure.get("tags", {}),
|
||||||
structure["id"],
|
structure["id"],
|
||||||
coordinates=np.array((structure["lat"], structure["lon"])),
|
coordinates=np.array((structure["lat"], structure["lon"])),
|
||||||
)
|
)
|
||||||
|
@ -223,13 +223,13 @@ class OSMWay(Tagged):
|
||||||
tags,
|
tags,
|
||||||
int(element.attrib["id"]),
|
int(element.attrib["id"]),
|
||||||
[nodes[int(x.attrib["ref"])] for x in element if x.tag == "nd"],
|
[nodes[int(x.attrib["ref"])] for x in element if x.tag == "nd"],
|
||||||
attributes["visible"] if "visible" in attributes else None,
|
attributes.get("visible", None),
|
||||||
attributes["changeset"] if "changeset" in attributes else None,
|
attributes.get("changeset", None),
|
||||||
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
||||||
if "timestamp" in attributes
|
if "timestamp" in attributes
|
||||||
else None,
|
else None,
|
||||||
attributes["user"] if "user" in attributes else None,
|
attributes.get("user", None),
|
||||||
attributes["uid"] if "uid" in attributes else None,
|
attributes.get("uid", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -243,7 +243,7 @@ class OSMWay(Tagged):
|
||||||
:param nodes: node structure
|
:param nodes: node structure
|
||||||
"""
|
"""
|
||||||
return cls(
|
return cls(
|
||||||
structure["tags"] if "tags" in structure else {},
|
structure.get("tags", {}),
|
||||||
structure["id"],
|
structure["id"],
|
||||||
[nodes[x] for x in structure["nodes"]],
|
[nodes[x] for x in structure["nodes"]],
|
||||||
)
|
)
|
||||||
|
@ -306,13 +306,13 @@ class OSMRelation(Tagged):
|
||||||
tags,
|
tags,
|
||||||
int(attributes["id"]),
|
int(attributes["id"]),
|
||||||
members,
|
members,
|
||||||
attributes["visible"] if "visible" in attributes else None,
|
attributes.get("visible", None),
|
||||||
attributes["changeset"] if "changeset" in attributes else None,
|
attributes.get("changeset", None),
|
||||||
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
datetime.strptime(attributes["timestamp"], OSM_TIME_PATTERN)
|
||||||
if "timestamp" in attributes
|
if "timestamp" in attributes
|
||||||
else None,
|
else None,
|
||||||
attributes["user"] if "user" in attributes else None,
|
attributes.get("user", None),
|
||||||
attributes["uid"] if "uid" in attributes else None,
|
attributes.get("uid", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Add table
Reference in a new issue