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


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

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


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

示例1: TranslateFromSrcLayer

OGRFeature* OGRUnionLayer::TranslateFromSrcLayer(OGRFeature* poSrcFeature)
{
    CPLAssert(panMap != NULL);
    CPLAssert(iCurLayer >= 0 && iCurLayer < nSrcLayers);

    OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
    poFeature->SetFrom(poSrcFeature, panMap, TRUE);

    if( osSourceLayerFieldName.size() &&
        !poFeatureDefn->GetFieldDefn(0)->IsIgnored() )
    {
        poFeature->SetField(0, papoSrcLayers[iCurLayer]->GetName());
    }

    for(int i=0;i<poFeatureDefn->GetGeomFieldCount();i++)
    {
        if( poFeatureDefn->GetGeomFieldDefn(i)->IsIgnored() )
            poFeature->SetGeomFieldDirectly(i, NULL);
        else
        {
            OGRGeometry* poGeom = poFeature->GetGeomFieldRef(i);
            if( poGeom != NULL )
            {
                poGeom->assignSpatialReference(
                    poFeatureDefn->GetGeomFieldDefn(i)->GetSpatialRef());
            }
        }
    }

    if( bPreserveSrcFID )
        poFeature->SetFID(poSrcFeature->GetFID());
    else
        poFeature->SetFID(nNextFID ++);
    return poFeature;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:35,代码来源:ogrunionlayer.cpp

示例2: GetNextFeature

OGRFeature* GTMWaypointLayer::GetNextFeature()
{
    if( bError )
        return nullptr;

    while (poDS->hasNextWaypoint())
    {
        Waypoint* poWaypoint = poDS->fetchNextWaypoint();
        if (poWaypoint == nullptr)
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "Could not read waypoint. File probably corrupted");
            bError = true;
            return nullptr;
        }

        OGRFeature* poFeature = new OGRFeature( poFeatureDefn );
        double altitude = poWaypoint->getAltitude();
        if (altitude == 0.0)
            poFeature->SetGeometryDirectly(new OGRPoint
                                           (poWaypoint->getLongitude(),
                                            poWaypoint->getLatitude()));
        else
            poFeature->SetGeometryDirectly(new OGRPoint
                                           (poWaypoint->getLongitude(),
                                            poWaypoint->getLatitude(),
                                            altitude));

        if (poSRS)
            poFeature->GetGeometryRef()->assignSpatialReference(poSRS);
        poFeature->SetField( NAME, poWaypoint->getName());
        poFeature->SetField( COMMENT, poWaypoint->getComment());
        poFeature->SetField( ICON, poWaypoint->getIcon());

        GIntBig wptdate = poWaypoint->getDate();
        if (wptdate != 0)
        {
            struct tm brokendownTime;
            CPLUnixTimeToYMDHMS(wptdate, &brokendownTime);
            poFeature->SetField( DATE,
                                 brokendownTime.tm_year + 1900,
                                 brokendownTime.tm_mon + 1,
                                 brokendownTime.tm_mday,
                                 brokendownTime.tm_hour,
                                 brokendownTime.tm_min,
                                 static_cast<float>(brokendownTime.tm_sec));
        }

        poFeature->SetFID( nNextFID++ );
        delete poWaypoint;
        if( (m_poFilterGeom == nullptr
             || FilterGeometry( poFeature->GetGeometryRef() ) )
            && (m_poAttrQuery == nullptr
                || m_poAttrQuery->Evaluate( poFeature )) )
            return poFeature;

        delete poFeature;
    }
    return nullptr;
}
开发者ID:koordinates,项目名称:gdal,代码行数:60,代码来源:gtmwaypointlayer.cpp

示例3: ResetReading

OGRFeature *OGRFMELayerCached::ReadNextIndexFeature()

