本文整理汇总了C++中OGRFeature::GetFieldAsGNMGFID方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::GetFieldAsGNMGFID方法的具体用法?C++ OGRFeature::GetFieldAsGNMGFID怎么用?C++ OGRFeature::GetFieldAsGNMGFID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::GetFieldAsGNMGFID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadGraph
CPLErr GNMGenericNetwork::LoadGraph()
{
if(m_bIsGraphLoaded)
return CE_None;
if(NULL == m_poGraphLayer)
{
CPLError( CE_Failure, CPLE_AppDefined, "Loading of graph data failed");
return CE_Failure;
}
OGRFeature *poFeature;
m_poGraphLayer->ResetReading();
GNMGFID nSrcFID, nTgtFID, nConFID;
double dfCost, dfInvCost;
while ((poFeature = m_poGraphLayer->GetNextFeature()) != NULL)
{
nSrcFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_SOURCE);
nTgtFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_TARGET);
nConFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_CONNECTOR);
dfCost = poFeature->GetFieldAsDouble(GNM_SYSFIELD_COST);
dfInvCost = poFeature->GetFieldAsDouble(GNM_SYSFIELD_INVCOST);
GNMDirection eDir = poFeature->GetFieldAsInteger(GNM_SYSFIELD_DIRECTION);
int nBlockState = poFeature->GetFieldAsInteger(GNM_SYSFIELD_BLOCKED);
bool bIsBlock = GNM_BLOCK_NONE != nBlockState;
m_oGraph.AddEdge(nConFID, nSrcFID, nTgtFID, eDir == GNM_EDGE_DIR_BOTH,
dfCost, dfInvCost);
if(bIsBlock)
{
if(nBlockState & GNM_BLOCK_SRC)
m_oGraph.ChangeBlockState(nSrcFID, bIsBlock);
if(nBlockState & GNM_BLOCK_TGT)
m_oGraph.ChangeBlockState(nTgtFID, bIsBlock);
if(nBlockState & GNM_BLOCK_CONN)
m_oGraph.ChangeBlockState(nConFID, bIsBlock);
}
if(nConFID < m_nVirtualConnectionGID)
m_nVirtualConnectionGID = nConFID;
OGRFeature::DestroyFeature(poFeature);
}
m_bIsGraphLoaded = true;
return CE_None;
}
示例2: FindNearestPoint
GNMGFID GNMGenericNetwork::FindNearestPoint(const OGRPoint* poPoint,
const std::vector<OGRLayer*>& paPointLayers,
double dfTolerance)
{
VALIDATE_POINTER1(poPoint, "GNMGenericNetwork::FindNearestPoint", -1);
double dfMinX = poPoint->getX() - dfTolerance;
double dfMinY = poPoint->getY() - dfTolerance;
double dfMaxX = poPoint->getX() + dfTolerance;
double dfMaxY = poPoint->getY() + dfTolerance;
OGRFeature *poFeature;
for(size_t i = 0; i < paPointLayers.size(); ++i)
{
OGRLayer *poLayer = paPointLayers[i];
poLayer->SetSpatialFilterRect(dfMinX, dfMinY,
dfMaxX, dfMaxY);
poLayer->ResetReading();
while((poFeature = poLayer->GetNextFeature()) != NULL)
{
GNMGFID nRetFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_GFID);
OGRFeature::DestroyFeature(poFeature);
return nRetFID;
}
}
return -1;
}
示例3: LoadFeaturesLayer
CPLErr GNMGenericNetwork::LoadFeaturesLayer(GDALDataset * const pDS)
{
m_poFeaturesLayer = pDS->GetLayerByName(GNM_SYSLAYER_FEATURES);
if(NULL == m_poFeaturesLayer)
{
CPLError( CE_Failure, CPLE_AppDefined, "Loading of '%s' layer failed",
GNM_SYSLAYER_FEATURES );
return CE_Failure;
}
OGRFeature *poFeature;
m_poFeaturesLayer->ResetReading();
while ((poFeature = m_poFeaturesLayer->GetNextFeature()) != NULL)
{
GNMGFID nFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_GFID);
const char *pFeatureClass = poFeature->GetFieldAsString(
GNM_SYSFIELD_LAYERNAME);
if(nFID >= m_nGID)
m_nGID = nFID + 1;
m_moFeatureFIDMap[nFID] = pFeatureClass;
// Load network layer. No error handling as we want to load whole network
LoadNetworkLayer(pFeatureClass);
OGRFeature::DestroyFeature(poFeature);
}
return CE_None;
}
示例4: DeleteLayer
OGRErr GNMGenericNetwork::DeleteLayer(int nIndex)
{
if(nIndex < 0 || nIndex >= (int)m_apoLayers.size())
return OGRERR_FAILURE;
const char* pszLayerName = m_apoLayers[nIndex]->GetName();
OGRFeature *poFeature;
std::set<GNMGFID> anGFIDs;
std::set<GNMGFID>::iterator it;
// remove layer GFID's from Features layer
m_poFeaturesLayer->ResetReading();
while ((poFeature = m_poFeaturesLayer->GetNextFeature()) != NULL)
{
const char *pFeatureClass = poFeature->GetFieldAsString(
GNM_SYSFIELD_LAYERNAME);
if(EQUAL(pFeatureClass, pszLayerName))
{
anGFIDs.insert(poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_GFID));
CPL_IGNORE_RET_VAL(m_poFeaturesLayer->DeleteFeature(poFeature->GetFID()));
}
OGRFeature::DestroyFeature(poFeature);
}
// remove GFID's from graph layer
m_poGraphLayer->ResetReading();
while ((poFeature = m_poGraphLayer->GetNextFeature()) != NULL)
{
GNMGFID nGFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_SOURCE);
it = anGFIDs.find(nGFID);
if( it != anGFIDs.end())
{
CPL_IGNORE_RET_VAL(m_poGraphLayer->DeleteFeature(poFeature->GetFID()));
OGRFeature::DestroyFeature(poFeature);
continue;
}
nGFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_TARGET);
it = anGFIDs.find(nGFID);
if( it != anGFIDs.end())
{
CPL_IGNORE_RET_VAL(m_poGraphLayer->DeleteFeature(poFeature->GetFID()));
OGRFeature::DestroyFeature(poFeature);
continue;
}
nGFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_CONNECTOR);
it = anGFIDs.find(nGFID);
if( it != anGFIDs.end())
{
CPL_IGNORE_RET_VAL(m_poGraphLayer->DeleteFeature(poFeature->GetFID()));
OGRFeature::DestroyFeature(poFeature);
continue;
}
OGRFeature::DestroyFeature(poFeature);
}
// remove connected rules
for(size_t i = m_asRules.size(); i > 0; --i)
{
if(EQUAL(m_asRules[i - 1].GetSourceLayerName(), pszLayerName))
{
m_asRules.erase(m_asRules.begin() + i - 1);
m_bIsRulesChanged = true;
}
else if(EQUAL(m_asRules[i - 1].GetTargetLayerName(), pszLayerName))
{
m_asRules.erase(m_asRules.begin() + i - 1);
m_bIsRulesChanged = true;
}
else if(EQUAL(m_asRules[i - 1].GetConnectorLayerName(), pszLayerName))
{
m_asRules.erase(m_asRules.begin() + i - 1);
m_bIsRulesChanged = true;
}
}
delete m_apoLayers[nIndex];
// remove from array
m_apoLayers.erase (m_apoLayers.begin() + nIndex);
return OGRERR_NONE;
}
示例5: ChangeBlockState
CPLErr GNMGenericNetwork::ChangeBlockState(GNMGFID nFID, bool bIsBlock)
{
if(!m_bIsGraphLoaded && LoadGraph() != CE_None)
{
return CE_Failure;
}
// change block state in layer
OGRLayer* poLayer = GetLayerByName(m_moFeatureFIDMap[nFID]);
if(NULL == poLayer)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed to get layer '%s'.",
m_moFeatureFIDMap[nFID].c_str() );
return CE_Failure;
}
OGRFeature* poFeature = poLayer->GetFeature(nFID);
if(NULL == poFeature)
{
CPLError( CE_Failure, CPLE_AppDefined, "Failed to get feature '"
GNMGFIDFormat"'.", nFID );
return CE_Failure;
}
if(bIsBlock)
{
poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_ALL );
}
else
{
poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_NONE );
}
if( poLayer->SetFeature( poFeature ) != OGRERR_NONE )
{
OGRFeature::DestroyFeature( poFeature );
CPLError( CE_Failure, CPLE_AppDefined, "Failed to update feature." );
return CE_Failure;
}
OGRFeature::DestroyFeature( poFeature );
GNMGFID nSrcFID, nTgtFID, nConFID;
// change block state in graph layer
m_poGraphLayer->ResetReading();
while ((poFeature = m_poGraphLayer->GetNextFeature()) != NULL)
{
nSrcFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_SOURCE);
nTgtFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_TARGET);
nConFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_CONNECTOR);
int nBlockState = poFeature->GetFieldAsInteger(GNM_SYSFIELD_BLOCKED);
if(bIsBlock)
{
if(nSrcFID == nFID)
nBlockState |= GNM_BLOCK_SRC;
else if(nTgtFID == nFID)
nBlockState |= GNM_BLOCK_TGT;
else if(nConFID == nFID)
nBlockState |= GNM_BLOCK_CONN;
poFeature->SetField( GNM_SYSFIELD_BLOCKED, nBlockState );
}
else
{
if(nSrcFID == nFID)
nBlockState &= ~GNM_BLOCK_SRC;
else if(nTgtFID == nFID)
nBlockState &= ~GNM_BLOCK_TGT;
else if(nConFID == nFID)
nBlockState &= ~GNM_BLOCK_CONN;
poFeature->SetField( GNM_SYSFIELD_BLOCKED, nBlockState );
}
if( m_poGraphLayer->SetFeature( poFeature ) != OGRERR_NONE )
{
OGRFeature::DestroyFeature( poFeature );
CPLError( CE_Failure, CPLE_AppDefined, "Failed to update feature." );
return CE_Failure;
}
OGRFeature::DestroyFeature( poFeature );
}
// change block state in graph
m_oGraph.ChangeBlockState(nFID, bIsBlock);
return CE_None;
}