本文整理汇总了C++中Poly::IsPointInPoly方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::IsPointInPoly方法的具体用法?C++ Poly::IsPointInPoly怎么用?C++ Poly::IsPointInPoly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::IsPointInPoly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: movieSaveDlg
//.........这里部分代码省略.........
float flowPathGradient = 0.0001f;
int rows = pFlowDir->GetRowCount();
int cols = pFlowDir->GetColCount();
int cellCount = rows*cols;
int sofar=0;
for ( int row=0; row < rows; row++ )
{
for ( int col=0; col < cols; col++ )
{
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, gradient);
pFPDistGrid1->m_pData->Set(col, row, distance);
pFPDistGrid2->m_pData->Set(col, row, dist_grad);
sofar = sofar++;
gpHydroModel->m_pMap->Notify( NT_CALCDIST, sofar, cellCount );
} // end of: for ( col < cols )
} // end of: for ( row < rows )
*/
float flowPathDistance=0.0f;
int flowPathCount=0;
float flowPathGradient = 0.0001f;
MapLayer *pWatershed = gpMapWnd->m_pMap->GetLayer( "Cells" );
int polygonCount = pWatershed->GetRecordCount();
for ( int i=0; i < polygonCount; i++ )
{
Poly *pThisPoly = pWatershed->m_polyArray[ i ];
float flowPathDistance=0.0f;
int flowPathCount=0;
float flowPathGradient = 0.0001f;
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;
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));
flowPathGradient +=gradient;
flowPathDistance +=distance;
}
}
} // end of: for ( col < cols )
} // end of: for ( row < rows )
float averageFPDistance = flowPathDistance/flowPathCount;
float averageFPGrad = flowPathGradient/flowPathCount;
float averageFPDistGrad = averageFPDistance/averageFPGrad;
//float rt = (0.00881f*averageFPDistGrad) + 0.00314f;
gpHydroModel->m_pMap->Notify( NT_CALCDIST, i, polygonCount );
pWatershed->SetData(i,pWatershed->m_pData->GetCol("EXTRA_1"), averageFPDistGrad);
pFPDistGrid2->SaveGridFile("c:\\temp\\Dist_Grad.asc");
pFPDistGrid1->SaveGridFile("c:\\temp\\Dist.asc");
pFPDistGrid->SaveGridFile("c:\\temp\\Grad.asc");
}