Skip to content
Snippets Groups Projects
Commit 2e6fdfe4 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: write divided map to file

parent 68c84e1c
No related branches found
No related tags found
1 merge request!6Clhp map
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
......@@ -4,7 +4,7 @@ from shapely.ops import linemerge, unary_union, polygonize
import matplotlib.pyplot as plt
import random
import json
import numpy as np
import os
polygon_min_x = None # The left most point of the entire polygon
......@@ -59,7 +59,6 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water
self.wfile.write(json.dumps(tiles_json).encode('utf-8'))
def create_grid(poly: Polygon, cell_size):
# Retrieve bounds of the entire polygon
bounds = poly.bounds
......@@ -98,3 +97,20 @@ def combine_grid_with_poly(polygon, grid):
intersecting_tiles.append(intersection)
return intersecting_tiles
def write_json_to_file(path: str, file_name: str, json_data: dict):
print("Writing to file...")
if not os.path.exists(path):
raise Exception("Directory from path does not exist")
with open(path + '/' + file_name, 'w') as f:
json.dump(json_data, f)
'''
def get_divided_map(file_name):
geo_data = gpd.read_file("server/map/mjosa.geojson")
polygon_data = geo_data[geo_data['geometry'].geom_type == 'Polygon']
polygons = [Polygon(polygon.exterior) for polygon in polygon_data['geometry']]
'''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment