daemon: add check to catch infinity values resulting from geo transformations and throw an error

This commit is contained in:
Blake Harnden 2021-06-03 21:37:26 -07:00
parent 44d797c633
commit 7fcedf527f

View file

@ -4,6 +4,7 @@ that manages a CORE session.
""" """
import logging import logging
import math
import os import os
import pwd import pwd
import shutil import shutil
@ -610,13 +611,16 @@ class Session:
lat = options.lat lat = options.lat
lon = options.lon lon = options.lon
alt = options.alt alt = options.alt
# check if we need to generate position from lat/lon/alt # check if we need to generate position from lat/lon/alt
has_empty_position = all(i is None for i in [x, y]) has_empty_position = all(i is None for i in [x, y])
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:
x, y, _ = self.location.getxyz(lat, lon, alt) x, y, _ = self.location.getxyz(lat, lon, alt)
if math.isinf(x) or math.isinf(y):
raise CoreError(
f"invalid geo for current reference/scale: {lon},{lat},{alt}"
)
node.setposition(x, y, None) node.setposition(x, y, None)
node.position.set_geo(lon, lat, alt) node.position.set_geo(lon, lat, alt)
self.broadcast_node(node) self.broadcast_node(node)