From a5cd0aa484f3ba59b5661fe3fd91310a5b8d9c86 Mon Sep 17 00:00:00 2001 From: Hoa Ben The Nguyen <hbnguye@stud.ntnu.no> Date: Tue, 5 Mar 2024 21:56:18 +0100 Subject: [PATCH] add: calculation for subID and groupID --- server/data_processing/area_processing.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/data_processing/area_processing.py b/server/data_processing/area_processing.py index 5ff38d4b..6239487d 100644 --- a/server/data_processing/area_processing.py +++ b/server/data_processing/area_processing.py @@ -45,7 +45,9 @@ def define_gridareas(lat, lng, area_offset, grid_size): # find subareas size relative to main area subarea_offset = area_offset/grid_size - print(main_area) + group_id = 0 + i=0 + j=0 # find the center coordinates of each area in grid to find the corner areas for y in (range(grid_size)): @@ -55,10 +57,17 @@ def define_gridareas(lat, lng, area_offset, grid_size): lat_pos = main_area[3][0] + relative_size_lat * area_size[0] + dist_to_subcenter[0] lng_pos = main_area[3][1] + relative_size_lng * area_size[1] + dist_to_subcenter[1] # id of each subarea - sub_id = x % grid_size + grid_size*y + sub_id = x % grid_size + grid_size * y + + if (x+(y*grid_size)) % ((grid_size*2) + 1) == grid_size * 2: + group_id += 2 + + if (x+(y*grid_size)) % 2 == 0 and (x+(y*grid_size)) != 0: + i += 1 + # use the center of sub areas to find the corner of each subarea corners = calculate_corners(lat_pos, lng_pos, subarea_offset) - grided_area.append((sub_id, corners)) + grided_area.append((sub_id, group_id + i%2, corners)) return grided_area -- GitLab