以前書いたコードは役に立つような気がします


以前書いたコードが役に立つような気がしますが、

// TestDlg.h :    


#pragma once


#define ANG(dradian) (double((dradian)*180/M_PI)) 
typedef struct tagJWD
{
    double fLONG;//  
    double fLAT;//  
    bool operator == (const tagJWD ob)
    {
        bool isok=false;
        if( abs(fLONG-ob.fLONG)<0.00001 && abs(fLAT-ob.fLAT)<0.00001)
        {
            isok=true;
        }
        return isok;
    }
}JWD;

typedef struct tagSITE
{
    vector boundPoint;
    double minfLONG;
    double minfLAT;
    double maxfLONG;
    double maxfLAT;
    CString cityName;
}SITE;

//    
class CSwStation
{
public:
    CSwStation()
    {
        nType = 2;
        strGUID = "";
        strStartTime = "";
        strStopTime = "";
        strEmisType = "";
        nBand = 0;
        nFreq = 0;
        nPow = -999;
        nLevel = -999;
        nOcc = nGate = -999;
        bGeneral = false;
        sApplycode = "";
        sDeclCode  = "";
        bExistFreq = false;
        bLocal     = true;
        nSendAnteHigh = 0;
        nBJIndication= -999;        //     
        nBJElevation= -999;     //    
        nHRBIndication= -999;       //      
        nHRBElevation= -999;        //      
        nSHIndication= -999;        //     
        nSHElevation= -999;     //     
        nCHDIndication= -999;       //     
        nCHDElevation= -999;        //     
        nWLMQIndication= -999;  //       
        nWLMQElevation= -999;       //       
        nSZIndication= -999;        //     
        nSZElevation= -999;     //     
        nWYSIndication= -999;       //      
        nWYSElevation= -999;        //      
        nXAIndication= -999;        //     
        nXAElevation= -999;     //    
        nKMIndication= -999;        //     
        nKMElevation= -999;     //    
        nAntPloa = -1;
        fantegaint = -999;
        dEmcField  = -999.f;
        dEmcStrength = -999.f;
    }

    ~CSwStation(){;}

    int             nType;              //      0-ITU-HFBC 1-      2-      3-  
    std::string     strGUID;
    __int64         nFreq;              //  
    std::string     strMonitorDate;     //    
    std::string     strStartTime;       //    
    std::string     strStopTime;        //    
    int             nLevel;             //     100 
    std::string     strBRC;             //    
    std::string     strADM;             //    
    std::string     strStationType;     //    
    __int64         nBand;              //  (Hz)
    std::string     strEmisType;        //    
    std::string     strLONGITYPE;       //    (E/W)
    int             nLongi;             //  ( )
    double          nLongifen;          //  ( )
    std::string     strLATITYPE;        //    (N/S)
    int             nLati;              //  ( )
    double          nLatifen;           //  ( ) 
    long            nPow;               //    
    std::string     strModeType;        //    
    std::string     strLANGUAGE;        //   
    int             nBJIndication;      //     
    int             nBJElevation;       //    
    int             nHRBIndication;     //      
    int             nHRBElevation;      //      
    int             nSHIndication;      //     
    int             nSHElevation;       //     
    int             nCHDIndication;     //     
    int             nCHDElevation;      //     
    int             nWLMQIndication;    //       
    int             nWLMQElevation;     //       
    int             nSZIndication;      //     
    int             nSZElevation;       //     
    int             nWYSIndication;     //      
    int             nWYSElevation;      //      
    int             nXAIndication;      //     
    int             nXAElevation;       //    
    int             nKMIndication;      //     
    int             nKMElevation;       //    
    std::string     strLOCATION;        //        
    bool            bGeneral;           //       
    std::string     sApplycode   ;      //     
    std::string     sDeclCode   ;       //       
    bool            bExistFreq;         //            
    bool            bLocal;             //       
    int             nSendAnteHigh ;       //      

    //        
    double          fLongi       ;  //   
    double          fLati        ;  //  
    int             nOcc;         
    int             nGate;

