예제 #1
0
OGRErr OGRFeatureDefn::ReorderFieldDefns( int* panMap )

{
    if (GetFieldCount() == 0)
        return OGRERR_NONE;

    OGRErr eErr = OGRCheckPermutation(panMap, nFieldCount);
    if (eErr != OGRERR_NONE)
        return eErr;

    OGRFieldDefn** papoFieldDefnNew = (OGRFieldDefn**)
        CPLMalloc(sizeof(OGRFieldDefn*) * nFieldCount);

    for(int i=0;i<nFieldCount;i++)
    {
        papoFieldDefnNew[i] = papoFieldDefn[panMap[i]];
    }

    CPLFree(papoFieldDefn);
    papoFieldDefn = papoFieldDefnNew;

    return OGRERR_NONE;
}
예제 #2
0
OGRErr OGRMemLayer::ReorderFields( int* panMap )
{
    if (!bUpdatable)
        return OGRERR_FAILURE;

    if (poFeatureDefn->GetFieldCount() == 0)
        return OGRERR_NONE;

    OGRErr eErr = OGRCheckPermutation(panMap, poFeatureDefn->GetFieldCount());
    if (eErr != OGRERR_NONE)
        return eErr;

/* -------------------------------------------------------------------- */
/*      Remap all the internal features.  Hopefully there aren't any    */
/*      external features referring to our OGRFeatureDefn!              */
/* -------------------------------------------------------------------- */
    for( GIntBig i = 0; i < nMaxFeatureCount; i++ )
    {
        if( papoFeatures[i] != NULL )
            papoFeatures[i]->RemapFields( NULL, panMap );
    }

    return poFeatureDefn->ReorderFieldDefns( panMap );
}