Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
geohash_str = place + '%'
neighbor = dbsession.query(model.Station_Geohash).\
select_from(model.Station_Geohash).\
filter(model.Station_Geohash.geohash_loc.ilike(geohash_str)).\
all()
neighborhoods = neighborhoods + neighbor
dist_list = []
# For all of the stations found in neighborhoods, check for data and snow.
# If there is data and snow for a given station, add it to the heap
for location in neighborhoods:
try:
station = dbsession.query(model.Station).filter(model.Station.id == location.station_id).one()
snow = station.snow_data[-1]
origin = float(l), float(g)
destination = float(station.latitude), float(station.longitude)
kms = int(distance(origin, destination))
mi = int(0.621371*kms)
if snow.depth != None and snow.depth > 0:
if snow.water_equiv != None and snow.water_equiv != 0:
density = (int((snow.water_equiv / snow.depth) * 100))
if density > 100:
density = 100
else:
density = "No Data"
dist_list.append({'dist':mi, 'text-code':station.id, 'id':station.given_id, 'ele':station.elevation,\
'lat':station.latitude, 'lng':station.longitude, 'name':station.name, 'depth':snow.depth,\
'depth_change':snow.depth_change, 'density':density, 'date':snow.date.strftime("%m/%d/%y %H:%M")})
else:
continue
except IndexError:
continue
# Return the 10 closest stations, their distances away in miles (converted from kms)