Commit d9b8ea78 by Corey Koval

Moved AOIs to their own CZML File

parent a44e4044
...@@ -284,7 +284,6 @@ def process_data(database_name): ...@@ -284,7 +284,6 @@ def process_data(database_name):
ell_radius_y = np.sqrt(1 - pearson) * np.sqrt(c) * n_std ell_radius_y = np.sqrt(1 - pearson) * np.sqrt(c) * n_std
axis_x = v.inverse(clustermean.tolist()[::-1], (ell_radius_x + clustermean[1], clustermean[0]))[0] axis_x = v.inverse(clustermean.tolist()[::-1], (ell_radius_x + clustermean[1], clustermean[0]))[0]
axis_y = v.inverse(clustermean.tolist()[::-1], (clustermean[1], ell_radius_y + clustermean[0]))[0] axis_y = v.inverse(clustermean.tolist()[::-1], (clustermean[1], ell_radius_y + clustermean[0]))[0]
print(math.atan(2*((2*b)/(a-c)))/2)
if b == 0 and a >= c: if b == 0 and a >= c:
rotation = 0 rotation = 0
elif b == 0 and a < c: elif b == 0 and a < c:
...@@ -459,8 +458,6 @@ def write_czml(best_point, all_the_points, ellipsedata): ...@@ -459,8 +458,6 @@ def write_czml(best_point, all_the_points, ellipsedata):
best_point_packets = [] best_point_packets = []
ellipse_packets = [] ellipse_packets = []
# exclusion_packets = []
if len(all_the_points) > 0 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])
...@@ -484,21 +481,20 @@ def write_czml(best_point, all_the_points, ellipsedata): ...@@ -484,21 +481,20 @@ def write_czml(best_point, all_the_points, ellipsedata):
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]:
rotation = x[2] # rotation = x[2]
semiMajorAxis = x[0] semiMajorAxis = x[0]
semiMinorAxis = x[1] semiMinorAxis = x[1]
# rotation = 2 * np.pi - x[2] rotation = 2 * np.pi - x[2]
# rotation += np.pi/2 rotation += np.pi/2
print(f"{x[2]} Inverted to: {rotation}") # print(f"{x[2]} Inverted to: {rotation}")
print(f"SemiMajor: {semiMajorAxis}, Semiminor: {semiMinorAxis}") # print(f"SemiMajor: {semiMajorAxis}, Semiminor: {semiMinorAxis}")
# print(f"{x[4], x[3]} is inveted") # print(f"{x[4], x[3]} is inveted")
else: else:
rotation = x[2] rotation = x[2]
semiMajorAxis = x[1] semiMajorAxis = x[1]
semiMinorAxis = x[0] semiMinorAxis = x[0]
print(f"Not inverted: {rotation}") # print(f"Not inverted: {rotation}")
print(f"SemiMajor: {semiMajorAxis}, Semiminor: {semiMinorAxis}") # print(f"SemiMajor: {semiMajorAxis}, Semiminor: {semiMinorAxis}")
# print(f"{x[4], x[3]} is NOT inveted") # print(f"{x[4], x[3]} is NOT inveted")
ellipse_info = {"semiMajorAxis": semiMajorAxis, "semiMinorAxis": semiMinorAxis, "rotation": rotation} ellipse_info = {"semiMajorAxis": semiMajorAxis, "semiMinorAxis": semiMinorAxis, "rotation": rotation}
...@@ -513,11 +509,12 @@ def write_czml(best_point, all_the_points, ellipsedata): ...@@ -513,11 +509,12 @@ def write_czml(best_point, all_the_points, ellipsedata):
############################################### ###############################################
# Writes receivers.czml used by the WebUI # Writes receivers.czml used by the WebUI
############################################### ###############################################
@get('/receivers.czml')
def write_rx_czml(): def write_rx_czml():
response.set_header('Cache-Control', 'no-cache, no-store, must-revalidate')
height = 50 height = 50
receiver_point_packets = [] receiver_point_packets = []
lob_packets = [] lob_packets = []
aoi_packets = []
top = Preamble(name="Receivers") top = Preamble(name="Receivers")
rx_properties = { rx_properties = {
...@@ -528,36 +525,6 @@ def write_rx_czml(): ...@@ -528,36 +525,6 @@ def write_rx_czml():
"width": 48, "width": 48,
} }
area_of_interest_properties = {
"granularity": 0.008722222,
"height": 0,
"material": {
"solidColor": {
"color": {
"rgba": [0, 0, 255, 25]
}
}
},
"outline": True,
"outlineWidth": 2,
"outlineColor": {"rgba": [53, 184, 240, 255],},
},
exclusion_area_properties = {
"granularity": 0.008722222,
"height": 0,
"material": {
"solidColor": {
"color": {
"rgba": [242, 10, 0, 25]
}
}
},
"outline": True,
"outlineWidth": 2,
"outlineColor": {"rgba": [224, 142, 0, 255],},
},
for index, x in enumerate(receivers): for index, x in enumerate(receivers):
if x.isActive and ms.receiving: if x.isActive and ms.receiving:
lob_start_lat = x.latitude lob_start_lat = x.latitude
...@@ -590,6 +557,46 @@ def write_rx_czml(): ...@@ -590,6 +557,46 @@ def write_rx_czml():
billboard={**rx_properties, **rx_icon}, billboard={**rx_properties, **rx_icon},
position={"cartographicDegrees": [ x.longitude, x.latitude, 15 ]})) position={"cartographicDegrees": [ x.longitude, x.latitude, 15 ]}))
output = Document([top] + receiver_point_packets + lob_packets)
return str(output)
###############################################
# Writes aoi.czml used by the WebUI
###############################################
@get("/aoi.czml")
def wr_aoi_czml():
aoi_packets = []
top = Preamble(name="Receivers")
area_of_interest_properties = {
"granularity": 0.008722222,
"height": 0,
"material": {
"solidColor": {
"color": {
"rgba": [0, 0, 255, 25]
}
}
},
"outline": True,
"outlineWidth": 2,
"outlineColor": {"rgba": [53, 184, 240, 255],},
},
exclusion_area_properties = {
"granularity": 0.008722222,
"height": 0,
"material": {
"solidColor": {
"color": {
"rgba": [242, 10, 0, 25]
}
}
},
"outline": True,
"outlineWidth": 2,
"outlineColor": {"rgba": [224, 142, 0, 255],},
},
for x in fetch_aoi_data(): for x in fetch_aoi_data():
aoi = { aoi = {
'uid': x[0], 'uid': x[0],
...@@ -607,9 +614,8 @@ def write_rx_czml(): ...@@ -607,9 +614,8 @@ def write_rx_czml():
ellipse={**aoi_properties, **aoi_info}, ellipse={**aoi_properties, **aoi_info},
position={"cartographicDegrees": [ aoi['longitude'], aoi['latitude'], 0 ]})) position={"cartographicDegrees": [ aoi['longitude'], aoi['latitude'], 0 ]}))
output = Document([top] + receiver_point_packets + lob_packets + aoi_packets) output = Document([top] + aoi_packets)
return str(output)
return output
############################################### ###############################################
# CLears the screen if debugging is off. # CLears the screen if debugging is off.
...@@ -705,16 +711,6 @@ def tx_czml_out(): ...@@ -705,16 +711,6 @@ def tx_czml_out():
return str(output) return str(output)
############################################### ###############################################
# Returns a CZML file that contains receiver
# and LOB information for Cesium.
###############################################
@get('/receivers.czml')
def rx_czml_out():
response.set_header('Cache-Control', 'no-cache, no-store, must-revalidate')
output = write_rx_czml()
return str(output)
###############################################
# PUT request to update receiver variables # PUT request to update receiver variables
# from the WebUI # from the WebUI
############################################### ###############################################
......
...@@ -30,7 +30,7 @@ function makeNewAoi(aoi_type, latitude, longitude, radius) { ...@@ -30,7 +30,7 @@ function makeNewAoi(aoi_type, latitude, longitude, radius) {
fetch("/interest_areas/new", otherParams) fetch("/interest_areas/new", otherParams)
.then(res => { .then(res => {
updateAoi(createAois, true); updateAoi(createAois, true);
reloadRX(); reloadAoi();
}) })
} }
...@@ -52,7 +52,7 @@ function deleteAoi(uid) { ...@@ -52,7 +52,7 @@ function deleteAoi(uid) {
.then(res => { .then(res => {
// removerx(uid); // removerx(uid);
loadAoi(createAois); loadAoi(createAois);
reloadRX(); reloadAoi();
}) })
} }
...@@ -74,7 +74,7 @@ function purgeAoi(uid) { ...@@ -74,7 +74,7 @@ function purgeAoi(uid) {
.then(res => { .then(res => {
// removerx(uid); // removerx(uid);
loadAoi(createAois); loadAoi(createAois);
reloadRX(); reloadAoi();
}) })
} }
...@@ -87,7 +87,7 @@ function runAoi(uid) { ...@@ -87,7 +87,7 @@ function runAoi(uid) {
.then(res => { .then(res => {
// removerx(uid); // removerx(uid);
loadAoi(createAois); loadAoi(createAois);
reloadRX(); reloadAoi();
}) })
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
var transmittersDataSource = new Cesium.CzmlDataSource; var transmittersDataSource = new Cesium.CzmlDataSource;
var receiversDataSource = new Cesium.CzmlDataSource; var receiversDataSource = new Cesium.CzmlDataSource;
var aoiDataSource = new Cesium.CzmlDataSource;
// Your access token can be found at: https://cesium.com/ion/tokens. // Your access token can be found at: https://cesium.com/ion/tokens.
Cesium.Ion.defaultAccessToken = '{{access_token}}'; Cesium.Ion.defaultAccessToken = '{{access_token}}';
...@@ -213,8 +214,17 @@ ...@@ -213,8 +214,17 @@
return receiversDataSource; return receiversDataSource;
} }
function loadAoiCzml() {
aoiDataSource.load('/aoi.czml');
viewer.dataSources.add(aoiDataSource);
// console.log("Loaded CZML");
return aoiDataSource;
}
function loadAllCzml() { function loadAllCzml() {
loadTxCzml(); loadTxCzml();
loadAoiCzml();
let zoom = loadRxCzml(); let zoom = loadRxCzml();
return zoom; return zoom;
} }
...@@ -229,6 +239,11 @@ ...@@ -229,6 +239,11 @@
loadRxCzml(); loadRxCzml();
} }
function reloadAoi() {
viewer.dataSources.remove(aoiDataSource, true);
loadAoiCzml();
}
</script> </script>
<div id="cardsmenu"> <div id="cardsmenu">
<div id="menuToggle"> <div id="menuToggle">
......
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