BOOL CSensorNetworkDataSettingDlg::ReadNetworkDataCSVFile(const char* ElementType, std::vector<std::string>& name_vector,std::vector<std::vector<std::string>>& value_vector)
{
	std::string fileName = m_pDoc->m_ProjectDirectory + ElementType + ".csv";
	std::vector<std::string> value;

	CCSVParser csvParser;
	csvParser.OpenCSVFile(fileName);

	name_vector = csvParser.GetHeaderList();

	while(csvParser.ReadRecord())
	{
		value_vector.push_back(csvParser.GetLineRecord());
	}

	csvParser.CloseCSVFile();

	return TRUE;
}
bool CTLiteDoc::ReadGPSCSVFile(LPCTSTR lpszFileName)
{
    // save the original code
    //CCSVParser parser;

    //if (parser.OpenCSVFile(lpszFileName))
    //{
    //    m_VehicleSet.clear();

    //    string trajecory_id = "-1";
    //    string prev_trajecory_id = "0";

    //    float x1, y1, x2, y2;
    //    float SegmentTravelTime;

    //    DTAVehicle* pVehicle = 0;


    //    while(parser.ReadRecord())
    //    {
    //        if(parser.GetValueByFieldName("trajecory_id",trajecory_id) == false)
    //        {
    //            break;
    //        }

    //        GDPoint pt1;
    //        GDPoint pt2;

    //        parser.GetValueByFieldName("x1",pt1.x);
    //        parser.GetValueByFieldName("y1",pt1.y);
    //        parser.GetValueByFieldName("x2",pt2.x);
    //        parser.GetValueByFieldName("y2",pt2.y);

    //        if(prev_trajecory_id.compare(trajecory_id)!=0)
    //        {
    //        // we have a new vehicle
    //        pVehicle = new DTAVehicle;
    //        pVehicle->m_VehicleID = m_VehicleSet.size();  // we skip vehicle id
    //        pVehicle-> m_VehicleKey = trajecory_id;
    //    
    //        m_VehicleSet.push_back (pVehicle);
    //        m_VehicleIDMap[pVehicle->m_VehicleID]  = pVehicle;
    //    
    //        }

    //        pVehicle->m_GPSLocationVector.push_back(pt1); 
    //        pVehicle->m_GPSLocationVector.push_back(pt2); 
    //        prev_trajecory_id = trajecory_id;
    //    }
    //}
 //  return true;
// save the original code


    CCSVParser parser;

    if (parser.OpenCSVFile(lpszFileName))
    {    
        m_VehicleSet.clear();
        float TrajecoryTravelTime;
        DTAVehicle* pVehicle = 0;
        std::vector<string> SeperatedStrings;
        while(parser.ReadRecord())
        {
           SeperatedStrings=parser.GetLineRecord();
           TrajecoryTravelTime=::atof(SeperatedStrings[4].c_str());
           pVehicle = new DTAVehicle;
           m_VehicleSet.push_back(pVehicle);
           m_VehicleIDMap[pVehicle->m_VehicleID]  = pVehicle;
           for(int i=6;i<(SeperatedStrings.size()-6);i=i+6)// read the data every 6 numbers
           {
               if((SeperatedStrings[i]!="")&&(SeperatedStrings[i+1]!="")&&(SeperatedStrings[i+2]!="")&&(SeperatedStrings[i+3]!=""))
               {
                   GDPoint pt1;
                   GDPoint pt2;

                   pt1.x=::atof(SeperatedStrings[i].c_str());
                   pt1.y=::atof(SeperatedStrings[i+1].c_str());
                   pt2.x=::atof(SeperatedStrings[i+2].c_str());
                   pt2.y=::atof(SeperatedStrings[i+3].c_str());

                   pVehicle->m_GPSLocationVector.push_back(pt1); 
                   pVehicle->m_GPSLocationVector.push_back(pt2); 
               }
            }
        }

    parser.CloseCSVFile();
    return true;
    }

	return true;
}