    short   nAntPloa;        //    
    float   fantegaint;      //    
    double  dEmcField;       //          
    double  dEmcStrength;    //   
};

typedef struct Parameter
{
    vector m_stations;
    std::string     m_strStationID;           //   ID
    INT64 m_iFreq;
    INT64 m_iBandwide;
}Param;

// CTestDlg    
class CTestDlg : public CDialog
{
//   
public:
    CTestDlg(CWnd* pParent = NULL); //       

//      
    enum { IDD = IDD_TEST_DIALOG };

    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV   


//   
protected:
    HICON m_hIcon;

    //          
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnEnChangeEdit1();
    afx_msg void OnBnClickedOk();
    double GetAngle(JWD jwd1,JWD jwd2);
    SITE LoadXML();
    void  GetPathTwoways();
private:
    CEdit           m_fLong1;//  1   
    CEdit           m_fLAT1;//  1   
    CEdit           m_fLong2;//  1   
    CEdit           m_fLAT2;//  1   
    Param                   m_sParam;

public:
    afx_msg void OnBnClickedWiznext();
     void  isPointInPolygon(JWD testP,SITE site);
     bool  PointBeInPolygon(JWD testP,SITE site);
     void  FiltErrorPoint(/*vector points*/);

     afx_msg void OnBnClickedButton1();
     void MFCReadTxt();
     void ReadTxt();
     void WriteTxt(CString ostr);
     CString PackageXML(INT64 lnFreq,INT64 bandwide,vector queryStation);
     bool ParseXML(std::string strparam,std::string freq);


     void SetInInfo();
     void  CTimeToCString();
     __int64  SysTimeToInt(SYSTEMTIME systime );
     SYSTEMTIME Int64ToSystemTime(const __int64& itime);
     __int64 SystemTimeToInt64(const SYSTEMTIME& itime);
     bool  IsLeapYear(unsigned short wYear) ;

     SYSTEMTIME  SytemTimeAdd8Hour(SYSTEMTIME& st);
     void  EqualZero(std::string myreportV)  ;

     void  OnUnsigedLong();
     void PlayMp3();
     std::string  DecimalConversion(std::string decimal,int anglen);
     void UpperCase(char str[]);


};

// TestDlg.cpp :     
//

#include "stdafx.h"
#include "Test.h"
#include "TestDlg.h"
#include 
#include 
#include "windows.h"
#pragma comment(lib,"WinMM.Lib")
#include "mmsystem.h"
#include 
using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


//       “  ”     CAboutDlg    

class CAboutDlg : public CDialog
{
public:
    CAboutDlg();

//      
    enum { IDD = IDD_ABOUTBOX };

    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV   

//   
protected:
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CTestDlg    




CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CTestDlg::IDD, pParent)
{
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_EDIT1, m_fLong1);
    DDX_Control(pDX, IDC_EDIT2, m_fLAT1);
    DDX_Control(pDX, IDC_EDIT4, m_fLong2);
    DDX_Control(pDX, IDC_EDIT5, m_fLAT2);
}

BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    //}}AFX_MSG_MAP
    ON_EN_CHANGE(IDC_EDIT1, &CTestDlg::OnEnChangeEdit1)
    ON_BN_CLICKED(IDOK, &CTestDlg::OnBnClickedOk)
    ON_BN_CLICKED(ID_WIZNEXT, &CTestDlg::OnBnClickedWiznext)
    ON_BN_CLICKED(IDC_BUTTON1, &CTestDlg::OnBnClickedButton1)
END_MESSAGE_MAP()


// CTestDlg       

BOOL CTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    //  “  ...”           。

    // IDM_ABOUTBOX           。
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        BOOL bNameValid;
        CString strAboutMenu;
        bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
        ASSERT(bNameValid);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }

    //          。              ,     
    //      
    SetIcon(m_hIcon, TRUE);         //      
    SetIcon(m_hIcon, FALSE);        //      

    // TODO:             

    return TRUE;  //           ,     TRUE
}

void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

//              ,        
//       。      /      MFC     ,
//          。

void CTestDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); //           

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);

        //             
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        //     
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

//                      
//  。
HCURSOR CTestDlg::OnQueryDragIcon()
{
    return static_cast(m_hIcon);
}


void CTestDlg::OnEnChangeEdit1()
{
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO: Add your control notification handler code here
}

void CTestDlg::OnBnClickedOk()
{

    JWD jwd1,jwd2;
    CString strValue;   
    m_fLong1.GetWindowText(strValue);   
    strValue.Trim();
    if (strValue.GetLength()==0)
    {
        MessageBox( _T("  1      "));       
    }
    jwd1.fLONG=_ttol(strValue);

    m_fLAT1.GetWindowText(strValue);    
    strValue.Trim();
    if (strValue.GetLength()==0)
    {
        MessageBox( _T("  1      "));       
    }
    jwd1.fLAT=_ttol(strValue);

    m_fLong2.GetWindowText(strValue);   
    strValue.Trim();
    if (strValue.GetLength()==0)
    {
        MessageBox( _T("  2      "));       
    }
    jwd2.fLONG=_ttol(strValue);

    m_fLAT2.GetWindowText(strValue);    
    strValue.Trim();
    if (strValue.GetLength()==0)
    {
        MessageBox( _T("  2      "));       
    }
    jwd2.fLAT=atof(strValue);


    double angle=GetAngle(jwd1,jwd2);
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_RESULT);

    CString temp;
    temp.Format("%f",angle);
    if(pEdit)
    {
        pEdit->SetWindowText(temp);
    }
// OnOK();
}

