当前位置: 首页>>代码示例>>C++>>正文


C++ MapLayer::GetColCount方法代码示例

本文整理汇总了C++中MapLayer::GetColCount方法的典型用法代码示例。如果您正苦于以下问题:C++ MapLayer::GetColCount方法的具体用法?C++ MapLayer::GetColCount怎么用?C++ MapLayer::GetColCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapLayer的用法示例。


在下文中一共展示了MapLayer::GetColCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFPDistGrid

void CWet_hView::GetFPDistGrid()
   {
   MapLayer *pFlowDir = gpMapWnd->m_pMap->GetLayer( "FLOWDIR" );
   MapLayer *pStreamGrid = gpMapWnd->m_pMap->GetLayer( "STRGRID" );
   MapLayer *pDEM = gpMapWnd->m_pMap->GetLayer( "DEM" );
   MapLayer *pFPDistGrid = gpMapWnd->m_pMap->GetLayer( "FLOWDIRX" );
   
 //  pFPDistGrid->m_name = "FP DistGrad";
   MapLayer *pWatershed = gpMapWnd->m_pMap->GetLayer( "CATCH" );


   float flowPathDistance=0.0f;
   int flowPathCount=0;

   int rows = pDEM->GetRowCount();
   int cols = pDEM->GetColCount();
   for ( int row=0; row < rows; row++ )
      {
      for ( int col=0; col < cols; col++ )
         {
         float distance = pFlowDir->GetDownFlowPathDistance( row, col, pStreamGrid );
         pFPDistGrid->m_pData->Set(col, row, (distance));
         }  // end of:  for ( col < cols )
      }  // end of:  for ( row < rows )
      pFPDistGrid->SaveGridFile("c:\\research\\maimai\\nato\\fpDist.grd");
   }
开发者ID:johnmetta,项目名称:wethydro,代码行数:26,代码来源:wet_hView.cpp

示例2: OnTopographiccalculationMeanwatershedelevation

