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


C++ OGRFeature::GetFID方法代码示例

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


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

示例1: AddFeature

void OGRGeoJSONLayer::AddFeature( OGRFeature* poFeature )
{
    CPLAssert( NULL != poFeature );

    // NOTE - mloskot:
    // Features may not be sorted according to FID values.

    // TODO: Should we check if feature already exists?
    // TODO: Think about sync operation, upload, etc.

    OGRFeature* poNewFeature = NULL;
    poNewFeature = poFeature->Clone();


    if( -1 == poNewFeature->GetFID() )
    {
        int nFID = static_cast<int>(seqFeatures_.size());
        poNewFeature->SetFID( nFID );

        // TODO - mlokot: We need to redesign creation of FID column
        int nField = poNewFeature->GetFieldIndex( DefaultFIDColumn );
        if( -1 != nField && GetLayerDefn()->GetFieldDefn(nField)->GetType() == OFTInteger )
        {
            poNewFeature->SetField( nField, nFID );
        }
    }
    
        
    if( (GIntBig)(int)poNewFeature->GetFID() != poNewFeature->GetFID() )
        SetMetadataItem(OLMD_FID64, "YES");

    seqFeatures_.push_back( poNewFeature );
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:33,代码来源:ogrgeojsonlayer.cpp

示例2: FixIndexes

int FGdbDataSource::FixIndexes()
{
    int bRet = TRUE;
    if( m_pConnection && m_pConnection->IsFIDHackInProgress() )
    {
        m_pConnection->CloseGeodatabase();

        char* apszDrivers[2];
        apszDrivers[0] = (char*) "OpenFileGDB";
        apszDrivers[1] = NULL;
        const char* pszSystemCatalog = CPLFormFilename(m_osFSName, "a00000001.gdbtable", NULL);
        GDALDataset* poOpenFileGDBDS = (GDALDataset*)
            GDALOpenEx(pszSystemCatalog, GDAL_OF_VECTOR,
                       apszDrivers, NULL, NULL);
        if( poOpenFileGDBDS == NULL || poOpenFileGDBDS->GetLayer(0) == NULL )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "Cannot open %s with OpenFileGDB driver. "
                     "Should not happen. Some layers will be corrupted",
                     pszSystemCatalog);
            bRet = FALSE;
        }
        else
        {
            OGRLayer* poLayer = poOpenFileGDBDS->GetLayer(0);
            size_t count = m_layers.size();
            for(size_t i = 0; i < count; ++i )
            {
                if( m_layers[i]->m_oMapOGRFIDToFGDBFID.size() == 0)
                    continue;
                CPLString osFilter = "name = '";
                osFilter += m_layers[i]->GetName();
                osFilter += "'";
                poLayer->SetAttributeFilter(osFilter);
                poLayer->ResetReading();
                OGRFeature* poF = poLayer->GetNextFeature();
                if( poF == NULL )
                {
                    CPLError(CE_Failure, CPLE_AppDefined,
                             "Cannot find filename for layer %s",
                             m_layers[i]->GetName());
                    bRet = FALSE;
                }
                else
                {
                    if( !m_layers[i]->EditIndexesForFIDHack(CPLFormFilename(m_osFSName,
                                        CPLSPrintf("a%08x", (int)poF->GetFID()), NULL)) )
                    {
                        bRet = FALSE;
                    }
                }
                delete poF;
            }
        }
        GDALClose(poOpenFileGDBDS);

        m_pConnection->SetFIDHackInProgress(FALSE);
    }
    return bRet;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:60,代码来源:FGdbDatasource.cpp

示例3: DisconnectFeatures

