From 26093f7bb22549c94c88f51558595b59a8a1af64 Mon Sep 17 00:00:00 2001 From: Koa Wells Date: Mon, 18 Dec 2023 19:12:35 -0500 Subject: [PATCH] Remove unecessary files and add requirements.txt --- building_region_selector.py | 52 ------------------------------------- map_view_simple_example.py | 52 ------------------------------------- requirements.txt | 4 +++ 3 files changed, 4 insertions(+), 104 deletions(-) delete mode 100644 building_region_selector.py delete mode 100644 map_view_simple_example.py create mode 100644 requirements.txt diff --git a/building_region_selector.py b/building_region_selector.py deleted file mode 100644 index 82a7c1c..0000000 --- a/building_region_selector.py +++ /dev/null @@ -1,52 +0,0 @@ -import json - -from pathlib import Path -from shapely.geometry import Polygon - -""" -BuildingSelectionTool is a tool that allows for a subset of buildings to be selected from a larger geojson dataset. -SPDX - License - Identifier: LGPL - 3.0 - or -later -Copyright © 2023 Concordia CERC group -Project Coder Koa Wells kekoa.wells@concordia.ca -""" - -class BuildingSelectionTool: - def __init__(self, city_file, output_file): - self._city_file = city_file - self._city = json.load(city_file) - self._buildings = self._city['features'] - self._polygon_points = [] - - def _assign_buildings_to_regions(self): - for building in self._buildings: - if building['geometry']['type'] == 'Polygon': - building_centroid = Polygon(building["geometry"]["coordinates"][0]).centroid - elif building['geometry']['type'] == 'MultiPolygon': - # use the centroid of the first polygon inside of the multipolygon - building_centroid = Polygon(building["geometry"]["coordinates"][0][0]).centroid - - building['properties']['centroid'] = [building_centroid.x, building_centroid.y] - building['properties']['district_property'] = [] - - target_regions = [] - region_assigned = False - - target_region = self._regions[len(self._regions) / 2] - while not region_assigned: - if building_centroid.within(Polygon(target_region['geometry']['coordinates'])): - region_assigned = True - break - - target_region_centroid = Polygon(target_region['geometry']['coordinates']).centroid - - if building_centroid.x <= target_region_centroid.x: - if building_centroid.y >= target_region_centroid.y: - regions = regions[0:len(regions) / 2] - elif building_centroid.y < target_region_centroid.y: - regions = regions[len(regions) / 2:len(regions) - 1] - elif building_centroid.x > target_region_centroid.x: - if building_centroid.y >= target_region_centroid.y: - regions = regions[0:len(regions) / 2] - elif building_centroid.y < target_region_centroid.y: - regions = regions[len(regions) / 2:len(regions) - 1] - diff --git a/map_view_simple_example.py b/map_view_simple_example.py deleted file mode 100644 index 5189523..0000000 --- a/map_view_simple_example.py +++ /dev/null @@ -1,52 +0,0 @@ -import tkinter -import tkintermapview - -select_buildings = False -selected_coordinates = [] - -def marker_click(marker): - print(f"marker clicked - text: {marker.text} position: {marker.position}") - -def on_click(coordinates_tuple): - if select_buildings: - print(coordinates_tuple) - selected_coordinates.append(coordinates_tuple) - -def activate_selection_box(): - select_buildings = True - -# create tkinter window -root_tk = tkinter.Tk() -root_tk.geometry(f"{1000}x{700}") -root_tk.title("Building Selection Tool") - -# create left frame -leftframe = tkinter.Frame(root_tk) -leftframe.pack(side=tkinter.LEFT) - -# create right frame -rightframe = tkinter.Frame(root_tk,width=80) -rightframe.pack(side=tkinter.RIGHT) - -# create button for activating building selection -selection_box_button = tkinter.Button(leftframe, text="Create Selection Box", command=activate_selection_box) -selection_box_button.pack(side=tkinter.TOP) - -# create text box for viewing selecting coordinates -text_width = tkinter.Text(leftframe,height=50,width=30) -text_width.pack(side=tkinter.BOTTOM,padx=50) - -# create map widget -map_widget = tkintermapview.TkinterMapView(rightframe, width=1000, height=700, corner_radius=0) -map_widget.pack(fill="both", expand=True) - -# set other tile server (standard is OpenStreetMap) -map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=14) # google normal - -# set current position and zoom -map_widget.set_position(45.497059, -73.578451, marker=False) # Montreal, Quebec -map_widget.set_zoom(11) - -map_widget.add_left_click_map_command(on_click) - -root_tk.mainloop() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3078b41 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +json +shapely +pathlib +requests \ No newline at end of file