#ifndef _LOC_POINT_HPP_
#define _LOC_POINT_HPP_

#include "point.h"
#include "line_fit.h"

struct loc_message;

struct loc_point:point
{
	int64_t m_time;
	int     m_ct;
	uint32_t m_cid;
    int     m_sid;
	float	m_acc;
	float	m_rav;
	int	    m_cred_level;
	int		m_tof[2];
	//float	m_rsp[2];
	int	    m_step;
	double  m_area;
	point   m_sol[2];
	double  m_dist;
	double 	m_speed;
	int 	m_stat;
    bool    m_useless;

	double m_dist1;	//smooth phase 1
	double m_dist2;	//smooth phase 3
	double m_smooth_x;
	double m_smooth_y;

	fit_result m_k;

	fit_result&set_k(const fit_result&k)
	{
		return m_k=k;
	}

	loc_point();
	const point& operator[](int i)const
	{
		return m_sol[i];
	}

	point& operator[](int i)
	{
		return m_sol[i];
	}

	double loc_dist(const point&pt)const
	{
		return m_sol[0].dist_direct(pt);
	}

	double loc_dist(const loc_point&lp)const
	{
		return m_sol[0].dist_direct(lp.m_sol[0]);
	}

	bool is_same_site(const loc_point&o)const
	{
		return m_sid==o.m_sid;
	}

	double time_off(const loc_point&o)const
	{
		return (o.m_time-m_time)/1000.;
	}

	double ct_off(const loc_point&o)const
	{
		return o.m_ct-m_ct;
	}

	void  debug_out(const char * str="")const ;

	void set_sol(int i,const point&p) ;
	bool b_50m()const
	{
		static int tof_50m=50/(15.65*2.996*1e-4);
		return m_tof[0]==0?m_tof[1]>tof_50m:m_tof[0]>tof_50m;
	}

	loc_point& reset() ;

	int inc_cl(int cred_level) ;
	int set_cl(int cred_level) ;
	int cl()const ;

	void set_source(const loc_message&li,const loc_message&li2) ;
	void set_source(const loc_message&li) ;
};
#endif