{
    OGRFeature          *poOGRFeature = NULL;
    FME_Boolean         endOfQuery;

    if( poIndex == NULL )
        return NULL;

    if( !bQueryActive )
        ResetReading();

    poDS->AcquireSession();

    if( poIndex->fetch( *poFMEFeature, endOfQuery ) == 0
        && !endOfQuery )
    {
        poOGRFeature = poDS->ProcessFeature( this, poFMEFeature );

        if( poOGRFeature != NULL )
        {
            poOGRFeature->SetFID( ++nPreviousFeature );
            m_nFeaturesRead++;
        }
    }

    poDS->ReleaseSession();

    return poOGRFeature;
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:30,代码来源:ogrfmelayercached.cpp

示例4: while

OGRFeature *OGRLIBKMLLayer::GetNextRawFeature (
     )
{
    FeaturePtr poKmlFeature;
    OGRFeature *poOgrFeature = NULL;

    do {
        if ( iFeature >= nFeatures )
            break;

        poKmlFeature = m_poKmlLayer->get_feature_array_at ( iFeature++ );

    } while ( poKmlFeature->Type (  ) != kmldom::Type_Placemark );


    if ( iFeature <= nFeatures && poKmlFeature
         && poKmlFeature->Type (  ) == kmldom::Type_Placemark ) {
        poOgrFeature =
            kml2feat ( AsPlacemark ( poKmlFeature ), m_poOgrDS, this,
                       m_poOgrFeatureDefn, m_poOgrSRS );
        poOgrFeature->SetFID(nFID ++);
    }

    return poOgrFeature;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:25,代码来源:ogrlibkmllayer.cpp

示例5: 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 );
        }
    }

    seqFeatures_.push_back( poNewFeature );
}
开发者ID:0004c,项目名称:node-gdal,代码行数:29,代码来源:ogrgeojsonlayer.cpp

示例6: if

OGRFeature *OGROpenAirLabelLayer::GetNextRawFeature()
{
    const char* pszLine;
    double dfLat = 0, dfLon = 0;
    int bHasCoord = FALSE;

    while(TRUE)
    {
        pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);
        if (pszLine == NULL)
            return NULL;

        if (pszLine[0] == '*' || pszLine[0] == '\0')
            continue;

        if (EQUALN(pszLine, "AC ", 3))
        {
            if (osCLASS.size() != 0)
            {
                osNAME = "";
                osCEILING = "";
                osFLOOR = "";
            }
            osCLASS = pszLine + 3;
        }
        else if (EQUALN(pszLine, "AN ", 3))
            osNAME = pszLine + 3;
        else if (EQUALN(pszLine, "AH ", 3))
            osCEILING = pszLine + 3;
        else if (EQUALN(pszLine, "AL ", 3))
            osFLOOR = pszLine + 3;
        else if (EQUALN(pszLine, "AT ", 3))
        {
            bHasCoord = OGROpenAirGetLatLon(pszLine + 3, dfLat, dfLon);
            break;
        }
    }

    OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
    poFeature->SetField(0, osCLASS.c_str());
    poFeature->SetField(1, osNAME.c_str());
    poFeature->SetField(2, osFLOOR.c_str());
    poFeature->SetField(3, osCEILING.c_str());

    CPLString osStyle;
    osStyle.Printf("LABEL(t:\"%s\")", osNAME.c_str());
    poFeature->SetStyleString(osStyle.c_str());

    if (bHasCoord)
    {
        OGRPoint* poPoint = new OGRPoint(dfLon, dfLat);
        poPoint->assignSpatialReference(poSRS);
        poFeature->SetGeometryDirectly(poPoint);
    }

    poFeature->SetFID(nNextFID++);

    return poFeature;
}
开发者ID:samalone,项目名称:gdal-ios,代码行数:59,代码来源:ogropenairlabellayer.cpp

示例7: while