double CTestDlg::GetAngle(JWD jwd1,JWD jwd2)
{ 
    double Rjd1,Rwd1,Rjd2,Rwd2,dAngle;
    Rjd1=jwd1.fLONG*M_PI/180;//    
    Rwd1=jwd1.fLAT*M_PI/180;
    Rjd2=jwd2.fLONG*M_PI/180;
    Rwd2=jwd2.fLAT*M_PI/180;

    dAngle=abs(ANG(atan((sin(Rjd2-Rjd1)*cos(Rwd2))/(sin(Rwd2)*cos(Rwd1)-cos(Rjd2-Rjd1)*cos(Rwd2)*sin(Rwd1)))));
    if(Rwd2>=Rwd1)
    {
        if(Rjd2360-dAngle;
    }
    else
    {
        if(Rjd2>=Rjd1)
            dAngle=180-dAngle;
        else
            dAngle=180+dAngle;
    }
    return dAngle;
}

void CTestDlg::OnBnClickedWiznext()
{
    //JWD testP;
    //CString strValue; 
    //m_fLong2.GetWindowText(strValue); 
    //strValue.Trim();
    //if (strValue.GetLength()==0)
    //{
    // MessageBox( _T("  2      ")); 
    //}
    //testP.fLONG=atof(strValue);

    //m_fLAT2.GetWindowText(strValue); 
    //strValue.Trim();
    //if (strValue.GetLength()==0)
    //{
    // MessageBox( _T("  2      ")); 
    //}
    //testP.fLAT=atof(strValue);




}
//MFC       Txt  
void CTestDlg::MFCReadTxt()
{
    //  MFC        txt  ,      CString    
    CString fileName="city.txt";    
    CFile file(fileName,CFile::modeRead);
    BYTE buffer[0x1000];
    DWORD dwBytesRemaining/*file.GetLength()*/;
    CString strBuffer,strTemp;
    UINT nBytesRead;

    int pos;
    while (dwBytesRemaining)
    {
        if (dwBytesRemaining>4096)
        {
            nBytesRead=file.Read(buffer,sizeof(buffer));        
            strTemp=buffer;
        }else
        {
            BYTE temBuffer[0x1000];
            nBytesRead=file.Read(temBuffer,sizeof(temBuffer));      
            strTemp=temBuffer;
        }       
        pos=strTemp.Find(" ");
        strTemp=strTemp.Left(pos);
        strBuffer+=strTemp;
        dwBytesRemaining=dwBytesRemaining-nBytesRead;
    }

    //  CString   
    SITE site;
    JWD temp;
    vector m_sites;

    while (strBuffer.Find(",")>=0&&strBuffer.Find(";")>=0)
    {
        pos=strBuffer.Find(" ");
        site.cityName=strBuffer.Left(pos);
        strBuffer=strBuffer.Right(strBuffer.GetLength()-pos-1);

        pos=strBuffer.Find("
"
); strTemp=strBuffer.Left(pos); if (pos==-1) { strTemp=strBuffer; } strBuffer=strBuffer.Right(strBuffer.GetLength()-pos-1); site.minfLAT=100000; site.minfLONG=100000; site.maxfLAT=-100000; site.maxfLONG=-100000; while (strTemp.Find(",")>=0&&strTemp.Find(";")>=0) { pos=strTemp.Find(","); temp.fLONG=atof(strTemp.Left(pos)); if (site.minfLONG>temp.fLONG) { site.minfLONG=temp.fLONG; } if (site.maxfLONG1); pos=strTemp.Find(";"); temp.fLAT=atof(strTemp.Left(pos)); if (site.minfLAT>temp.fLAT) { site.minfLAT=temp.fLAT; } if (site.maxfLAT1); site.boundPoint.push_back(temp); } m_sites.push_back(site); site.boundPoint.clear(); } } //C++ Txt void CTestDlg::GetPathTwoways() { TCHAR exeFullPath[MAX_PATH]; // MAX_PATH GetCurrentDirectory(MAX_PATH,exeFullPath); CString lstr = exeFullPath; lstr +="\bool.txt"; std::string strPath = lstr.GetBuffer(); // C++ txt , CString ifstream file; file.open(strPath.c_str(),ios::in); CString path; GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH); path.ReleaseBuffer(); int pos2 = path.ReverseFind('\\'); path = path.Left(pos2); CString fileName="city.txt"; path+="\\data\\"+fileName; ofstream ofs(path); bool mb=true; CString ostr; if (mb) { ostr="1;"; }else{ ostr="0;"; } ofs.write(ostr,ostr.GetLength()); ofs.close(); } //C++ Txt void CTestDlg::ReadTxt() { CString path; // .exe **\**\a.exe GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH); path.ReleaseBuffer(); int pos2 = path.ReverseFind('\\'); path = path.Left(pos2); CString fileName="city.txt"; path+="\\data\\"+fileName; // C++ txt , CString ifstream file; file.open(path,ios::in); if(!file) { cout<<"open fail!"<return ; } int pos; CString strBuffer,strTemp,res; while(!file.eof()) { char buffer[4096]; file.read(buffer,4096); strTemp=buffer; pos=strTemp.Find(" "); strTemp=strTemp.Left(pos); strBuffer+=strTemp; res=strTemp; } file.close(); // CString SITE site; JWD temp; vector m_sites; while (strBuffer.Find(",")>=0&&strBuffer.Find(";")>=0) { pos=strBuffer.Find(" "); site.cityName=strBuffer.Left(pos); strBuffer=strBuffer.Right(strBuffer.GetLength()-pos-1); pos=strBuffer.Find("
"
); strTemp=strBuffer.Left(pos); /* if (pos==-1) { strTemp=strBuffer; }*/ strBuffer=strBuffer.Right(strBuffer.GetLength()-pos-1); site.minfLAT=100000; site.minfLONG=100000; site.maxfLAT=-100000; site.maxfLONG=-100000; while (strTemp.Find(",")>=0&&strTemp.Find(";")>=0) { pos=strTemp.Find(","); temp.fLONG=atof(strTemp.Left(pos)); if (site.minfLONG>temp.fLONG) { site.minfLONG=temp.fLONG; } if (site.maxfLONG1); pos=strTemp.Find(";"); temp.fLAT=atof(strTemp.Left(pos)); if (site.minfLAT>temp.fLAT) { site.minfLAT=temp.fLAT; } if (site.maxfLAT1); site.boundPoint.push_back(temp); } m_sites.push_back(site); site.boundPoint.clear(); } CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_RESULT); std::string m_result=res; if(pEdit) { pEdit->SetWindowText(m_result.c_str()); } } // XML CString CTestDlg::PackageXML(INT64 lnFreq,INT64 bandwide,vector queryStation) { // XML CString strResult=_T("
"
) ; CString strTemp; strTemp.Format("
"
); strResult+=strTemp; strTemp.Format("
"
,lnFreq,bandwide); strResult+=strTemp; if (queryStation.size()>0) { std::vector ::iterator iter; for (iter=queryStation.begin();iter!=queryStation.end();iter++) { strTemp.Format(",iter->sApplycode,iter->sDeclCode); strResult+=strTemp; strTemp.Format("strADM=%s strLOCATION=%s ",iter->strADM,iter->strLOCATION); strResult+=strTemp; strTemp.Format("fLongi=%lf fLati=%lf/>
"
,iter->fLongi,iter->fLati); strResult+=strTemp; } } strTemp.Format("
"
); strResult+=strTemp; return strResult; } // XML bool CTestDlg::ParseXML(std::string strparam,std::string freq) { // XML TiXmlDocument lxmlDoc; lxmlDoc.Parse(strparam.c_str()); if(!lxmlDoc.Error()) { TiXmlElement* pRoot = lxmlDoc.RootElement(); if (pRoot != NULL) { CString ret; TiXmlElement* pFrame = pRoot->FirstChildElement("group"); if (pFrame) { std::string mname; std::string mfreq; TiXmlElement* pItem=pFrame->FirstChildElement("item"); while (pItem) { mname=pItem->Attribute("name"); if (mname.compare("frequency")==0) { mfreq=pItem->Attribute("value"); int pos=mfreq.find("M"); mfreq=mfreq.substr(0,pos); double m_nfreq=atof(mfreq.c_str()); CString mstrFreq; mstrFreq.Format("%.4lf", m_nfreq); mfreq=mstrFreq; double nfreq = atof(freq.c_str()); CString strfreq; strfreq.Format("%.4lf", nfreq); freq=strfreq; if (mfreq.compare(freq)==0) { return true; } std::string myinfo=" "; } pItem=pItem->NextSiblingElement("item"); }//pItem }//pFrame }//pRoot!=NULL }//!lxmlDoc.Error() } // txt void CTestDlg::WriteTxt(CString ostr) { TCHAR exeFullPath[MAX_PATH]; // MAX_PATH GetCurrentDirectory(MAX_PATH,exeFullPath); CString lstr = exeFullPath; lstr +="\\bool.txt"; std::string strPath = lstr.GetBuffer(); ofstream ofs(strPath.c_str()); ofs.write(ostr,ostr.GetLength()); ofs.close(); } // XML SITE CTestDlg::LoadXML() { SITE site; // XML , TCHAR exeFullPath[MAX_PATH]; // MAX_PATH GetCurrentDirectory(MAX_PATH,exeFullPath); CString lstr = exeFullPath; lstr +="\\site.xml"; std::string strPath = lstr.GetBuffer(); TiXmlDocument doc; doc.LoadFile(strPath); TiXmlElement* pRoot = doc.RootElement(); if (pRoot == NULL) { MessageBox(" site.xml !"); return site; } CString ret; TiXmlElement* pFrame = pRoot->FirstChildElement("min"); if (pFrame) { CString tempValue; JWD tempJ; tempValue= pFrame->Attribute("minfLONG"); site.minfLONG=atof(tempValue); tempValue= pFrame->Attribute("minfLAT"); site.minfLAT=atof(tempValue); TiXmlElement* pMap = pFrame->NextSiblingElement("max"); tempValue= pMap->Attribute("maxfLONG"); site.maxfLONG=atof(tempValue); tempValue= pMap->Attribute("maxfLAT"); site.maxfLAT=atof(tempValue); pMap = pMap->NextSiblingElement("jwd"); while (pMap){ tempValue= pMap->Attribute("fLONG"); tempJ.fLONG=atof(tempValue); tempValue= pMap->Attribute("fLAT"); tempJ.fLAT=atof(tempValue); site.boundPoint.push_back(tempJ); pMap = pMap->NextSiblingElement("jwd"); } } return site; } // : void CTestDlg:: isPointInPolygon(JWD testP,SITE site) { int count =site.boundPoint.size(); if(count < 3) { return; } bool result = false; int i=0; std::vector::iterator iter,temp; vector chosedP; JWD tjwd; temp=site.boundPoint.end(); temp--; for (iter=site.boundPoint.begin();iter!=site.boundPoint.end();iter++) { // , if (iter->fLAT==testP.fLAT&&iter->fLONG==testP.fLONG) { result=false; break; } if((iter->fLAT fLAT > testP.fLAT )||(temp->fLAT < testP.fLAT && iter->fLAT > testP.fLAT)) { cout<<""<double
a1=(testP.fLAT -iter->fLAT)/(temp->fLAT -iter->fLAT)*(temp->fLONG-iter->fLONG); if(iter->fLONG+a1fLAT; tjwd.fLONG=iter->fLONG; chosedP.push_back(tjwd); result =true; } } temp = iter; } CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_RESULT); if(pEdit) { if (result) { pEdit->SetWindowText("YES, ……"); }else { pEdit->SetWindowText("NO, ……"); } } } // : bool CTestDlg:: PointBeInPolygon(JWD testP,SITE site) { int count =site.boundPoint.size(); if(count < 3) { return false; } bool result = false; int i=0; std::vector::iterator iter,temp,next; vector chosedP; // JWD tjwd; // , if (testP.fLATsite.maxfLAT||testP.fLONG>site.maxfLONG) { return false; } temp=site.boundPoint.end(); temp--; for (iter=site.boundPoint.begin();iter!=site.boundPoint.end();iter++) { // , if (iter->fLAT==testP.fLAT&&iter->fLONG==testP.fLONG) { return true; } if (testP.fLATfLAT,temp->fLAT)||testP.fLAT>max(iter->fLAT,iter->fLAT)) { temp=iter; continue; } if (testP.fLAT>=min(iter->fLAT,temp->fLAT)&&testP.fLAT<=max(iter->fLAT,iter->fLAT)) { if (testP.fLONG<=max(iter->fLONG,temp->fLONG)) { if (iter->fLAT==temp->fLAT&&testP.fLONG>=min(iter->fLONG,temp->fLONG)) { return true; } if (iter->fLONG==temp->fLONG) { if (testP.fLONG==iter->fLONG) { return true; }else{ ++i; } }else{ double a2=(testP.fLAT-temp->fLAT)*(iter->fLONG-temp->fLONG)/(iter->fLAT-temp->fLAT)+temp->fLONG; // if(abs(testP.fLONG-a2)<0.0000000002) // return true; if (testP.fLONG/*++i;*/ return true; } } } }else{ if (testP.fLAT==iter->fLAT&&testP.fLONG<=iter->fLONG) { next=iter; next++; if (testP.fLAT>=min(temp->fLAT,next->fLAT)&&testP.fLAT<=max(temp->fLAT,next->fLAT)) { ++i; }else{ i+=2; } } } temp=iter; } if (i%2==0) { return false; }else{ return true; } } // ,Vector 。 void CTestDlg::FiltErrorPoint(/*vector pointsit*/) { // vector<double> pointsit,result; double a[3]={177.42,179.19,189.27}; for (int i=0;i<3;i++) { pointsit.push_back(a[i]); } // sort(pointsit.begin(),pointsit.end()); std::vector<double >::iterator tempB,iterB,iterEnd,iter; vector <int>::size_type len; len=pointsit.size(); iterB=pointsit.begin(); tempB=iterB; tempB++; iterEnd=pointsit.end(); iterEnd--; double mean=(*iterEnd-*iterB)/len; bool delBeg; int m_count=0; for (;tempB!=pointsit.end();) { delBeg=false; m_count++; double preV=*tempB-*iterB; if(preV>mean) { if (m_count*2>len) { tempB=pointsit.erase(tempB); if (tempB!=pointsit.end()) { iterB=tempB-1; } }else{ iterB = pointsit.erase(iterB); tempB = iterB +1; } delBeg=true; } if (delBeg==false) { iterB++; tempB++; } } CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_RESULT); CString strv; std::string str; if(pEdit) { for (iter=pointsit.begin();iter!=pointsit.end();iter++) { UpdateData(); strv.Format("%d",*iter); str=strv; pEdit->SetWindowText(str.c_str()); } } } void CTestDlg::SetInInfo() { const std::string lstrIn="monitorId:37160001,freq:152225000,bandwide:25000;"; CString strTemp,strParam; strParam=lstrIn.c_str(); int pos; pos=strParam.Find("monitorId"); pos=strParam.Find(":"); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); m_sParam.m_strStationID=strParam.Left(pos); pos=strParam.Find(":"); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); m_sParam.m_iFreq=static_cast<__int64>(atof(strParam.Left(pos))+0.5); pos=strParam.Find(":"); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(";"); m_sParam.m_iBandwide=static_cast<__int64>(atof(strParam.Left(pos))+0.5); CSwStation stations; while (strParam.Find("station:")>0) { pos=strParam.Find(":"); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); stations.sApplycode=strParam.Left(pos); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); stations.sDeclCode=strParam.Left(pos); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); stations.strADM=strParam.Left(pos); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); stations.strLOCATION=strParam.Left(pos); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(","); stations.fLongi=atof(strParam.Left(pos)); strParam=strParam.Right(strParam.GetLength()-pos-1); pos=strParam.Find(";"); stations.fLati=atof(strParam.Left(pos)); strParam=strParam.Right(strParam.GetLength()-pos-1); m_sParam.m_stations.push_back(stations); } } void CTestDlg::CTimeToCString() { CTime m_cTime = CTime::GetCurrentTime(); CString cstrDateTime =m_cTime.Format("'%Y-%m-%d %H:%M:%S'"); // "2006-11-27 23:30:59" . ? // CTime CString cstrDate = m_cTime.Format("%Y-%m-%d"); // CTime CString cstrTime = m_cTime.Format("%H:%M:%S"); } __int64 CTestDlg::SysTimeToInt(SYSTEMTIME systime ) { FILETIME ftStart; __int64 nStartTime(0); SystemTimeToFileTime(&systime, &ftStart); nStartTime = ftStart.dwHighDateTime; nStartTime = nStartTime<<32; nStartTime += ftStart.dwLowDateTime; return nStartTime; } // bool CTestDlg::IsLeapYear(unsigned short wYear) { if ((wYear%4==0&&wYear%100!=0)||wYear%400==0) { return true; }else{ return false; } } SYSTEMTIME CTestDlg::SytemTimeAdd8Hour(SYSTEMTIME& st) { if (st.wHour+8<24) { st.wHour=st.wHour+8; } else { st.wHour=st.wHour+8-24; switch(st.wMonth) { case 2: // if (IsLeapYear(st.wYear)) { if (st.wDay+1<30) { st.wDay=st.wDay+1; } else { st.wDay=1; st.wMonth=st.wMonth+1; } } else { if (st.wDay+1<29) { st.wDay=st.wDay+1; } else { st.wDay=1; st.wMonth=st.wMonth+1; } } break; case 1: case 3: case 5: case 7: case 8: case 10: if (st.wDay+1<32) { st.wDay=st.wDay+1; } else { st.wDay=1; st.wMonth=st.wMonth+1; } break; case 12: if (st.wDay+1<32) { st.wDay=st.wDay+1; } else { st.wDay=1; st.wMonth=1; st.wYear=st.wYear+1; } break; case 4: case 6: case 9: case 11: if (st.wDay+1<31) { st.wDay=st.wDay+1; } else { st.wDay=1; st.wMonth=st.wMonth+1; } break; } } return st; } __int64 CTestDlg::SystemTimeToInt64(const SYSTEMTIME& itime) { FILETIME ft; SystemTimeToFileTime(&itime, &ft); ULARGE_INTEGER ularge; ularge.LowPart = ft.dwLowDateTime; ularge.HighPart = ft.dwHighDateTime; __int64 int64 = ularge.QuadPart; return int64; } SYSTEMTIME CTestDlg::Int64ToSystemTime(const __int64& itime) { FILETIME ft; SYSTEMTIME st; ULARGE_INTEGER ularge; __int64 tmptimeA, tmptimeB; tmptimeA = itime; tmptimeB = itime; ularge.HighPart = (DWORD)(tmptimeA>>32); ularge.LowPart = (DWORD)((tmptimeB<<32)>>32); ft.dwLowDateTime = ularge.LowPart; ft.dwHighDateTime = ularge.HighPart; FileTimeToSystemTime(&ft, &st); return st; } void CTestDlg::EqualZero(std::string myreportV) { if (myreportV.empty()) { myreportV ="0"; } } void CTestDlg::OnUnsigedLong() { DWORD a,b,d; a=9; b=10; double c=(double)a/(double)b; d=0.8; if (c>0.8) { d=0.6; } else { d=0.9; } } // , std::string CTestDlg::DecimalConversion(std::string decimal,int anglen) { std::string du,fen,miao; int len; double dnum; int pos; CString conStr; conStr=decimal.c_str(); pos=conStr.Find("."); du=conStr.Left(pos); len=(int)strlen(du.c_str()); while (len"0"+du; len++; } conStr=conStr.Right(conStr.GetLength()-pos-1); conStr="0."+conStr; dnum=atof(conStr); dnum=dnum*60; conStr.Format("%.4lf",dnum); pos=conStr.Find("."); fen=conStr.Left(pos); len=(int)strlen(fen.c_str()); while (len<2) { fen="0"+fen; len++; } conStr=conStr.Right(conStr.GetLength()-pos-1); conStr="0."+conStr; dnum=atof(conStr); dnum=dnum*60; conStr.Format("%.4lf",dnum); pos=conStr.Find("."); miao=conStr.Left(pos); len=(int)strlen(miao.c_str()); while (len<2) { miao="0"+miao; len++; } conStr=conStr.Right(conStr.GetLength()-pos-1); CString tem=conStr.Left(2); miao+=tem; std::string res=du+fen+miao; return res; } void CTestDlg::UpperCase(char str[]) { //tes=4, , , int tes=sizeof(str); //tes1=5,strlen str int tes1=strlen(str); int a[5]; printf("%d
"
, a); printf("%d
"
, &a); printf("%d
"
, a + 1); printf("%d
"
, &a + 1); printf("%d
"
, &a[0] + 1); printf("---------------
"
); printf("%d
"
,sizeof(a)); printf("%d
"
,sizeof(&a)); } void CTestDlg::PlayMp3() { MCI_OPEN_PARMS m_mciOpen; // MCI_PLAY_PARMS m_mciPlay; // // m_mciOpen.lpstrDeviceType ="mpegvideo" ; // m_mciOpen.lpstrElementName ="F:\\ \\20170405 \\Alarm.mp3" ; MCIERROR mcierror=mciSendCommand( 0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT ,(DWORD)&m_mciOpen); // if(mcierror){ char buf[128]={0}; mciGetErrorString(mcierror, buf,128); ::MessageBox(NULL, buf, " ", MB_OK|MB_ICONERROR); }else{ m_mciPlay.dwCallback=NULL/*(DWORD)hwnd*/; m_mciPlay.dwFrom = (DWORD)(12 * 1); // ms mciSendCommand(m_mciOpen.wDeviceID, MCI_PLAY, MCI_NOTIFY|MCI_FROM, (DWORD)(LPVOID)&m_mciPlay); } } void CTestDlg::OnBnClickedButton1() { char str[]="abced"; UpperCase(str); //PlaySound("F:\\ \\20170405 \\Alarm.wav", NULL, SND_FILENAME | SND_ASYNC); }