Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -119,28 +119,28 @@ def get_duration_score(user, shelter):
|
|
119 |
if shelter == "Transitional": return 0.5
|
120 |
if shelter == "Long-Term": return 0
|
121 |
|
122 |
-
def get_coordinates(zipcode: str, api_key: str) -> list:
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
Parameters:
|
127 |
-
zipcode (str): The zipcode to geocode.
|
128 |
-
api_key (str): Your OpenWeather API key.
|
129 |
-
|
130 |
-
Returns:
|
131 |
-
list: A list containing the latitude and longitude of the address.
|
132 |
-
"""
|
133 |
-
|
134 |
-
base_url = "http://api.openweathermap.org/geo/1.0/zip"
|
135 |
-
params = {
|
136 |
-
'zip': str(zipcode) + ",US",
|
137 |
-
'appid': api_key
|
138 |
-
}
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
def haversine(lat1, lon1, lat2, lon2):
|
146 |
R = 6371 # Earth radius in kilometers. Use 3956 for miles.
|
@@ -251,7 +251,7 @@ else:
|
|
251 |
max_d = max(distances) if (max(distances) != 0) else 1
|
252 |
shelters['zipcode_score'] = [d / max_d for d in distances]
|
253 |
scores.append('zipcode_score')
|
254 |
-
print('zipcode_score')
|
255 |
|
256 |
# get urgency scores
|
257 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|
@@ -285,8 +285,6 @@ else:
|
|
285 |
scores.append('time_score')
|
286 |
elif data['Urgency'] == "In a week or more":
|
287 |
pass
|
288 |
-
|
289 |
-
print(scores)
|
290 |
|
291 |
# calcualte cumulative score
|
292 |
shelters['total_score'] = shelters[scores].sum(axis=1)
|
|
|
119 |
if shelter == "Transitional": return 0.5
|
120 |
if shelter == "Long-Term": return 0
|
121 |
|
122 |
+
# def get_coordinates(zipcode: str, api_key: str) -> list:
|
123 |
+
# """
|
124 |
+
# Get the coordinates (latitude and longitude) of an address using the OpenWeather Geocoding API.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
+
# Parameters:
|
127 |
+
# zipcode (str): The zipcode to geocode.
|
128 |
+
# api_key (str): Your OpenWeather API key.
|
129 |
+
|
130 |
+
# Returns:
|
131 |
+
# list: A list containing the latitude and longitude of the address.
|
132 |
+
# """
|
133 |
+
|
134 |
+
# base_url = "http://api.openweathermap.org/geo/1.0/zip"
|
135 |
+
# params = {
|
136 |
+
# 'zip': str(zipcode) + ",US",
|
137 |
+
# 'appid': api_key
|
138 |
+
# }
|
139 |
+
|
140 |
+
# response = requests.get(base_url, params=params)
|
141 |
+
# data = response.json()
|
142 |
+
# print(data)
|
143 |
+
# return [data.get('lat'), data.get('lon')]
|
144 |
|
145 |
def haversine(lat1, lon1, lat2, lon2):
|
146 |
R = 6371 # Earth radius in kilometers. Use 3956 for miles.
|
|
|
251 |
max_d = max(distances) if (max(distances) != 0) else 1
|
252 |
shelters['zipcode_score'] = [d / max_d for d in distances]
|
253 |
scores.append('zipcode_score')
|
254 |
+
print(scores['zipcode_score'])
|
255 |
|
256 |
# get urgency scores
|
257 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|
|
|
285 |
scores.append('time_score')
|
286 |
elif data['Urgency'] == "In a week or more":
|
287 |
pass
|
|
|
|
|
288 |
|
289 |
# calcualte cumulative score
|
290 |
shelters['total_score'] = shelters[scores].sum(axis=1)
|