OGRFeature *OGRKMLLayer::GetNextFeature()
{
#ifndef HAVE_EXPAT
    return NULL;
#else
    /* -------------------------------------------------------------------- */
    /*      Loop till we find a feature matching our criteria.              */
    /* -------------------------------------------------------------------- */
    KML *poKMLFile = poDS_->GetKMLFile();
    if( poKMLFile == NULL )
        return NULL;
    poKMLFile->selectLayer(nLayerNumber_);

    while( true )
    {
        Feature *poFeatureKML = NULL;
        poFeatureKML = poKMLFile->getFeature(iNextKMLId_++, nLastAsked, nLastCount);

        if(poFeatureKML == NULL)
            return NULL;

        CPLAssert( poFeatureKML != NULL );

        OGRFeature *poFeature = new OGRFeature( poFeatureDefn_ );

        if(poFeatureKML->poGeom)
        {
            poFeature->SetGeometryDirectly(poFeatureKML->poGeom);
            poFeatureKML->poGeom = NULL;
        }

        // Add fields
        poFeature->SetField( poFeatureDefn_->GetFieldIndex("Name"), poFeatureKML->sName.c_str() );
        poFeature->SetField( poFeatureDefn_->GetFieldIndex("Description"), poFeatureKML->sDescription.c_str() );
        poFeature->SetFID( iNextKMLId_ - 1 );

        // Clean up
        delete poFeatureKML;

        if( poFeature->GetGeometryRef() != NULL && poSRS_ != NULL)
        {
            poFeature->GetGeometryRef()->assignSpatialReference( poSRS_ );
        }

        /* Check spatial/attribute filters */
        if ((m_poFilterGeom == NULL || FilterGeometry( poFeature->GetGeometryRef() ) ) &&
            (m_poAttrQuery == NULL || m_poAttrQuery->Evaluate( poFeature )) )
        {
        // Return the feature
            return poFeature;
        }
        else
        {
            delete poFeature;
        }
    }

#endif /* HAVE_EXPAT */
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:59,代码来源:ogrkmllayer.cpp

示例8: while

OGRFeature *OGRSEGUKOOALineLayer::GetNextRawFeature()
{
    if( bEOF )
        return nullptr;

    /* Merge points of base layer that have same value for attribute(0) */
    /* into a single linestring */

    OGRFeature* poFeature = nullptr;
    OGRLineString* poLS = nullptr;

    if (poNextBaseFeature == nullptr)
        poNextBaseFeature = poBaseLayer->GetNextFeature();

    while(poNextBaseFeature != nullptr)
    {
        if (poNextBaseFeature->IsFieldSetAndNotNull(0) &&
            poNextBaseFeature->GetFieldAsString(0)[0] != '\0')
        {
            if (poFeature != nullptr &&
                strcmp(poFeature->GetFieldAsString(0),
                    poNextBaseFeature->GetFieldAsString(0)) != 0)
            {
                poFeature->SetGeometryDirectly(poLS);
                return poFeature;
            }

            OGRGeometry* poGeom =
                poNextBaseFeature->GetGeometryRef();
            OGRPoint* poPoint = poGeom ? poGeom->toPoint(): nullptr;
            if (poPoint != nullptr)
            {
                if (poFeature == nullptr)
                {
                    poFeature = new OGRFeature(poFeatureDefn);
                    poFeature->SetFID(nNextFID ++);
                    poFeature->SetField(0,
                        poNextBaseFeature->GetFieldAsString(0));
                    poLS = new OGRLineString();
                    if (poBaseLayer->GetSpatialRef())
                        poLS->assignSpatialReference(
                                    poBaseLayer->GetSpatialRef());
                }

                poLS->addPoint(poPoint);
            }
        }

        delete poNextBaseFeature;
        poNextBaseFeature = poBaseLayer->GetNextFeature();
    }

    bEOF = true;
    if( poFeature )
        poFeature->SetGeometryDirectly(poLS);
    return poFeature;
}
开发者ID:OSGeo,项目名称:gdal,代码行数:57,代码来源:ogrsegukooalayer.cpp

示例9: OGRFeature

OGRErr       OGRLayerWithTransaction::ISetFeature( 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->SetFeature(poSrcFeature);
    delete poSrcFeature;
    return eErr;
}
开发者ID:miccferr,项目名称:wmshp-electron,代码行数:10,代码来源:ogremulatedtransaction.cpp

示例10: while

OGRFeature *OGRSEGUKOOALineLayer::GetNextRawFeature()
{
    if (bEOF)
        return NULL;

    /* Merge points of base layer that have same value for attribute(0) */
    /* into a single linestring */

    OGRFeature* poFeature = NULL;
    OGRLineString* poLS = NULL;

    if (poNextBaseFeature == NULL)
        poNextBaseFeature = poBaseLayer->GetNextFeature();

    while(poNextBaseFeature != NULL)
    {
        if (poNextBaseFeature->IsFieldSet(0) &&
            poNextBaseFeature->GetFieldAsString(0)[0] != '\0')
        {
            if (poFeature != NULL &&
                strcmp(poFeature->GetFieldAsString(0),
                    poNextBaseFeature->GetFieldAsString(0)) != 0)
            {
                return poFeature;
            }

            OGRPoint* poPoint =
                (OGRPoint*) poNextBaseFeature->GetGeometryRef();
            if (poPoint != NULL)
            {
                if (poFeature == NULL)
                {
                    poFeature = new OGRFeature(poFeatureDefn);
                    poFeature->SetFID(nNextFID ++);
                    poFeature->SetField(0,
                        poNextBaseFeature->GetFieldAsString(0));
                    poLS = new OGRLineString();
                    if (poBaseLayer->GetSpatialRef())
                        poLS->assignSpatialReference(
                                    poBaseLayer->GetSpatialRef());
                    poFeature->SetGeometryDirectly(poLS);
                }

                poLS->addPoint(poPoint);
            }
        }

        delete poNextBaseFeature;
        poNextBaseFeature = poBaseLayer->GetNextFeature();
    }

    bEOF = TRUE;
    return poFeature;
}
开发者ID:drownedout,项目名称:datamap,代码行数:54,代码来源:ogrsegukooalayer.cpp

示例11: OGRFeature

OGRFeature * OGRFGdbSingleFeatureLayer::GetNextFeature()
{
    if (iNextShapeId != 0)
        return NULL;

    OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
    if (pszVal)
        poFeature->SetField(0, pszVal);
    poFeature->SetFID(iNextShapeId ++);
    return poFeature;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:11,代码来源:FGdbDatasource.cpp

示例12: 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

示例13: switch

OGRFeature *OGRLIBKMLLayer::GetNextRawFeature (
     )
{
    FeaturePtr poKmlFeature;
    OGRFeature *poOgrFeature = NULL;

    if( m_poKmlLayer == NULL )
        return NULL;

    /***** loop over the kml features to find the next placemark *****/

    do {
        if ( iFeature >= nFeatures )
            break;

        /***** get the next kml feature in the container *****/

        poKmlFeature = m_poKmlLayer->get_feature_array_at ( iFeature++ );

        /***** what type of kml feature in the container? *****/

        switch (poKmlFeature->Type (  )) {

            case kmldom::Type_Placemark:
                poOgrFeature = kml2feat ( AsPlacemark ( poKmlFeature ),
                                          m_poOgrDS, this,
                                          m_poOgrFeatureDefn, m_poOgrSRS );
                break;

            case kmldom::Type_GroundOverlay:
                if (m_bReadGroundOverlay) {
                    poOgrFeature =
                        kmlgroundoverlay2feat ( AsGroundOverlay ( poKmlFeature ),
                                                m_poOgrDS, this,
                                                m_poOgrFeatureDefn,
                                                m_poOgrSRS );
                }
                break;

            default:
                break;

        }

    } while ( !poOgrFeature );

    /***** set the FID on the ogr feature *****/

    if (poOgrFeature)
        poOgrFeature->SetFID(nFID ++);

    return poOgrFeature;
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:53,代码来源:ogrlibkmllayer.cpp

示例14: ISetFeature

OGRErr OGRUnionLayer::ISetFeature( OGRFeature* poFeature )
{
    if( !bPreserveSrcFID )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "SetFeature() not supported when PreserveSrcFID is OFF");
        return OGRERR_FAILURE;
    }

    if( osSourceLayerFieldName.size() == 0 )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "SetFeature() not supported when SourceLayerFieldName is not set");
        return OGRERR_FAILURE;
    }

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

    if( !poFeature->IsFieldSet(0) )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "SetFeature() 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);
            poSrcFeature->SetFID(poFeature->GetFID());
            OGRErr eErr = papoSrcLayers[i]->SetFeature(poSrcFeature);
            delete poSrcFeature;
            return eErr;
        }
    }

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

