Spaces:
Sleeping
Sleeping
Update app.py
#1
by
peter2520
- opened
app.py
CHANGED
@@ -2,22 +2,23 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
import geopandas as gpd
|
4 |
from shapely.geometry import Point
|
|
|
5 |
|
6 |
|
7 |
def process_input(address, selected_option, additional_input):
|
8 |
-
transport_analysis_needed =
|
9 |
-
"Residential",
|
10 |
-
"Office",
|
11 |
-
"Community Facility",
|
12 |
-
]
|
13 |
-
|
14 |
-
output_address = f"You entered the address:\n{address}"
|
15 |
-
output_option = f"Selected option:\n{selected_option}"
|
16 |
|
17 |
response = requests.get(
|
18 |
f"https://geosearch.planninglabs.nyc/v2/autocomplete?text={address}"
|
19 |
)
|
|
|
20 |
data = response.json()
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
x = data["features"][0]["geometry"]["coordinates"]
|
22 |
|
23 |
# Load the GeoJSON file into a GeoDataFrame
|
@@ -29,18 +30,26 @@ def process_input(address, selected_option, additional_input):
|
|
29 |
# Find the zone that the location point is in
|
30 |
zone = geodata[geodata.geometry.contains(location_point)]["id"].values.item()
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
if selected_option in ["Off-Street Parking Facility", "Residential"]:
|
33 |
output_additional = f"Number of Units/Spaces:\n{additional_input}"
|
34 |
else:
|
35 |
output_additional = f"Area (in 1000 GSF):\n{additional_input}"
|
36 |
|
37 |
output_transport_analysis = (
|
38 |
-
f"
|
39 |
)
|
40 |
|
41 |
# Replace 'Your Zone Calculation Logic' with the actual zone calculation code
|
42 |
|
43 |
-
output_zone = f"
|
44 |
|
45 |
return (
|
46 |
output_address,
|
|
|
2 |
import requests
|
3 |
import geopandas as gpd
|
4 |
from shapely.geometry import Point
|
5 |
+
import pandas as pd
|
6 |
|
7 |
|
8 |
def process_input(address, selected_option, additional_input):
|
9 |
+
transport_analysis_needed = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
response = requests.get(
|
12 |
f"https://geosearch.planninglabs.nyc/v2/autocomplete?text={address}"
|
13 |
)
|
14 |
+
|
15 |
data = response.json()
|
16 |
+
|
17 |
+
address = data["features"][0]["properties"]["label"]
|
18 |
+
output_address = f"{address}"
|
19 |
+
output_option = f"{selected_option}"
|
20 |
+
|
21 |
+
|
22 |
x = data["features"][0]["geometry"]["coordinates"]
|
23 |
|
24 |
# Load the GeoJSON file into a GeoDataFrame
|
|
|
30 |
# Find the zone that the location point is in
|
31 |
zone = geodata[geodata.geometry.contains(location_point)]["id"].values.item()
|
32 |
|
33 |
+
# Load Zone Table of Transportation Analysis
|
34 |
+
df = pd.read_csv("./zone_table.csv")
|
35 |
+
df = df.loc[df['Development Type']==selected_option]
|
36 |
+
threshold_value = df.loc[:, zone]
|
37 |
+
|
38 |
+
if additional_input < threshold_value:
|
39 |
+
transport_analysis_needed = False
|
40 |
+
|
41 |
if selected_option in ["Off-Street Parking Facility", "Residential"]:
|
42 |
output_additional = f"Number of Units/Spaces:\n{additional_input}"
|
43 |
else:
|
44 |
output_additional = f"Area (in 1000 GSF):\n{additional_input}"
|
45 |
|
46 |
output_transport_analysis = (
|
47 |
+
f"{transport_analysis_needed}"
|
48 |
)
|
49 |
|
50 |
# Replace 'Your Zone Calculation Logic' with the actual zone calculation code
|
51 |
|
52 |
+
output_zone = f"{zone}"
|
53 |
|
54 |
return (
|
55 |
output_address,
|