# Path: mlat/geodesy.py
# WGS84_A = 6378137.0
# WGS84_F = 1.0/298.257223563
# WGS84_B = WGS84_A * (1 - WGS84_F)
# WGS84_ECC_SQ = 1 - WGS84_B * WGS84_B / (WGS84_A * WGS84_A)
# WGS84_ECC = math.sqrt(WGS84_ECC_SQ)
# SPHERICAL_R = 6371e3
#     N = WGS84_A / math.sqrt(1 - WGS84_ECC_SQ * math.sin(lat)**2)
# def llh2ecef(llh):
# def ecef2llh(ecef):
# def greatcircle(p0, p1):
# def ecef_distance(p0, p1):
# 
# Path: mlat/server/net.py
# class MonitoringListener(object):
# class MonitoringConnector(object):
#     def __init__(self, host, port, factory, logger=glogger, description=None):
#     def start(self):
#     def _start(self):
#     def _new_client(self, r, w):
#     def _close(self):
#     def start_client(self, r, w):
#     def monitor_client(self, client):
#     def close(self):
#     def wait_closed(self):
#     def __init__(self, host, port, reconnect_interval, factory):
#     def start(self):
#     def reconnect(self):
#     def close(self):
#     def wait_closed(self):
# 
# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):
# 
# Path: mlat/server/connection.py
# class Connection(object):
#     def request_traffic(self, receiver, icao_set):
#     def report_mlat_position(self, receiver,
#                              receive_timestamp, address, ecef, ecef_cov, receivers, distinct):
# 
# Path: mlat/server/config.py
# MIN_NUC = 6
# MAX_RANGE = 500e3
# MAX_INTERMESSAGE_RANGE = 10e3
# MAX_ALT = 50000 * constants.FTOM
# MLAT_DELAY = 2.5
# SOLVER_MAXFEV = 50


import asyncio
import zlib
import logging
import json
import struct
import time
import random
import socket
import inspect
import sys
import math
from mlat import constants, geodesy
from mlat.server import net, util, connection, config
                    raise ValueError('invalid longitude, should be -180 .. 360')
                if lon > 180:
                    lon = lon - 180

                alt = float(hs['alt'])
                if alt < -1000 or alt > 10000:
                    raise ValueError('invalid altitude, should be -1000 .. 10000')

                clock_type = str(hs.get('clock_type', 'dump1090'))

                self.use_return_results = bool(hs.get('return_results', False))
                if self.use_return_results:
                    return_result_format = hs.get('return_result_format', 'old')
                    if return_result_format == 'old':
                        self.report_mlat_position = self.report_mlat_position_old
                    elif return_result_format == 'ecef':
                        self.report_mlat_position = self.report_mlat_position_ecef
                    else:
                        raise ValueError('invalid return_result_format, should be one of "old" or "ecef"')
                else:
                    self.report_mlat_position = self.report_mlat_position_discard

                self.use_udp = (self.udp_protocol is not None and hs.get('udp_transport', 0) == 2)

                conn_info = 'v{v} {clock_type} {cversion} {udp} {compress}'.format(
                    v=hs['version'],
                    cversion=hs.get("client_version", "unknown"),
                    udp="udp" if self.use_udp else "tcp",
                    clock_type=clock_type,
                    compress=self.compress)

# Path: mlat/geodesy.py
# WGS84_A = 6378137.0
# WGS84_F = 1.0/298.257223563
# WGS84_B = WGS84_A * (1 - WGS84_F)
# WGS84_ECC_SQ = 1 - WGS84_B * WGS84_B / (WGS84_A * WGS84_A)
# WGS84_ECC = math.sqrt(WGS84_ECC_SQ)
# SPHERICAL_R = 6371e3
#     N = WGS84_A / math.sqrt(1 - WGS84_ECC_SQ * math.sin(lat)**2)
# def llh2ecef(llh):
# def ecef2llh(ecef):
# def greatcircle(p0, p1):
# def ecef_distance(p0, p1):
# 
# Path: mlat/server/net.py
# class MonitoringListener(object):
# class MonitoringConnector(object):
#     def __init__(self, host, port, factory, logger=glogger, description=None):
#     def start(self):
#     def _start(self):
#     def _new_client(self, r, w):
#     def _close(self):
#     def start_client(self, r, w):
#     def monitor_client(self, client):
#     def close(self):
#     def wait_closed(self):
#     def __init__(self, host, port, reconnect_interval, factory):
#     def start(self):
#     def reconnect(self):
#     def close(self):
#     def wait_closed(self):
# 
# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):
# 
# Path: mlat/server/connection.py
# class Connection(object):
#     def request_traffic(self, receiver, icao_set):
#     def report_mlat_position(self, receiver,
#                              receive_timestamp, address, ecef, ecef_cov, receivers, distinct):
# 
# Path: mlat/server/config.py
# MIN_NUC = 6
# MAX_RANGE = 500e3
# MAX_INTERMESSAGE_RANGE = 10e3
# MAX_ALT = 50000 * constants.FTOM
# MLAT_DELAY = 2.5
# SOLVER_MAXFEV = 50


# Path: mlat/server/jsonclient.py
import asyncio
import zlib
import logging
import json
import struct
import time
import random
import socket
import inspect
import sys
import math
from mlat import constants, geodesy
from mlat.server import net, util, connection, config

                    raise ValueError('invalid longitude, should be -180 .. 360')
                if lon > 180:
                    lon = lon - 180

                alt = float(hs['alt'])
                if alt < -1000 or alt > 10000:
                    raise ValueError('invalid altitude, should be -1000 .. 10000')

                clock_type = str(hs.get('clock_type', 'dump1090'))

                self.use_return_results = bool(hs.get('return_results', False))
                if self.use_return_results:
                    return_result_format = hs.get('return_result_format', 'old')
                    if return_result_format == 'old':
                        self.report_mlat_position = self.report_mlat_position_old
                    elif return_result_format == 'ecef':
                        self.report_mlat_position = self.report_mlat_position_ecef
                    else:
                        raise ValueError('invalid return_result_format, should be one of "old" or "ecef"')
                else:
                    self.report_mlat_position = self.report_mlat_position_discard

                self.use_udp = (self.udp_protocol is not None and hs.get('udp_transport', 0) == 2)

                conn_info = 'v{v} {clock_type} {cversion} {udp} {compress}'.format(
                    v=hs['version'],
                    cversion=hs.get("client_version", "unknown"),
                    udp="udp" if self.use_udp else "tcp",
                    clock_type=clock_type,
                    compress=self.compress)

                self.receiver = self.coordinator.new_receiver(connection=self,