Skip to content

Commit e366c77

Browse files
author
matthias_schaub
committed
Add type hints.
1 parent b681dab commit e366c77

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

mapswipe_workers/mapswipe_workers/utils/tile_grouping_functions.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import math
22

33
from osgeo import ogr
4+
from Typing import Dict, List
45

56
from mapswipe_workers.definitions import logger
67
from mapswipe_workers.utils import tile_functions as t
@@ -49,7 +50,7 @@ def get_geometry_from_file(infile: str):
4950
return extent, geomcol
5051

5152

52-
def get_horizontal_slice(extent, geomcol, zoom):
53+
def get_horizontal_slice(extent: List, geomcol, zoom: int):
5354
"""
5455
The function slices all input geometries vertically
5556
using a height of max 3 tiles per geometry.
@@ -155,7 +156,7 @@ def get_horizontal_slice(extent, geomcol, zoom):
155156
return slice_infos
156157

157158

158-
def get_vertical_slice(slice_infos, zoom, width_threshold=40):
159+
def get_vertical_slice(slice_infos: Dict, zoom: int, width_threshold: int = 40):
159160
"""
160161
The function slices the horizontal stripes vertically.
161162
Each input stripe has a height of three tiles
@@ -287,7 +288,7 @@ def get_vertical_slice(slice_infos, zoom, width_threshold=40):
287288
return raw_groups
288289

289290

290-
def groups_intersect(group_a, group_b):
291+
def groups_intersect(group_a: Dict, group_b: Dict):
291292
"""Check if groups intersect."""
292293
x_max = int(group_a["xMax"])
293294
x_min = int(group_a["xMin"])
@@ -307,7 +308,7 @@ def groups_intersect(group_a, group_b):
307308
)
308309

309310

310-
def merge_groups(group_a, group_b, zoom):
311+
def merge_groups(group_a: Dict, group_b: Dict, zoom: int):
311312
"""Merge two overlapping groups into a single group.
312313
313314
This can result in groups that are "longer" than
@@ -364,7 +365,7 @@ def merge_groups(group_a, group_b, zoom):
364365
return new_group
365366

366367

367-
def adjust_overlapping_groups(groups, zoom):
368+
def adjust_overlapping_groups(groups: Dict, zoom: int):
368369
"""Loop through groups dict and merge overlapping groups."""
369370

370371
groups_without_overlap = {}
@@ -398,7 +399,7 @@ def adjust_overlapping_groups(groups, zoom):
398399
return groups_without_overlap, overlaps_total
399400

400401

401-
def extent_to_groups(infile, zoom, groupSize):
402+
def extent_to_groups(infile, zoom: int, groupSize):
402403
"""
403404
The function to polygon geometries of a given input file
404405
into horizontal slices and then vertical slices.
@@ -444,7 +445,7 @@ def extent_to_groups(infile, zoom, groupSize):
444445
return groups_dict
445446

446447

447-
def vertical_groups_as_geojson(raw_group_infos, outfile):
448+
def vertical_groups_as_geojson(raw_group_infos: Dict, outfile: str):
448449
"""
449450
The function to create a geojson file from the groups dictionary.
450451
@@ -494,7 +495,7 @@ def vertical_groups_as_geojson(raw_group_infos, outfile):
494495
return True
495496

496497

497-
def horizontal_groups_as_geojson(slices_info, outfile):
498+
def horizontal_groups_as_geojson(slices_info: Dict, outfile: str):
498499

499500
# Create the output Driver and out GeoJson
500501
outDriver = ogr.GetDriverByName("GeoJSON")

0 commit comments

Comments
 (0)