Commit 929bcaf8 authored by Sebastian Hörl's avatar Sebastian Hörl
Browse files

Fix hexagon script for LOD scenario

parent c6a5960b
......@@ -27,6 +27,7 @@ t = 2.0 * hexagon_radius * np.cos(30.0 * np.pi / 180.0) / np.sqrt(3.0)
offset_y = hexagon_radius + 0.5 * t
geometry = []
counter = {}
for area_name, area_geometry in zip(df_operating_areas[service_area_attribute_name], df_operating_areas["geometry"]):
min_x, min_y, max_x, max_y = area_geometry.bounds
......@@ -34,7 +35,8 @@ for area_name, area_geometry in zip(df_operating_areas[service_area_attribute_na
max_i = int(np.ceil((max_x - min_x) / offset_x)) + 1
max_j = int(np.ceil((max_y - min_y) / offset_y)) + 1
index = 0
if not area_name in counter:
counter[area_name] = 0
for i in range(max_i):
for j in range(max_j):
......@@ -46,8 +48,8 @@ for area_name, area_geometry in zip(df_operating_areas[service_area_attribute_na
hexagon = geo.Polygon(corners + centroid)
if hexagon.intersects(area_geometry):
geometry.append((area_name, "%s_%d" % (area_name, index), hexagon))
index += 1
counter[area_name] += 1
geometry.append((area_name, "%s_%d" % (area_name, counter[area_name]), hexagon))
df = pd.DataFrame.from_records(geometry, columns = [service_area_attribute_name, waiting_time_zone_attribute_name, "geometry"])
df = gpd.GeoDataFrame(df, crs = {"init": "EPSG:2056"})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment