rest - account for node update with only geo, that results in calculation the x,y
This commit is contained in:
parent
a42b29b563
commit
f57e931082
3 changed files with 21 additions and 17 deletions
|
@ -581,6 +581,7 @@ class EmuSession(Session):
|
||||||
has_lat_lon_alt = all(i is not None for i in [lat, lon, alt])
|
has_lat_lon_alt = all(i is not None for i in [lat, lon, alt])
|
||||||
using_lat_lon_alt = has_empty_position and has_lat_lon_alt
|
using_lat_lon_alt = has_empty_position and has_lat_lon_alt
|
||||||
if using_lat_lon_alt:
|
if using_lat_lon_alt:
|
||||||
|
logger.debug("updating node(%s) location using geo: %s, %s, %s", node.name, lat, lon, alt)
|
||||||
x, y, _ = self.location.getxyz(lat, lon, alt)
|
x, y, _ = self.location.getxyz(lat, lon, alt)
|
||||||
|
|
||||||
# set position and broadcast
|
# set position and broadcast
|
||||||
|
@ -588,6 +589,7 @@ class EmuSession(Session):
|
||||||
|
|
||||||
# broadcast updated location when using lat/lon/alt
|
# broadcast updated location when using lat/lon/alt
|
||||||
if using_lat_lon_alt:
|
if using_lat_lon_alt:
|
||||||
|
logger.debug("broadcasting node(%s) location", node.name)
|
||||||
self.broadcast_node_location(node)
|
self.broadcast_node_location(node)
|
||||||
|
|
||||||
def broadcast_node_location(self, node):
|
def broadcast_node_location(self, node):
|
||||||
|
|
|
@ -56,14 +56,15 @@ def edit_node(session_id, node_id):
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
|
|
||||||
node_options = NodeOptions()
|
node_options = NodeOptions()
|
||||||
node_position = data["position"]
|
node_position = data.get("position", {})
|
||||||
x = node_position["x"]
|
x = node_position.get("x")
|
||||||
y = node_position["y"]
|
y = node_position.get("y")
|
||||||
node_options.set_position(x, y)
|
node_options.set_position(x, y)
|
||||||
lat = data.get("lat")
|
lat = data.get("lat")
|
||||||
lon = data.get("lon")
|
lon = data.get("lon")
|
||||||
alt = data.get("alt")
|
alt = data.get("alt")
|
||||||
node_options.set_location(lat, lon, alt)
|
node_options.set_location(lat, lon, alt)
|
||||||
|
logger.debug("updating node(%s) - pos(%s, %s) geo(%s, %s, %s)", node_id, x, y, lat, lon, alt)
|
||||||
|
|
||||||
result = session.update_node(node_id, node_options)
|
result = session.update_node(node_id, node_options)
|
||||||
if result:
|
if result:
|
||||||
|
|
|
@ -114,25 +114,26 @@ def broadcast_config(config_data):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def broadcast_event(event):
|
def broadcast_event(event_data):
|
||||||
socketio.emit("event", {
|
socketio.emit("event", {
|
||||||
"node": event.node,
|
"node": event_data.node,
|
||||||
"event_type": event.event_type,
|
"event_type": event_data.event_type,
|
||||||
"name": event.name,
|
"name": event_data.name,
|
||||||
"data": event.data,
|
"data": event_data.data,
|
||||||
"time": event.time,
|
"time": event_data.time,
|
||||||
"session": event.session
|
"session": event_data.session
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def broadcast_node(node):
|
def broadcast_node(node_data):
|
||||||
|
services = node_data.services or ""
|
||||||
socketio.emit("node", {
|
socketio.emit("node", {
|
||||||
"id": node.id,
|
"id": node_data.id,
|
||||||
"name": node.name,
|
"name": node_data.name,
|
||||||
"model": node.model,
|
"model": node_data.model,
|
||||||
"position": {
|
"position": {
|
||||||
"x": node.x_position,
|
"x": node_data.x_position,
|
||||||
"y": node.y_position,
|
"y": node_data.y_position,
|
||||||
},
|
},
|
||||||
"services": node.services.split("|"),
|
"services": services.split("|"),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue