diff --git a/server/map/get_relation.py b/server/map/get_relation.py index a2f455bcf2c6b9430c8f8756a7cfb28801d8b92a..0aa7c7fcdfede41f812a0e5d585b53819d90f0be 100644 --- a/server/map/get_relation.py +++ b/server/map/get_relation.py @@ -53,8 +53,11 @@ def cut_map(self, body_of_water: str): # NB: implement body_of_water sub_div_id = 0 for tile in divided_map: # NB temporarily limited to 5 tiles - # Round coordinates to 4 decimals - center = round(tile.centroid.coords[0][0], 4), round(tile.centroid.coords[0][1], 4) + # Calculate tile center based on bounds, and round down to two decimals + min_x, min_y, max_x, max_y = tile.bounds + center = round(max_x-min_x, 4), round(max_y-min_y, 4) + # center = round(tile.centroid.coords[0][0], 4), round(tile.centroid.coords[0][1], 4) + rounded_coordinates = [] if isinstance(tile, Polygon): for coords in tile.exterior.coords: @@ -135,9 +138,7 @@ def write_json_to_file(path: str, file_name: str, json_data: dict): json.dump(json_data, f) -''' def get_divided_map(file_name): - geo_data = gpd.read_file("server/map/mjosa.geojson") + geo_data = gpd.read_file("server/map/" + file_name + ".geojson") polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon'] polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']] -'''