示例15: while

OGRFeature *OGRAeronavFAANAVAIDLayer::GetNextRawFeature()
{
    char szBuffer[134];

    while( true )
    {
        const char* pszLine = CPLReadLine2L(fpAeronavFAA, 134, nullptr);
        if (pszLine == nullptr)
        {
            bEOF = true;
            return nullptr;
        }
        if (strlen(pszLine) != 132)
            continue;
        if ( !(pszLine[psRecordDesc->nLatStartCol-1] == 'N' ||
               pszLine[psRecordDesc->nLatStartCol-1] == 'S') )
            continue;
        if ( !(pszLine[psRecordDesc->nLonStartCol-1] == 'E' ||
               pszLine[psRecordDesc->nLonStartCol-1] == 'W') )
            continue;

        OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
        poFeature->SetFID(nNextFID ++);

        for( int i=0; i < psRecordDesc->nFields; i++ )
        {
            int nWidth = psRecordDesc->pasFields[i].nLastCol - psRecordDesc->pasFields[i].nStartCol + 1;
            strncpy(szBuffer, pszLine + psRecordDesc->pasFields[i].nStartCol - 1, nWidth);
            szBuffer[nWidth] = 0;
            while(nWidth > 0 && szBuffer[nWidth - 1] == ' ')
            {
                szBuffer[nWidth - 1] = 0;
                nWidth --;
            }
            if (nWidth != 0)
                poFeature->SetField(i, szBuffer);
        }

        double dfLat = 0.0;
        double dfLon = 0.0;
        GetLatLon(pszLine + psRecordDesc->nLatStartCol - 1,
                  pszLine + psRecordDesc->nLonStartCol - 1,
                  dfLat,
                  dfLon);

        OGRGeometry* poGeom = new OGRPoint(dfLon, dfLat);
        poGeom->assignSpatialReference(poSRS);
        poFeature->SetGeometryDirectly( poGeom );
        return poFeature;
    }
}
开发者ID:koordinates,项目名称:gdal,代码行数:51,代码来源:ograeronavfaalayer.cpp


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