Refactor radar distance search to match whole storm path
This commit is contained in:
parent
12ead19918
commit
0726782ee8
1 changed files with 19 additions and 7 deletions
|
@ -118,17 +118,29 @@ class StormReport():
|
|||
select
|
||||
id,
|
||||
call,
|
||||
ST_Distance(coord, MakePoint(?, ?, %d), true) as distance
|
||||
ST_Distance(coord,
|
||||
MakeLine(MakePoint(?, ?, {csr}),
|
||||
MakePoint(?, ?, {csr})), true) as distance
|
||||
from
|
||||
nexrad_radar
|
||||
where
|
||||
distance <= 460000
|
||||
distance <= 230000
|
||||
order by
|
||||
distance asc
|
||||
limit 3
|
||||
""" % (COORD_SYSTEM)
|
||||
""".format(csr=COORD_SYSTEM)
|
||||
|
||||
st = db.execute(sql, (self.coord_start.lon,
|
||||
self.coord_start.lat))
|
||||
radars = list()
|
||||
|
||||
return st.fetchone()
|
||||
st = db.execute(sql, (
|
||||
self.coord_start.lon, self.coord_start.lat,
|
||||
self.coord_end.lon, self.coord_end.lat))
|
||||
|
||||
while True:
|
||||
radar = st.fetchone()
|
||||
|
||||
if radar is None:
|
||||
break
|
||||
|
||||
radars.append(radar)
|
||||
|
||||
return radars
|
||||
|
|
Loading…
Add table
Reference in a new issue