Commit b6d4d389 by Corey Koval

Fixed handling of empty database

parent eb711a43
...@@ -143,11 +143,14 @@ def process_data(database_name, outfile): ...@@ -143,11 +143,14 @@ def process_data(database_name, outfile):
c = conn.cursor() c = conn.cursor()
intersect_list = [] intersect_list = []
try:
c.execute("SELECT COUNT(*) FROM intersects") c.execute("SELECT COUNT(*) FROM intersects")
n_intersects = int(c.fetchone()[0]) n_intersects = int(c.fetchone()[0])
c.execute("SELECT longitude, latitude, time FROM intersects") c.execute("SELECT longitude, latitude, time FROM intersects")
intersect_array = np.array(c.fetchall()) intersect_array = np.array(c.fetchall())
except sqlite3.OperationalError:
n_intersects = 0
intersect_array = np.array([])
likely_location = [] likely_location = []
weighted_location = [] weighted_location = []
ellipsedata = [] ellipsedata = []
...@@ -214,11 +217,11 @@ def process_data(database_name, outfile): ...@@ -214,11 +217,11 @@ def process_data(database_name, outfile):
except IndexError: except IndexError:
intersect_list.append(x.tolist()) intersect_list.append(x.tolist())
return likely_location, intersect_list, ellipsedata
else: else:
print("No Intersections.") print("No Intersections.")
return None # return None
return likely_location, intersect_list, ellipsedata
def write_geojson(best_point, all_the_points): def write_geojson(best_point, all_the_points):
all_pt_style = {"name": "Various Points", "marker-color": "#FF0000"} all_pt_style = {"name": "Various Points", "marker-color": "#FF0000"}
...@@ -281,7 +284,7 @@ def write_czml(best_point, all_the_points, ellipsedata): ...@@ -281,7 +284,7 @@ def write_czml(best_point, all_the_points, ellipsedata):
receiver_point_packets = [] receiver_point_packets = []
ellipse_packets = [] ellipse_packets = []
if all_the_points != None and (ms.plotintersects or ms.eps == 0): if len(all_the_points) > 0 and (ms.plotintersects or ms.eps == 0):
all_the_points = np.array(all_the_points) all_the_points = np.array(all_the_points)
scaled_time = minmax_scale(all_the_points[:,-1]) scaled_time = minmax_scale(all_the_points[:,-1])
all_the_points = np.column_stack((all_the_points, scaled_time)) all_the_points = np.column_stack((all_the_points, scaled_time))
...@@ -293,13 +296,13 @@ def write_czml(best_point, all_the_points, ellipsedata): ...@@ -293,13 +296,13 @@ def write_czml(best_point, all_the_points, ellipsedata):
position={"cartographicDegrees": [ x[0], x[1], 10 ]}, position={"cartographicDegrees": [ x[0], x[1], 10 ]},
)) ))
if best_point != None: if len(best_point) > 0:
for x in best_point: for x in best_point:
best_point_packets.append(Packet(id=str(x[0]) + ", " + str(x[1]), best_point_packets.append(Packet(id=str(x[0]) + ", " + str(x[1]),
point=best_point_properties, point=best_point_properties,
position={"cartographicDegrees": [ x[1], x[0], 15 ]})) position={"cartographicDegrees": [ x[1], x[0], 15 ]}))
if ellipsedata != None: if len(ellipsedata) > 0:
for x in ellipsedata: for x in ellipsedata:
# rotation = 2 * np.pi - x[2] # rotation = 2 * np.pi - x[2]
if x[0] >= x[1]: if x[0] >= x[1]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment