# 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
        expanded_motd = """

        {motd}

        The multilateration server source code is available under
        the terms of the Affero GPL (v3 or later). You may obtain
        a copy of this server's source code at the following
        location: {agpl_url}
        """.format(agpl_url=config.AGPL_SERVER_CODE_URL,
                   motd=self.motd)

        response = {"compress": self.compress,
                    "reconnect_in": util.fuzzy(15),
                    "selective_traffic": True,
                    "heartbeat": True,
                    "return_results": self.use_return_results,
                    "rate_reports": True,
                    "motd": expanded_motd}

        if self.use_udp:
            self._udp_key = self.udp_protocol.add_client(sync_handler=self.process_sync,
                                                         mlat_handler=self.process_mlat)
            response['udp_transport'] = (self.udp_host,
                                         self.udp_port,
                                         self._udp_key)

        self.write_raw(**response)
        self.logger.info("Handshake successful ({user} {conn_info})'".format(
            user=user,
            conn_info=conn_info))

# 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

        expanded_motd = """

        {motd}

        The multilateration server source code is available under
        the terms of the Affero GPL (v3 or later). You may obtain
        a copy of this server's source code at the following
        location: {agpl_url}
        """.format(agpl_url=config.AGPL_SERVER_CODE_URL,
                   motd=self.motd)

        response = {"compress": self.compress,
                    "reconnect_in": util.fuzzy(15),
                    "selective_traffic": True,
                    "heartbeat": True,
                    "return_results": self.use_return_results,
                    "rate_reports": True,
                    "motd": expanded_motd}

        if self.use_udp:
            self._udp_key = self.udp_protocol.add_client(sync_handler=self.process_sync,
                                                         mlat_handler=self.process_mlat)
            response['udp_transport'] = (self.udp_host,
                                         self.udp_port,
                                         self._udp_key)

        self.write_raw(**response)
        self.logger.info("Handshake successful ({user} {conn_info})'".format(
            user=user,
            conn_info=conn_info))

        self.logger = util.TaggingLogger(glogger, {'tag': '{user}'.format(user=user)})