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])
|
||||
using_lat_lon_alt = has_empty_position and has_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)
|
||||
|
||||
# set position and broadcast
|
||||
|
@ -588,6 +589,7 @@ class EmuSession(Session):
|
|||
|
||||
# broadcast updated location when using lat/lon/alt
|
||||
if using_lat_lon_alt:
|
||||
logger.debug("broadcasting node(%s) location", node.name)
|
||||
self.broadcast_node_location(node)
|
||||
|
||||
def broadcast_node_location(self, node):
|
||||
|
|
|
@ -56,14 +56,15 @@ def edit_node(session_id, node_id):
|
|||
data = request.get_json() or {}
|
||||
|
||||
node_options = NodeOptions()
|
||||
node_position = data["position"]
|
||||
x = node_position["x"]
|
||||
y = node_position["y"]
|
||||
node_position = data.get("position", {})
|
||||
x = node_position.get("x")
|
||||
y = node_position.get("y")
|
||||
node_options.set_position(x, y)
|
||||
lat = data.get("lat")
|
||||
lon = data.get("lon")
|
||||
alt = data.get("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)
|
||||
if result:
|
||||
|
|
|
@ -114,25 +114,26 @@ def broadcast_config(config_data):
|
|||
})
|
||||
|
||||
|
||||
def broadcast_event(event):
|
||||
def broadcast_event(event_data):
|
||||
socketio.emit("event", {
|
||||
"node": event.node,
|
||||
"event_type": event.event_type,
|
||||
"name": event.name,
|
||||
"data": event.data,
|
||||
"time": event.time,
|
||||
"session": event.session
|
||||
"node": event_data.node,
|
||||
"event_type": event_data.event_type,
|
||||
"name": event_data.name,
|
||||
"data": event_data.data,
|
||||
"time": event_data.time,
|
||||
"session": event_data.session
|
||||
})
|
||||
|
||||
|
||||
def broadcast_node(node):
|
||||
def broadcast_node(node_data):
|
||||
services = node_data.services or ""
|
||||
socketio.emit("node", {
|
||||
"id": node.id,
|
||||
"name": node.name,
|
||||
"model": node.model,
|
||||
"id": node_data.id,
|
||||
"name": node_data.name,
|
||||
"model": node_data.model,
|
||||
"position": {
|
||||
"x": node.x_position,
|
||||
"y": node.y_position,
|
||||
"x": node_data.x_position,
|
||||
"y": node_data.y_position,
|
||||
},
|
||||
"services": node.services.split("|"),
|
||||
"services": services.split("|"),
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue