pass
// parse grade attrs to float: should always have only 1 value each
if "grade" in data:
data["grade"] = float(data["grade"])
if "grade_abs" in data:
data["grade_abs"] = float(data["grade_abs"])
// these attributes might have a single value, or a list if edge"s
// topology was simplified
for attr in [
"highway",
"name",
"bridge",
"tunnel",
"lanes",
"ref",
"maxspeed",
"service",
"access",
"area",
"landuse",
"width",
"est_width",
]:
// if this edge has this attribute, and it starts with "[" and ends
// with "]", then it"s a list to be parsed
if attr in data and data[attr].startswith("[") and data[attr].endswith("]"):
// try to convert the string list to a list type, else leave as
// single-value string (and leave as string if error)
try:
data[attr] = ast.literal_eval(data[attr])
except Exception:
pass
// osmid might have a single value or a list
if "osmid" in data:
if data["osmid"].startswith("[") and data["osmid"].endswith("]"):
// if it"s a list, eval list then convert each element to node_type
data["osmid"] = [node_type(i) for i in ast.literal_eval(data["osmid"])]
else:
// if it"s not a list, convert it to the node_type
data["osmid"] = node_type(data["osmid"])
// if geometry attribute exists, load the string as well-known text to
// shapely LineString
if "geometry" in data:
data["geometry"] = wkt.loads(data["geometry"])
return G