# 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/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/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):


import asyncio
import logging
import time
import math
import functools
import socket
import numpy
from mlat import constants, geodesy
from mlat.server import util, net
            return

    @asyncio.coroutine
    def send_heartbeats(self):
        try:
            while True:
                now = time.monotonic()
                delay = self.last_output + self.heartbeat_interval - now
                if delay > 0.1:
                    yield from asyncio.sleep(delay)
                    continue

                self.writer.write(b'\n')
                self.last_output = now

        except socket.error:
            self.close()
            return

    def write_result(self, receive_timestamp, address, ecef, ecef_cov, receivers, distinct, dof, kalman_data):
        try:
            if self.use_kalman_data:
                if not kalman_data.valid or kalman_data.last_update < receive_timestamp:
                    return

                lat, lon, alt = kalman_data.position_llh
                speed = int(round(kalman_data.ground_speed * constants.MS_TO_KTS))
                heading = int(round(kalman_data.heading))
                vrate = int(round(kalman_data.vertical_speed * constants.MS_TO_FPM))
            else:

# 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/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/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/output.py
import asyncio
import logging
import time
import math
import functools
import socket
import numpy
from mlat import constants, geodesy
from mlat.server import util, net

            return

    @asyncio.coroutine
    def send_heartbeats(self):
        try:
            while True:
                now = time.monotonic()
                delay = self.last_output + self.heartbeat_interval - now
                if delay > 0.1:
                    yield from asyncio.sleep(delay)
                    continue

                self.writer.write(b'\n')
                self.last_output = now

        except socket.error:
            self.close()
            return

    def write_result(self, receive_timestamp, address, ecef, ecef_cov, receivers, distinct, dof, kalman_data):
        try:
            if self.use_kalman_data:
                if not kalman_data.valid or kalman_data.last_update < receive_timestamp:
                    return

                lat, lon, alt = kalman_data.position_llh
                speed = int(round(kalman_data.ground_speed * constants.MS_TO_KTS))
                heading = int(round(kalman_data.heading))
                vrate = int(round(kalman_data.vertical_speed * constants.MS_TO_FPM))
            else:

                lat, lon, alt = geodesy.ecef2llh(ecef)