CPLErr GNMGenericNetwork::DisconnectFeatures(GNMGFID nSrcGFID, GNMGFID nTgtGFID,
                                             GNMGFID nConGFID)
{
    if(!m_bIsGraphLoaded && LoadGraph() != CE_None)
    {
        return CE_Failure;
    }

    OGRFeature *poFeature = FindConnection(nSrcGFID, nTgtGFID, nConGFID);
    if (poFeature == NULL)
    {
        CPLError( CE_Failure, CPLE_AppDefined, "The connection not exist" );
        return CE_Failure;
    }

    if (m_poGraphLayer->DeleteFeature(poFeature->GetFID()) != OGRERR_NONE)
    {
        OGRFeature::DestroyFeature(poFeature);
        return CE_Failure;
    }

    OGRFeature::DestroyFeature(poFeature);

    // update graph

    m_oGraph.DeleteEdge(nConGFID);

    return CE_None;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:29,代码来源:gnmgenericnetwork.cpp

示例4: ResetReading

OGRFeature *OGRAVCBinLayer::GetNextFeature()

{
    if( bNeedReset )
        ResetReading();

    OGRFeature *poFeature = GetFeature( -3 );

    // Skip universe polygon.
    if( poFeature != NULL && poFeature->GetFID() == 1 
        && psSection->eType == AVCFilePAL )
    {
        OGRFeature::DestroyFeature( poFeature );
        poFeature = GetFeature( -3 );
    }

    while( poFeature != NULL 
           && ((m_poAttrQuery != NULL
                && !m_poAttrQuery->Evaluate( poFeature ) )
               || !FilterGeometry( poFeature->GetGeometryRef() ) ) )
    {
        OGRFeature::DestroyFeature( poFeature );
        poFeature = GetFeature( -3 );
    }

    if( poFeature == NULL )
        ResetReading();

    return poFeature;
}
开发者ID:garnertb,项目名称:gdal,代码行数:30,代码来源:ogravcbinlayer.cpp

示例5: DGNReadElement

OGRFeature *OGRDGNLayer::GetFeature( long nFeatureId )

{
    OGRFeature *poFeature;
    DGNElemCore *psElement;

    if( !DGNGotoElement( hDGN, nFeatureId ) )
        return NULL;

    // We should likely clear the spatial search region as it affects 
    // DGNReadElement() but I will defer that for now. 

    psElement = DGNReadElement( hDGN );
    poFeature = ElementToFeature( psElement );
    DGNFreeElement( hDGN, psElement );

    if( poFeature == NULL )
        return NULL;

    if( poFeature->GetFID() != nFeatureId )
    {
        delete poFeature;
        return NULL;
    }

    return poFeature;
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:27,代码来源:ogrdgnlayer.cpp

示例6: CSVWriteVectorValues

void Raster::CSVWriteVectorValues(OGRLayer * poLayer, const char * psFieldName, const char * sRasterOutputPath){

    // use the filename with CSV added onto the end.
    QFileInfo sOutputFileInfo(sRasterOutputPath);
    QDir sNewDir = QDir(sOutputFileInfo.absolutePath());
    QString sCSVFullPath = sNewDir.filePath(sOutputFileInfo.completeBaseName() + ".csv");

    QFile csvFile(sCSVFullPath);

    if (csvFile.open(QFile::WriteOnly|QFile::Truncate))
    {
      QTextStream stream(&csvFile);

      // Write CSV file header
      stream << "\"index\", " << "\""<< psFieldName << "\""<< "\n"; // this writes first line with two columns

      OGRFeature *poFeature;
      poLayer->ResetReading();
      poLayer->SetSpatialFilter(NULL);
      while( (poFeature = poLayer->GetNextFeature()) != NULL){
          const char * sFieldVal = poFeature->GetFieldAsString(psFieldName);
          //  write line to file
          stream << poFeature->GetFID() << ", " << "\"" << sFieldVal << "\"" << "\n"; // this writes first line with two columns
          OGRFeature::DestroyFeature( poFeature );
      }

      csvFile.close();
    }
    return;

}
开发者ID:JamesSLC,项目名称:rasterman,代码行数:31,代码来源:raster_vector2raster.cpp

示例7: OGRFeature

OGRErr       OGRLayerWithTransaction::ICreateFeature( OGRFeature *poFeature )
{
    if( !m_poDecoratedLayer ) return OGRERR_FAILURE;
    OGRFeature* poSrcFeature = new OGRFeature(m_poDecoratedLayer->GetLayerDefn());
    poSrcFeature->SetFrom(poFeature);
    poSrcFeature->SetFID(poFeature->GetFID());
    OGRErr eErr = m_poDecoratedLayer->CreateFeature(poSrcFeature);
    poFeature->SetFID(poSrcFeature->GetFID());
    delete poSrcFeature;
    return eErr;
}
开发者ID:miccferr,项目名称:wmshp-electron,代码行数:11,代码来源:ogremulatedtransaction.cpp

示例8: GetNextFeature

OGRFeature* OGRESRIFeatureServiceLayer::GetNextFeature()
{
    while( TRUE )
    {
        int bWasInFirstPage = !bOtherPage;
        OGRFeature* poSrcFeat = poDS->GetUnderlyingLayer()->GetNextFeature();
        if( poSrcFeat == NULL )
        {
            if( !poDS->LoadNextPage() )
                return NULL;
            poSrcFeat = poDS->GetUnderlyingLayer()->GetNextFeature();
            if( poSrcFeat == NULL )
                return NULL;
            bOtherPage = TRUE;
        }
        if( bOtherPage && bWasInFirstPage && poSrcFeat->GetFID() == 0 &&
            nLastFID == nFeaturesRead - 1 )
        {
            bUseSequentialFID = TRUE;
        }

        OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
        poFeature->SetFrom(poSrcFeat);
        if( bUseSequentialFID )
            poFeature->SetFID(nFeaturesRead);
        else
            poFeature->SetFID(poSrcFeat->GetFID());
        nLastFID = poFeature->GetFID();
        nFeaturesRead ++;
        delete poSrcFeat;
        
        if((m_poFilterGeom == NULL
            || FilterGeometry( poFeature->GetGeometryRef() ) )
        && (m_poAttrQuery == NULL
            || m_poAttrQuery->Evaluate( poFeature )) )
        {
            return poFeature;
        }
        delete poFeature;
    }
}
开发者ID:drownedout,项目名称:datamap,代码行数:41,代码来源:ogrgeojsondriver.cpp

示例9: ResetReading

OGRFeature *OGRILI1Layer::GetFeatureRef( GIntBig nFID )

{
    ResetReading();

    OGRFeature *poFeature = nullptr;
    while( (poFeature = GetNextFeatureRef()) != nullptr )
    {
        if( poFeature->GetFID() == nFID )
            return poFeature;
    }

    return nullptr;
}
开发者ID:OSGeo,项目名称:gdal,代码行数:14,代码来源:ogrili1layer.cpp

示例10: ResetReading

OGRFeature *OGRILI1Layer::GetFeatureRef( long nFID )

{
    OGRFeature *poFeature;

    ResetReading();
    while( (poFeature = GetNextFeatureRef()) != NULL )
    {
        if( poFeature->GetFID() == nFID )
            return poFeature;
    }

    return NULL;
}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:14,代码来源:ogrili1layer.cpp

示例11: GetNextFeature

OGRFeature* OGRGeoJSONSeqLayer::GetNextFeature()
{
    while( true )
    {
        auto poObject = GetNextObject();
        if( !poObject )
            return nullptr;
        OGRFeature* poFeature;
        auto type = OGRGeoJSONGetType(poObject);
        if( type == GeoJSONObject::eFeature )
        {
            poFeature = m_oReader.ReadFeature(
                this, poObject, m_osFeatureBuffer.c_str() );
            json_object_put(poObject);
        }
        else if( type == GeoJSONObject::eFeatureCollection ||
                 type == GeoJSONObject::eUnknown )
        {
            json_object_put(poObject);
            continue;
        }
        else
        {
            OGRGeometry* poGeom = m_oReader.ReadGeometry(poObject,
                                                         GetSpatialRef());
            json_object_put(poObject);
            if( !poGeom )
            {
                continue;
            }
            poFeature = new OGRFeature(m_poFeatureDefn);
            poFeature->SetGeometryDirectly(poGeom);
        }

        if( poFeature->GetFID() == OGRNullFID )
        {
            poFeature->SetFID(m_nNextFID);
            m_nNextFID ++;
        }
        if( (m_poFilterGeom == nullptr ||
            FilterGeometry(poFeature->GetGeomFieldRef(m_iGeomFieldFilter)) )
            && (m_poAttrQuery == nullptr ||
                m_poAttrQuery->Evaluate(poFeature)) )
        {
            return poFeature;
        }
        delete poFeature;
    }
}
开发者ID:koordinates,项目名称:gdal,代码行数:49,代码来源:ogrgeojsonseqdriver.cpp

示例12: run

void GDALClusterNeighbourhood::run()
{
	ngView.createIndex(name_id1);

	leadingView.resetReading();
	OGRFeature * f;
	std::map<int, int> visited;
	int marker = 0;
	while (f = leadingView.getNextFeature()) {
		int id = f->GetFID();
		visited[id] = -1;
	}
	while (f = leadingView.getNextFeature()) {
		int id = f->GetFID();
		if (visited[id] > 0)
			continue;
		marker++;
		getNext(id, marker, visited);
	}
	while (f = leadingView.getNextFeature()) {
		int id = f->GetFID();
		f->SetField("cluster_id", visited[id]);
	}
}
开发者ID:iut-ibk,项目名称:DynaMind-ToolBox,代码行数:24,代码来源:gdalclusterneighbourhood.cpp

示例13: ResetReading

OGRFeature *OGRLayer::GetFeature( long nFID )

{
    OGRFeature *poFeature;

    ResetReading();
    while( (poFeature = GetNextFeature()) != NULL )
    {
        if( poFeature->GetFID() == nFID )
            return poFeature;
        else
            delete poFeature;
    }
    
    return NULL;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:16,代码来源:ogrlayer.cpp

示例14: run

void RainWaterHarvestingOptions::run()
{
	DM::Logger(DM::Debug) << "Init CD3";
	if (!initmodel())
		return;
	DM::Logger(DM::Debug) << "Init CD3 done";

	OGRFeature * p;
	this->parcels.resetReading();
	int counter = 0;
	while(p = this->parcels.getNextFeature()) {
		counter++;
		//Create Raintanks
		//Input Vectors
		std::vector<double> non_potable_demand_daily;
		std::vector<double> run_off_roof_daily;
		std::vector<double> outdoor_demand_daily;

		DM::DMFeature::GetDoubleList(p, "non_potable_demand_daily", non_potable_demand_daily);
		DM::DMFeature::GetDoubleList(p, "run_off_roof_daily", run_off_roof_daily);
		DM::DMFeature::GetDoubleList(p, "outdoor_demand_daily", outdoor_demand_daily);


		for (int i = 0; i < this->storage_volume_tank.size(); i++){
			OGRFeature * rwht = rwhts.createFeature();
			rwht->SetField("parcel_id", (int)p->GetFID());
			this->createTankOption(rwht, QString::fromStdString(storage_volume_tank[i]).toDouble(), run_off_roof_daily, outdoor_demand_daily,  non_potable_demand_daily);
		}
		double non_potable_demand = 0;
		double outdoor_demand = 0;

		for (int i = 0; i <  outdoor_demand_daily.size(); i++) {
			outdoor_demand+=outdoor_demand_daily[i];
			non_potable_demand+=non_potable_demand_daily[i];
		}
		p->SetField("annual_outdoor_demand", outdoor_demand);
		p->SetField("annual_non_potable_demand", non_potable_demand);

		if (counter % 100000 == 0){
			DM::Logger(DM::Standard) << counter;
			this->parcels.syncAlteredFeatures();
			this->parcels.syncReadFeatures();
			this->rwhts.syncAlteredFeatures();
			this->parcels.setNextByIndex(counter);
		}
	}
}
开发者ID:iut-ibk,项目名称:DynaMind-ToolBox,代码行数:47,代码来源:rainwaterharvestingoptions.cpp

示例15: ICreateFeature

OGRErr OGRUnionLayer::ICreateFeature( OGRFeature* poFeature )
{
    if( osSourceLayerFieldName.size() == 0 )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "CreateFeature() not supported when SourceLayerFieldName is not set");
        return OGRERR_FAILURE;
    }

    if( poFeature->GetFID() != OGRNullFID )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "CreateFeature() not supported when FID is set");
        return OGRERR_FAILURE;
    }

    if( !poFeature->IsFieldSet(0) )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "CreateFeature() not supported when '%s' field is not set",
                 osSourceLayerFieldName.c_str());
        return OGRERR_FAILURE;
    }

    const char* pszSrcLayerName = poFeature->GetFieldAsString(0);
    for(int i=0;i<nSrcLayers;i++)
    {
        if( strcmp(pszSrcLayerName, papoSrcLayers[i]->GetName()) == 0)
        {
            pabModifiedLayers[i] = TRUE;

            OGRFeature* poSrcFeature =
                        new OGRFeature(papoSrcLayers[i]->GetLayerDefn());
            poSrcFeature->SetFrom(poFeature, TRUE);
            OGRErr eErr = papoSrcLayers[i]->CreateFeature(poSrcFeature);
            if( eErr == OGRERR_NONE )
                poFeature->SetFID(poSrcFeature->GetFID());
            delete poSrcFeature;
            return eErr;
        }
    }

    CPLError(CE_Failure, CPLE_NotSupported,
             "CreateFeature() not supported : '%s' source layer does not exist",
             pszSrcLayerName);
    return OGRERR_FAILURE;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:47,代码来源:ogrunionlayer.cpp


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