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 |             select | ||||||
|                 id, |                 id, | ||||||
|                 call, |                 call, | ||||||
|                 ST_Distance(coord, MakePoint(?, ?, %d), true) as distance |                 ST_Distance(coord, | ||||||
|  |                     MakeLine(MakePoint(?, ?, {csr}), | ||||||
|  |                              MakePoint(?, ?, {csr})), true) as distance | ||||||
|             from |             from | ||||||
|                 nexrad_radar |                 nexrad_radar | ||||||
|             where |             where | ||||||
|                 distance <= 460000 |                 distance <= 230000 | ||||||
|             order by |             order by | ||||||
|                 distance asc |                 distance asc | ||||||
|             limit 3 |         """.format(csr=COORD_SYSTEM) | ||||||
|         """ % (COORD_SYSTEM) |  | ||||||
| 
 | 
 | ||||||
|         st = db.execute(sql, (self.coord_start.lon, |         radars = list() | ||||||
|                               self.coord_start.lat)) |  | ||||||
| 
 | 
 | ||||||
|         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