Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalmhjn committed Nov 29, 2023
1 parent 653e38e commit 6e8ab66
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/helpers/sumoClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Sumo_Network:
A class for handling SUMO network data.
"""

def __init(
def __init__(
self,
path_network_csv="../data/paris_auto.net.csv",
path_edge_csv="../data/plainnet.edg.csv",
Expand Down Expand Up @@ -97,14 +97,14 @@ def sumo_net_to_geojson(self, output_path="../data/sumo_network.geojson"):
d["type"] = "FeatureCollection"
d["features"] = li
with open(output_path, "w") as f:
f.write(json.dumps(d, sort_keys=False, indent=4)
f.write(json.dumps(d, sort_keys=False, indent=4))

class Create_TAZs:
"""
A class for creating TAZs (Traffic Analysis Zones) from SUMO network data.
"""

def __init(
def __init__(
self,
path_sumo_network_geojson="../data/sumo_network.geojson",
path_zones_geojson="../data/paris_communes.json",
Expand Down Expand Up @@ -167,7 +167,8 @@ def write_tazs(self, output_path="../data/taZes.taz.xml"):
taz = self.get_tazs(attribute=self.osm_attr)
a = """<tazs>"""
b = ""
for i in taz[taz["link_type"].isin(["highway.secondary", "highway.tertiary"])].id.unique():
# for i in taz[taz["link_type"].isin(["highway.secondary", "highway.tertiary"])].id.unique():
for i in taz.id.unique():
temp = taz[taz.id == i]["edge_id"]
x = list(temp)
b = (
Expand All @@ -189,13 +190,14 @@ def write_tazs(self, output_path="../data/taZes.taz.xml"):
if __name__ == "__main__":
# Example usage:
# Convert SUMO network to GeoJSON
# geo = Sumo_Network()
# geo.sumo_net_to_geojson()
# geo = Sumo_Network(path_network_csv="network.net.csv",
# path_edge_csv="plainnet.edg.csv",)
# geo.sumo_net_to_geojson(output_path="network.geojson")

# Create TAZs
taz = Create_TAZs(
"../../ua_aqt/network.geojson",
"../../ua_aqt/taz.geojson",
"network.geojson",
"taz.geojson",
)
t = taz.get_tazs("NO")
taz.write_tazs("../../ua_aqt/tazes.taz.xml")
taz.write_tazs("tazes.taz.xml")

0 comments on commit 6e8ab66

Please sign in to comment.