Exemple #1
0
BOOL CRegKey2::ImportFromIni(LPCTSTR szIniPath)
{
	ASSERT (m_hKey);
	ASSERT (m_bReadOnly);
	
	if (!m_hKey || !m_bReadOnly)
		return FALSE;
	
	CStdioFileEx file;
	
	if (!file.Open(szIniPath, CFile::modeRead))
		return FALSE;

	CString sSection, sNextSection;
	BOOL bRes = TRUE;

	do 
	{
		// detect invalid ini files
		bRes &= ImportSectionFromIni(sSection, file, sNextSection);
		sSection = sNextSection;
	} 
	while(bRes && !sSection.IsEmpty());
	
	return bRes;
}
Exemple #2
0
BOOL CRegKey2::ExportToIni(LPCTSTR szIniPath) const
{
	ASSERT (m_hKey);
	
	if (!m_hKey)
		return FALSE;
	
	CStdioFileEx file;
	
	if (!file.Open(szIniPath, CFile::modeCreate | CFile::modeWrite))
		return FALSE;
	
	// process top level keys. ie we ignore any values in the root
	CStringArray aSubKeys;
	
	if (GetSubkeyNames(aSubKeys))
	{
		for (int nKey = 0; nKey < aSubKeys.GetSize(); nKey++)
		{
			CString sName = aSubKeys[nKey];
			
			if (!ExportKeyToIni(sName, file))
				return FALSE;
		}
	}
	
	return TRUE;
}
ERMsg CUSHourly::LoadStationList()
{
	ERMsg msg;

	CString workingDir = GetWorkingDir(); 


	CStdioFileEx file;
	msg = file.Open(workingDir + "STNS.TXT", CFile::modeRead);

	if(msg)
	{
		CString line;
		file.ReadString(line);

		while( file.ReadString(line) )
		{
			line.Trim();
			if( !line.IsEmpty() )
			{
				CString state = line.Mid(29,2);
				if( m_selection.IsUsed(state) )
				{
					CStation station;
					
					station.SetID(line.Mid(0,5) );
					station.SetName(line.Mid(6,22));
					int latNeg = line.Mid(37,1).CompareNoCase("N")==0?1:-1;
					station.SetLat(latNeg*(ToInt(line.Mid(38,2))+ToInt(line.Mid(41,2))/60.0) );

					int lonNeg = line.Mid(44,1).CompareNoCase("E")==0?1:-1;
					station.SetLon(lonNeg*(ToInt(line.Mid(45,3))+ToInt(line.Mid(49,2))/60.0) );
					station.SetElev(ToInt(line.Mid(52,5)) );

					ASSERT( station.IsValid() );
					m_stationList.Add(station);
				}
			}
		}
	}

	return msg;
}
BOOL CSyntaxWordList::LoadOASMSyntaxWord(const CString& strSyntaxWordFileName)
{
    BOOL bResult = FALSE;
    int nCurIndex = -1;
    CStdioFileEx stdFile;
    if(stdFile.Open(strSyntaxWordFileName, CFile::modeRead|CFile::typeText))
    {
        CString strLine;
        while(stdFile.ReadStringEx(strLine,TRUE,_T(';')))
        {
            if(strLine.Left(2) == _T("%%"))
            {
                strLine.TrimLeft(_T('%')); //去掉左边的百分号
                strLine.Trim(); //去掉两边空格

                if(!strLine.IsEmpty())
                {
                    switch(strLine[0])
                    {
                    case _T('0'):
                        bResult = TRUE;
                        nCurIndex = 0;
                        break;
                    case _T('1'):
                        bResult = TRUE;
                        nCurIndex = 1;
                        break;
                    case _T('2'):
                        bResult = TRUE;
                        nCurIndex = 2;
                        break;
                    case _T('3'):
                        bResult = TRUE;
                        nCurIndex = 3;
                        break;
                    case _T('4'):
                        bResult = TRUE;
                        nCurIndex = 4;
                        break;
                    case _T('5'):
                        bResult = TRUE;
                        nCurIndex = 5;
                        break;
                    case _T('6'):
                        bResult = TRUE;
                        nCurIndex = 6;
                        break;
                    case _T('7'):
                        bResult = TRUE;
                        nCurIndex = 7;
                        break;
                    default:
                        nCurIndex = -1;
                        break;
                    }
                }

                continue;
            }

            switch(nCurIndex)
            {
            case 0:
                m_strOasmWordListSymbol += strLine + _T(" ");
                break;
            case 1:
                m_strOasmWordListCPUInsns += strLine + _T(" ");
                break;
            case 2:
                m_strOasmWordListFPUInsns += strLine + _T(" ");
                break;
            case 3:
                m_strOasmWordListRegister += strLine + _T(" ");
                break;
            case 4:
                m_strOasmWordListDefineWord += strLine + _T(" ");
                break;
            case 5:
                m_strOasmWordListMacro += strLine + _T(" ");
                break;
            case 6:
                m_strOasmWordListOperatorTxt += strLine + _T(" ");
                break;
            case 7:
                m_strOasmWordListOperator += strLine + _T(" ");
                break;
            }
        }
    }

    return bResult;
}
BOOL CSyntaxWordList::LoadOMLSyntaxWord(const CString& strSyntaxWordFileName)
{
    BOOL bResult = FALSE;
    int nCurIndex = -1;
    CStdioFileEx stdFile;
    if(stdFile.Open(strSyntaxWordFileName, CFile::modeRead|CFile::typeText))
    {
        CString strLine;
        while(stdFile.ReadStringEx(strLine,TRUE,_T(';')))
        {
            if(strLine.Left(2) == _T("%%"))
            {
                strLine.TrimLeft(_T('%')); //去掉左边的百分号
                strLine.Trim(); //去掉两边空格

                if(!strLine.IsEmpty())
                {
                    switch(strLine[0])
                    {
                    case _T('0'):
                        bResult = TRUE;
                        nCurIndex = 0;
                        break;
                    case _T('1'):
                        bResult = TRUE;
                        nCurIndex = 1;
                        break;
                    case _T('2'):
                        bResult = TRUE;
                        nCurIndex = 2;
                        break;
                    case _T('3'):
                        bResult = TRUE;
                        nCurIndex = 3;
                        break;
                    default:
                        nCurIndex = -1;
                        break;
                    }
                }

                continue;
            }

            switch(nCurIndex)
            {
            case 0:
                m_strOMLWordListCommentSymbol += strLine + _T(" ");
                break;
            case 1:
                m_strOMLWordListKeyword += strLine + _T(" ");
                break;
            case 2:
                m_strOMLWordListOperator += strLine + _T(" ");
                break;
            case 3:
                m_strOMLWordListMacroTxt += strLine + _T(" ");
                break;
            }
        }
    }

    return bResult;
}
bool CPlainTextImporter::Import(LPCTSTR szSrcFilePath, ITaskList* pDestTaskFile, BOOL bSilent, IPreferences* pPrefs, LPCTSTR szKey)
{
    if (!InitConsts(bSilent, pPrefs, szKey))
        return false;

    CStdioFileEx file;

    if (!file.Open(szSrcFilePath, CFile::modeRead))
        return false;

    // else
    ITaskList4* pITL4 = GetITLInterface<ITaskList4>(pDestTaskFile, IID_TASKLIST4);

    // the first line can be the project name
    if (WANTPROJECT)
    {
        CString sProjectName;
        file.ReadString(sProjectName);
        sProjectName.TrimRight();
        sProjectName.TrimLeft();

        pITL4->SetProjectName(sProjectName);
    }

    // what follows are the tasks, indented to express subtasks
    int nLastDepth = 0;
    HTASKITEM hLastTask = NULL;

    ROOTDEPTH = -1; // gets set to the first task's depth

    CString sLine;

    while (file.ReadString(sLine))
    {
        CString sTitle, sComments;

        if (!GetTitleComments(sLine, sTitle, sComments))
            continue;

        // find the appropriate parent fro this task
        HTASKITEM hParent = NULL;
        int nDepth = GetDepth(sLine);

        if (nDepth == nLastDepth) // sibling
            hParent = hLastTask ? pITL4->GetTaskParent(hLastTask) : NULL;

        else if (nDepth > nLastDepth) // child
            hParent = hLastTask;

        else if (hLastTask) // we need to work up the tree
        {
            hParent = pITL4->GetTaskParent(hLastTask);

            while (hParent && nDepth < nLastDepth)
            {
                hParent = pITL4->GetTaskParent(hParent);
                nLastDepth--;
            }
        }

        HTASKITEM hTask = pITL4->NewTask(sTitle, hParent);

        if (!sComments.IsEmpty())
            pITL4->SetTaskComments(hTask, sComments);

        // update state
        hLastTask = hTask;
        nLastDepth = nDepth;
    }

    return true;
}
ERMsg CUSHourly::GetStation(const CString& stationName, CDailyStation& station)
{
	ERMsg msg;

	CString workingDir = GetWorkingDir(); 

	GetStationHeader( stationName, station );
	
	//CStdioFileEx fileOut( "d:\\travail\\hourly\\PeakHourUSA.csv", CFile::modeWrite|CFile::modeCreate|CFile::modeNoTruncate);
	
	
	//if( fileOut.GetLength() == 0)
	//	fileOut.WriteString( "#,Lat,Lon,Elev,Year,Month,Day,Hmin,Tmin,Hmax,Tmax\n");
	
//	fileOut.SeekToEnd();
	
	CYearPackage pakage;

	int nbYear = m_lastYear-m_firstYear+1;
	for(int y=0; y<nbYear; y++)
	{
		int year=m_firstYear+y;

		CString filePath;
		filePath.Format( "%sData\\%s\\%s_%d", workingDir, stationName, stationName, year-1900);
		
		CStdioFileEx file;
		msg = file.Open( filePath, CFile::modeRead );
		if( !msg )
			return msg;

		CDailyData dailyData;
		
		CString line;
		
		C24HoursData hours24;
		double minValue = 999;
		double maxValue = -999;
		int minHour = -1;
		int maxHour = -1;



		bool bContinue = true; 
		while( bContinue )
		{ 
			bContinue = file.ReadString(line);

			int year = ToInt(line.Mid(6,4));
			int m = ToInt(line.Mid(10,2))-1;
			int d = ToInt(line.Mid(12,2))-1;
			int h = ToInt(line.Mid(14,2))-1;

			if( hours24.GetYear() == -999)
				hours24.SetDate(year,m,d);

			if( d != hours24.GetDay() || !bContinue)
			{
				int jd = hours24.GetJDay();

				if( hours24.IsValid( CHourlyData::T_DEW ) )
				{
					dailyData[jd][TDEW] = (float)hours24.GetStat(CHourlyData::T_DEW)[CFL::MEAN];
				}

				if( hours24.IsValid( CHourlyData::RH ) )
				{
					dailyData[jd][RELH] = (float)hours24.GetStat(CHourlyData::RH)[CFL::MEAN];
					dailyData[jd][ADD1] = (float)hours24.GetStat(CHourlyData::RH)[CFL::LOWEST];
					dailyData[jd][ADD2] = (float)hours24.GetStat(CHourlyData::RH)[CFL::HIGHEST];
				}
				if( hours24.IsValid( CHourlyData::WIND_SPEED ) )
					dailyData[jd][WNDS] = (float)hours24.GetStat(CHourlyData::WIND_SPEED)[CFL::MEAN];

				if( hours24.IsValid( CHourlyData::T ) )
				{
					dailyData[jd][TMIN] = (float)hours24.GetTmin();
					dailyData[jd][TMAX] = (float)hours24.GetTmax();

					/*CString str;
					for(int i=1; i<CStation::NB_MEMBER; i++)
						str += station.GetString(i)+",";

					fileOut.WriteString(str);
					str.Format("%4d,%2d,%2d,%d,%.1lf,%d,%.1lf\n", hours24.GetYear(), hours24.GetMonth()+1, hours24.GetDay()+1, minHour, minValue, maxHour, maxValue);
					fileOut.WriteString(str);
					*/
				}
				
				if( hours24.IsValid( CHourlyData::HUMIDEX ) )
				{
					dailyData[jd][PRCP] = (float)hours24.GetStat(CHourlyData::HUMIDEX)[CFL::SUM];
				}

				/*if( hours24[23][CHourlyData::VISIBILITY] > -999 )
				{
					dailyData[jd][SNOW] = 0;//need a value
					dailyData[jd][SNDH] = (float)hours24[23][CHourlyData::VISIBILITY];
				}*/

				hours24.Reset();
				hours24.SetDate(year,m,d);
				minValue = 999;
				maxValue = -999;
				minHour = -1;
				maxHour = -1;

				
			}

			if( d == hours24.GetDay() && bContinue)
			{

				if( line.Mid(55,5) != "999.9" )
				{
					hours24.Set(h, CHourlyData::T, line.Mid(55,5) );

					double T = ToDouble(line.Mid(55,5));

					if( h<= 12 && T<minValue)
					{
						minValue= T;
						minHour=h;
					}
					if( h>= 12 && T>maxValue)
					{
						maxValue = T;
						maxHour = h;
					}
				}
				if( line.Mid(61,5) != "999.9" )
					hours24.Set(h, CHourlyData::T_DEW, line.Mid(61,5));
				if( line.Mid(67,3) != "999" )
					hours24.Set(h, CHourlyData::RH, line.Mid(67,3));
				if( line.Mid(80,4) != "99.9" )
				{
					double ws = ToDouble(line.Mid(80,4));
					hours24.Set(h, CHourlyData::WIND_SPEED, ToString(ws*3600/1000));//in km/h
				}
				
				if( line.Mid(128,1) == " " )
				{
					double ppt = ToDouble(line.Mid(125,3));
					hours24.Set(h, CHourlyData::HUMIDEX, ToString(ppt*0.2540));//100e of inch --> mm of water
				}

				if( line.Mid(128,1) == "A" )
				{
					int i;
					i=0;
				}

				if( line.Mid(129,3) != "999" )
				{
					double snowDepth = ToDouble(line.Mid(129,3));
					hours24.Set(h, CHourlyData::VISIBILITY, ToString(snowDepth*2.54));//in cm
				}
			}

		}
		
		
		if( dailyData.HaveData() )
		{
			CDailyYear yearData;
			yearData.SetYear(m_firstYear+y);
			yearData.SetData(dailyData);
			pakage.SetYear(yearData);
		}


	}//for all year


	if( msg )
	{
		
		pakage.SetFileTitle(station.GetName()+ "_" + station.GetID() );
		station.AddPakage(pakage);
	}

	return msg;
}
ERMsg C20thReanalysisProject::ExtractTopo(const CString& filePath, CSCCallBack& callback)
{
	ERMsg msg;

	

	CString outputFilePath(filePath);
	UtilWin::SetFileExtension( outputFilePath, ".csv");
	
	CString outputFilePathGrid(filePath);
	UtilWin::SetFileExtension( outputFilePathGrid, ".tif");
	
	CString filePathIn;
	if(m_type==_2X2)
		filePathIn.Format("%shgt.2x2.nc", m_path);
	else filePathIn.Format("%shgt.gauss.nc", m_path);

	int sizeX=0;
	int sizeY=0;
	int nbBand=0;
	CGeoRectWP rect;
	float noData=0;
	double cellSizeX=0;
	double cellSizeY=0;

	msg = GetGridInfo(filePathIn, sizeX, sizeY, nbBand, rect, noData, cellSizeX, cellSizeY);
	CMFCGDALDataset dataset;

	rect.m_xMax+=cellSizeX;
	dataset.Create(outputFilePathGrid, sizeX+1, sizeY, rect, "GTiff", GDT_Int16, 1, -9999);
	

	NcFile file(filePathIn);	
	
	int nbDim = file.num_dims();
	int nbAtt = file.num_atts();
	int nbVar = file.num_vars();

	//NcDim* dim0 = file.get_dim(0);
	//NcDim* dim1 = file.get_dim(1);
	//NcDim* dim2 = file.get_dim(2);

	if( !file.is_valid() )
	{
		CString err;
		err.FormatMessage(IDS_CMN_UNABLE_OPEN_READ, filePath);
		msg.ajoute(err);
	}

	callback.SetCurrentDescription("Create Topo");
	callback.SetCurrentStepRange(0, 17*28, 1);
	callback.SetStartNewStep();

	CStdioFileEx fileOut;


	msg += fileOut.Open( outputFilePath, CFile::modeCreate|CFile::modeWrite);
	if(!msg)
		return msg;

	fileOut.WriteString("Name,ID,Latitude,Longitude,Elevation\n");
	
//	NcVar* pVarX = file.get_var("xc");
	//NcVar* pVarY = file.get_var("yc");
//	NcDim* pDim = file.get_dim("lat");
	//int size = pDim->size();
	NcDim* pDimX = file.get_dim("lon");
	NcDim* pDimY = file.get_dim("lat");
	NcDim* pDimTime = file.get_dim("time");
	

		
	NcVar* pVarLat = file.get_var("lat");
	NcVar* pVarLon = file.get_var("lon");
	NcVar* pVarElev = file.get_var("hgt");
	float offset = pVarElev->get_att("add_offset")->as_float(0);
	float scaleFactor = pVarElev->get_att("scale_factor")->as_float(0);
	//int sizeX2 = pDimX->size();
	//int sizeY2 = pDimY->size();
	
	//typedef boost::multi_array<short, 3> CData3Array;
	//typedef boost::multi_array<float, 2> CDataFloatArray;
	vector<float> X(sizeX);
	vector<float> Y(sizeY);
//	CDataFloatArray X(boost::extents[180]);
//	CDataFloatArray Y(boost::extents[172]);
	//CData2Array lat(boost::extents[28][17]);
	//CData2Array lon(boost::extents[28][17]);
	boost::multi_array<short, 2> elev(boost::extents[sizeY][sizeX]);
	
	
//	pVarX->get(&(X[0]), 180);
//	pVarY->get(&(Y[0]), 172);
	pVarLon->get(&(X[0]), sizeX);
	pVarLat->get(&(Y[0]), sizeY);
	pVarElev->get(&(elev[0][0]), 1, sizeY, sizeX);

//	CProjection prj = GetDataGrid().GetPrj();

	CGridLine profile(sizeX+1);
	for(int i=0; i<sizeY; i++)
	{
		for(int jj=0; jj<sizeX; jj++)
		{
			int j=((sizeX+1)/2+jj)%sizeX;
			//int j=jj;
			//elev[y][x] = short(elev[y][x]*scaleFactor+offset);

			//double Lat=0, Lon=0; 
			//VERIFY( prj.InvertTransform(X[x],Y[y], &Lat, &Lon) );
			//
			//double x2=0, y2=0; 
			//VERIFY( prj.Transform(lat[y*180+x],lon[y*180+x], &x2, &y2) );
			//
			CString line;
			
			float lon = X[j];
			if( lon >= 180)
				lon-=360;

			
			double elev2 = -9999;
			if( elev[i][j]!= 32766 && elev[i][j]!=-32767 )
			{
				elev2=elev[i][j]+offset;
				//elev2 = fZhtoZgSMT(elev2/1000, Y[i])*1000;
			}
			
			//<(sizeX/2)?j+sizeX/2:j-sizeX/2
			//profile[j] = elev[i][(j+sizeX/2)%sizeX];
			profile[jj] = float(elev2);
			if( jj==0)
				profile[sizeX] = float(elev2);

			line.Format("%03d-%03d,%03d-%03d,%f,%f,%d\n",i,jj,i,jj,Y[i],lon,int(elev2));

			fileOut.WriteString(line);

			
			//CGeoPoint point(X[x], Y[y], prj.GetPrjType() );
//			int bContinental = (int)maskMap.ReadCell(x, y)==-1;

	//		if( bContinental )
//			if( shapefile.IsInside(point) )
		//	{
			//}
			//else
			//{
				//msg += grid.WriteCell(grid.GetNoData());
			//}
			msg += callback.StepIt();
		}

		dataset.WriteLine(profile);
	}

	file.close();
	fileOut.Close();
	dataset.Close();
	
	return msg;
}
Exemple #9
0
void CNetwork::LoadScript()
{
	const CString name( _T( "RecoveryClient.cfg" ) );

	CStdioFileEx file;

	if( ! file.Open( name, CFile::modeRead  ) )
	{
		CString textFileIsNotFound;
		textFileIsNotFound.LoadString( IDS_STRING308 );

		CString text;
		text.Format( textFileIsNotFound, name );

		MessageBox( 0, text, _T( "" ), MB_ICONERROR | MB_OK );

		AfxGetMainWnd()->PostMessage( WM_CLOSE, 0, 0 );
		return;
	}

	enum
	{
		eModeServer,
		eModeNone,
	}
	mode = eModeNone;

	CString line;

	DWORD serverIndex = 0;

	while( file.ReadString( line ) )
	{
		int i = 0;

		const CString	seperator( _T( "\"\n= " ) );
		CString			token = line.Tokenize( seperator, i );

		if( token.IsEmpty() )
		{
			continue;
		}
		else if( _T( "[server]" ) == token  )
		{
			mode = eModeServer;
			continue;
		}
		else if( _T( "//" ) == token.Left( 2 ) )
		{
			continue;
		}

		switch( mode )
		{
		case eModeServer:
			{
				Server& data = mServerMap[ ++serverIndex ];
				SetConnectData(
					token,
					data);
				data.mName	= line.Tokenize( seperator, i );

				do 
				{
					token = line.Tokenize( seperator, i );

					data.mName += ' ' + token;
				}
				while( ! token.IsEmpty() );

				break;
			}
		}
	}
}
ERMsg CMADIS::ExtractLOC(const CString& filePath, CSCCallBack& callback)
{
	ERMsg msg;

	callback.SetCurrentDescription("Extract location");
	callback.SetCurrentStepRange(0, 3, 1);
	callback.SetStartNewStep();

	CString outputFilePath(filePath);
	UtilWin::SetFileExtension( outputFilePath, ".loc");
	
//	CString outputFilePathGrid(filePath);
//	UtilWin::SetFileExtension( outputFilePathGrid, ".bil");

//	CShapeFileBase shapefile;
//	shapefile.Read("C:\\ouranos_data\\MapInput\\canada.shp");

	

	NcFile file(filePath);	

	if( !file.is_valid() )
	{
		CString err;
		err.FormatMessage(IDS_CMN_UNABLE_OPEN_READ, filePath);
		msg.ajoute(err);
	}

	//CMapBinaryFile grid;
 //   grid.SetProjection( GetDataGrid().GetPrj() );
 //   grid.SetNbCols(180);
 //   grid.SetNbRows(172);
 //   grid.SetBoundingBox(GetDataGrid());
 //   grid.SetNoData(-9999);
 //   grid.SetCellSizeX( 45000 );
 //   grid.SetCellSizeY( 45000 );
	CStdioFileEx fileOut;


	//msg += grid.Open(outputFilePathGrid, CGeoFileInterface::modeWrite);
	msg += fileOut.Open( outputFilePath, CFile::modeCreate|CFile::modeWrite);
	if(!msg)
		return msg;

	fileOut.WriteString("LOC_FILE 4 2,ID,Latitude,Longitude,Elevation,Slope(%),Orientation(°)\n");
	

	//char providerId(recNum, maxProviderIdLen) ;
	//	providerId:long_name = "Data Provider station Id" ;
	//	providerId:reference = "station table" ;
	//char stationId(recNum, maxStaIdLen) ;
	//	stationId:long_name = "alphanumeric station Id" ;
	//	stationId:reference = "station table" ;
	//char handbook5Id(recNum, maxStaIdLen) ;
	//	handbook5Id:long_name = "Handbook5 Id (AFOS or SHEF id)" ;
	//	handbook5Id:reference = "station table" ;
	//char stationName(recNum, maxNameLength) ;
	//	stationName:long_name = "alphanumeric station name" ;
	//	stationName:reference = "station table" ;

	//float latitude(recNum) ;
	//	latitude:long_name = "latitude" ;
	//	latitude:units = "degree_north" ;
	//	latitude:_FillValue = 3.4028235e+038f ;
	//	latitude:missing_value = -9999.f ;
	//	latitude:reference = "station table" ;
	//	latitude:standard_name = "latitude" ;
	//float longitude(recNum) ;
	//	longitude:long_name = "longitude" ;
	//	longitude:units = "degree_east" ;
	//	longitude:_FillValue = 3.4028235e+038f ;
	//	longitude:missing_value = -9999.f ;
	//	longitude:reference = "station table" ;
	//	longitude:standard_name = "longitude" ;
	//float elevation(recNum) ;
	//	elevation:long_name = "elevation" ;
	//	elevation:units = "meter" ;
	//	elevation:_FillValue = 3.4028235e+038f ;
	//	elevation:missing_value = -9999.f ;
	//	elevation:reference = "station table" ;
	//	elevation:standard_name = "elevation" ;

	//NcVar* pVarX = file.get_var("xc");
	//NcVar* pVarY = file.get_var("yc");
	
	NcVar* pVarLat = file.get_var("staLat");//file.get_var("latitude");
	NcVar* pVarLon = file.get_var("staLon");//file.get_var("longitude");
	NcVar* pVarElev = file.get_var("staElev");//file.get_var("elevation");
	NcDim* pDim = pVarLat->get_dim(0);
	//double offset = pVarElev->get_att("add_offset")->as_float(0);
	//double scaleFactor = pVarElev->get_att("scale_factor")->as_float(0);

	int nbRect = pDim->size();
	//delete pDim; pDim = NULL;

	//typedef boost::multi_array<char, 1> CDataCharArray;
	typedef boost::multi_array<float, 1> CDataFloatArray;
	//CDataFloatArray X(boost::extents[180]);
	//CDataFloatArray Y(boost::extents[172]);
	CDataFloatArray lat(boost::extents[nbRect]);
	CDataFloatArray lon(boost::extents[nbRect]);
	CDataFloatArray elev(boost::extents[nbRect]);

	ASSERT( pVarLat->get_dim(0)->size() == pVarLon->get_dim(0)->size() );
	ASSERT( pVarLat->get_dim(0)->size() == pVarElev->get_dim(0)->size() );
	
	//pVarX->get(&(X[0]), 180);
	//pVarY->get(&(Y[0]), 172);
	pVarLat->get(&(lat[0]), nbRect);callback.StepIt();
	pVarLon->get(&(lon[0]), nbRect);callback.StepIt();
	pVarElev->get(&(elev[0]), nbRect);callback.StepIt();

	
	//CProjection prj = GetDataGrid().GetPrj();

	for(int i=0; i<nbRect; i++)
	{
		double Lat=0, Lon=0; 
		
		CString line;
		line.Format("%d,%d,%f,%f,%.1f,0,0\n",i+1,i+1,lat[i],lon[i],elev[i]);
		fileOut.WriteString(line);
	}

	
	fileOut.Close();
	
	return msg;
}