void CWet_hView::OnTopographiccalculationMeanwatershedelevation()
   {
   MapLayer *pFlowDir = gpMapWnd->m_pMap->GetLayer( "FLOWDIR" );
   MapLayer *pStreamGrid = gpMapWnd->m_pMap->GetLayer( "STRGRID" );
   MapLayer *pDEM = gpMapWnd->m_pMap->GetLayer( "DEM" );
   MapLayer *pFPDistGrid = gpMapWnd->m_pMap->CloneLayer( *pDEM );
   pFPDistGrid->m_name = "FP DistGrad";
   MapLayer *pWatershed = gpMapWnd->m_pMap->GetLayer( "Cells" );
   MapLayer *pStreamV = gpMapWnd->m_pMap->GetLayer("Streams");
   
   int method = 2;
  // the third parameter is the method to use.  a 1 simply returns the average fpdist for each polygon
   // a two returns the entire fp distribution
   int watershedCount   = pWatershed->GetRecordCount();
   int reachCount = pStreamV->GetRecordCount();
   gpHydroModel->m_fpDistributionArray.SetSize(reachCount);
   gpHydroModel->m_fpDistributionArrayStream.SetSize(reachCount);
   for (int i=0; i < reachCount; i++ )
		{
      Poly *pStreamPoly = pStreamV->m_polyArray[i];
      int streamID;
      gpHydroModel->m_pStreamLayer->GetData(i,pStreamV->m_pData->GetCol("HYDRO_ID"), streamID);
      for ( int j=0; j < watershedCount; j++ )//this should be for each reach
         {
		   Poly *pThisPoly = pWatershed->m_polyArray[j];
         int watershedID;
         gpHydroModel->m_pCellLayer->GetData(j,pWatershed->m_pData->GetCol("HYDRO_ID"), watershedID);
         if (watershedID==streamID) // this polygon is in the current reach
            {
		      Poly *pThisPoly = pWatershed->m_polyArray[j];
            float flowPathDistance=0.0f;
            int flowPathCount=0;
            
            float flowPathGradient = 0.001f;
            int rows = pDEM->GetRowCount();
            int cols = pDEM->GetColCount();
            for ( int row=0; row < rows; row++ )
               {
               for ( int col=0; col < cols; col++ )
                  {
                  float x = 0;
                  float y = 0;
                  pDEM->GetGridCellCenter(row, col, x, y);
                  
                  Vertex point;
                  point.x = x;
                  point.y = y;       ///the stream grid is smaller than the flowdir grid
                  if (pThisPoly->IsPointInPoly(point))
                     {
                     int flowPathCellCount=0;
                     float distance = pFlowDir->GetDownFlowPathDistance( row, col, pStreamGrid );
                     float gradient = pFlowDir->GetDownFlowPathGradient(row,col,pStreamGrid,pDEM,flowPathCellCount);
                     gradient=gradient/flowPathCellCount;        
                     float dist_grad = distance/gradient;
                     if (distance==pFlowDir->GetNoDataValue())
                        {
                        dist_grad = pFlowDir->GetNoDataValue();
                        gradient = pFlowDir->GetNoDataValue();
                        }
                     pFPDistGrid->m_pData->Set(col, row, (distance/gradient)); 
                     if (method==1)// we just want the average fpdistance
                        {
                        flowPathGradient +=gradient;
                        flowPathDistance +=distance;
                        flowPathCount++;
                        }
                     if (method==2)// we want to maintain the entire distribution
                        {
                        int dist = (int)(distance/gradient);
                        gpHydroModel->m_fpDistributionArray[i].Add(dist);
                        }
                     }
                  }  // end of:  for ( col < cols )
               }  // end of:  for ( row < rows )
            } // end of :  if watershed==streamID
         }// end of j (watershedCount)
   //  we have found all the flowpaths in the jth reach, but want to now find the median value of that distribution
      float median=-1;
      if (method==2)
         {
         int  temp=-1;
         for (int bottom=gpHydroModel->m_fpDistributionArray[i].GetCount()-1; bottom>0;bottom--)
            {
            for (int position=0;position<bottom;position++)
               {
               int val = gpHydroModel->m_fpDistributionArray[i][position+1];
               int val2 = gpHydroModel->m_fpDistributionArray[i][position];
               if (val < val2)
                  {
                  int temp2 = gpHydroModel->m_fpDistributionArray[i][position];
                  gpHydroModel->m_fpDistributionArray[i][position] = gpHydroModel->m_fpDistributionArray[i][position+1];
                  gpHydroModel->m_fpDistributionArray[i][position+1] = temp2;
                  }
               }
            }
         if (gpHydroModel->m_fpDistributionArray[i].GetCount()<=1)//there were no watersheds for this reach
            {
            median = 0.0f;
            }
         else
//.........这里部分代码省略.........
开发者ID:johnmetta,项目名称:wethydro,代码行数:101,代码来源:wet_hView.cpp

示例3: movieSaveDlg

		/*
	//read Willamette Shapefile
    //read data with 365 rows and 9 cols.  1 column for each major subwatershed (minus the middle Willamette, for which we don't have data. 1 row for each day in year
    //for each day, classify map according to data
    //append to avi file
    //finish
    BOOL m_saveEmfOutput = TRUE;
    if (m_saveEmfOutput)
         { 
         numMovies = 1;
         movieFrameRate = 30;
         AVIGenerators = new CAVIGenerator*[numMovies];  // array of pointers to AVI generators
         auxMovieStuff = new AuxMovieStuff[numMovies];
         CDC* dc = gpView->GetWindowDC();
         // get the window's dimensions
         CRect rect;
         gpView->GetWindowRect(rect);
         for(int i = 0; i < numMovies; i++)
            {
            // get output filename from user
            CFileDialog movieSaveDlg(FALSE, "avi", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Movie Files (*.avi)|*.avi");
            CString movieFileName;
            if (movieSaveDlg.DoModal() == IDOK)
               {
               movieFileName = movieSaveDlg.GetPathName();
               }
            // need to handle canceling out of the file dialog box somehow

            AVIGenerators[i] = new CAVIGenerator(movieFileName, (CView*)gpView, movieFrameRate);

            AVIGenerators[i]->InitEngine();
            auxMovieStuff[i].bitmapDC.CreateCompatibleDC(dc);
            auxMovieStuff[i].bitmap.CreateCompatibleBitmap(dc, rect.Width(), rect.Height());
            auxMovieStuff[i].bitmapDC.SelectObject(&auxMovieStuff[i].bitmap);
            auxMovieStuff[i].bi.bmiHeader = *AVIGenerators[i]->GetBitmapHeader();
            auxMovieStuff[i].lpbi = &auxMovieStuff[i].bi;
            auxMovieStuff[i].bitAddress = new BYTE[3*rect.Width()*rect.Height()];
            }
         gpView->ReleaseDC(dc);
         }
	


    ASSERT ( gpMapWnd != NULL );
    ASSERT ( gpMapWnd->m_pMap != NULL );
	gpMapWnd->m_pMap->AddShapeLayer("c:\\research\\willamette\\will2.shp", true);
	MapLayer *pWill = gpMapWnd->m_pMap->GetLayer(0);
	FDataObj pAsciiData = FDataObj();
	pAsciiData.ReadAscii("c:\\research\\willamette\\willINDI.csv", ',');
	int numDays = pAsciiData.GetRowCount();
	int numWshed = pAsciiData.GetColCount()-1;
	float ti = -1.0f;
    
	gpMapWnd->m_pScatterPrecip = gpMapWnd->AllocateScatter( &pAsciiData, 0 );
	gpMapWnd->m_pScatterPrecip->RedrawWindow();

    for (int i=0;i<numDays;i++)           // for each day of the year (or row in the data)
		{
		int numSheds = pWill->m_pData->GetRowCount();
		float time = -1.0f;
		pAsciiData.Get(0,i,time);
        gpMapWnd->m_pScatterPrecip->UpdateCurrentPos( time );
		//gpMapWnd->m_pScatterPrecip->RedrawWindow();
		for (int j=0;j<numSheds;j++)  // go through each watershed (there are 12 of them)
			{
			float value = -1.0f;                              // and stick the data from pAsciiData into the datatable
			pAsciiData.Get(j+1,i,value);                         //dischargeValue
			pWill->SetData(j,pWill->GetFieldCol("EXTRA_2"),value); //add the value to the correct column in the Maplayer
			
			}
        CString msg;
		COleDateTime t( time );
		CString s = t.Format("%m/%d" );
		msg.Format( "Completed %s" , s );
        gpMain->SetStatusMsg( msg );

		pWill->SetBinColorFlag( BCF_BLUEGREEN );
		pWill->SetBins( -0.2, 0.4, 20 );
		pWill->SetActiveField( pWill->GetFieldCol( "EXTRA_2" ) );
	    pWill->ClassifyData();
        
		if ( gpMapWnd != NULL )
     	   gpMapWnd->RefreshList();

	    gpMapWnd->m_pMapList->RedrawWindow();
	    CDC *dc = gpMapWnd->m_pMap->GetDC();
	    gpMapWnd->m_pMap->DrawMap(*dc);
	    gpMapWnd->m_pMap->ReleaseDC(dc);
   
		if (m_saveEmfOutput)
			{
			CDC* dc = gpView->GetWindowDC();
			CRect rect;
			gpView->GetWindowRect(rect);

			for(int i = 0; i < numMovies; i++)
				{
				// copy from the application window to the new device context (and thus the bitmap)
				BOOL blitSuc = auxMovieStuff[i].bitmapDC.BitBlt(0, 0,
																rect.Width(),
//.........这里部分代码省略.........
开发者ID:johnmetta,项目名称:wethydro,代码行数:101,代码来源:wet_hView.cpp


注:本文中的MapLayer::GetColCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。