From 6b08d86490e40c2084a10e1f80ef9338a0782c31 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Thu, 13 Apr 2017 12:40:03 +0800 Subject: [PATCH] Handle multi-polygon in web_utils scan area --- monocle/web_utils.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/monocle/web_utils.py b/monocle/web_utils.py index cc33999bc..aae433f85 100644 --- a/monocle/web_utils.py +++ b/monocle/web_utils.py @@ -7,7 +7,7 @@ from monocle.names import DAMAGE, MOVES, POKEMON if conf.BOUNDARIES: - from shapely.geometry import mapping + from shapely.geometry import mapping, Polygon if conf.MAP_WORKERS: try: @@ -170,17 +170,21 @@ def get_spawnpoint_markers(): if conf.BOUNDARIES: def get_scan_coords(): markers = [] - coordinates = mapping(conf.BOUNDARIES)['coordinates'] - coords = coordinates[0] - for blacklist in coordinates[1:]: + boundaries = conf.BOUNDARIES + if isinstance(boundaries, Polygon): + boundaries = [boundaries] + for boundary in boundaries: + coordinates = mapping(boundary)['coordinates'] + coords = coordinates[0] + for blacklist in coordinates[1:]: + markers.append({ + 'type': 'scanblacklist', + 'coords': blacklist + }) markers.append({ - 'type': 'scanblacklist', - 'coords': blacklist + 'type': 'scanarea', + 'coords': coords }) - markers.append({ - 'type': 'scanarea', - 'coords': coords - }) return markers else: def get_scan_coords():