⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntf_generic.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                                          papoGroup[0]->GetField(11,16),                                          NULL, &pszProcessedValue, NULL ) )                poFeature->SetField(szValType, pszProcessedValue);        }        if( !EQUAL(papoGroup[0]->GetField(17,20),"    ") )        {            poFeature->SetField("FEAT_CODE",papoGroup[0]->GetField(17,20));        }    }    return poFeature;}/************************************************************************//*                        TranslateGenericLine()                        *//************************************************************************/static OGRFeature *TranslateGenericLine( NTFFileReader *poReader,                                         OGRNTFLayer *poLayer,                                         NTFRecord **papoGroup ){    if( CSLCount((char **) papoGroup) < 2        || papoGroup[0]->GetType() != NRT_LINEREC        || (papoGroup[1]->GetType() != NRT_GEOMETRY            && papoGroup[1]->GetType() != NRT_GEOMETRY3D) )        return NULL;            OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // LINE_ID    poFeature->SetField( "LINE_ID", atoi(papoGroup[0]->GetField( 3, 8 )) );    // Geometry    poFeature->SetGeometryDirectly(poReader->ProcessGeometry(papoGroup[1]));    poFeature->SetField( "GEOM_ID", papoGroup[1]->GetField(3,8) );    // ATTREC Attributes    AddGenericAttributes( poReader, papoGroup, poFeature );    // Handle singular attribute in pre-level 3 LINEREC.    if( poReader->GetNTFLevel() < 3 )    {        char    szValType[3];        strcpy( szValType, papoGroup[0]->GetField(9,10) );        if( !EQUAL(szValType,"  ") )        {            char        *pszProcessedValue;            if( poReader->ProcessAttValue(szValType,                                          papoGroup[0]->GetField(11,16),                                          NULL, &pszProcessedValue, NULL ) )                poFeature->SetField(szValType, pszProcessedValue);        }        if( !EQUAL(papoGroup[0]->GetField(17,20),"    ") )        {            poFeature->SetField("FEAT_CODE",papoGroup[0]->GetField(17,20));        }    }    return poFeature;}/************************************************************************//*                        TranslateGenericPoly()                        *//************************************************************************/static OGRFeature *TranslateGenericPoly( NTFFileReader *poReader,                                         OGRNTFLayer *poLayer,                                         NTFRecord **papoGroup ){/* ==================================================================== *//*      Traditional POLYGON record groups.                              *//* ==================================================================== */    if( CSLCount((char **) papoGroup) >= 2         && papoGroup[0]->GetType() == NRT_POLYGON        && papoGroup[1]->GetType() == NRT_CHAIN )    {        OGRFeature      *poFeature = new OGRFeature( poLayer->GetLayerDefn() );        // POLY_ID        poFeature->SetField( 0, atoi(papoGroup[0]->GetField( 3, 8 )) );        // NUM_PARTS        int             nNumLinks = atoi(papoGroup[1]->GetField( 9, 12 ));            if( nNumLinks > MAX_LINK )        {            CPLError( CE_Failure, CPLE_AppDefined,                       "MAX_LINK exceeded in ntf_generic.cpp." );            return poFeature;        }            poFeature->SetField( "NUM_PARTS", nNumLinks );        // DIR        int             i, anList[MAX_LINK];        for( i = 0; i < nNumLinks; i++ )            anList[i] = atoi(papoGroup[1]->GetField( 19+i*7, 19+i*7 ));        poFeature->SetField( "DIR", nNumLinks, anList );        // GEOM_ID_OF_LINK        for( i = 0; i < nNumLinks; i++ )            anList[i] = atoi(papoGroup[1]->GetField( 13+i*7, 18+i*7 ));        poFeature->SetField( "GEOM_ID_OF_LINK", nNumLinks, anList );        // RingStart        int     nRingList = 0;        poFeature->SetField( "RingStart", 1, &nRingList );        // ATTREC Attributes        AddGenericAttributes( poReader, papoGroup, poFeature );        // Read point geometry        if( papoGroup[2] != NULL            && (papoGroup[2]->GetType() == NRT_GEOMETRY                || papoGroup[2]->GetType() == NRT_GEOMETRY3D) )        {            poFeature->SetGeometryDirectly(                poReader->ProcessGeometry(papoGroup[2]));            poFeature->SetField( "GEOM_ID", papoGroup[2]->GetField(3,8) );        }        return poFeature;    }    return NULL;}/************************************************************************//*                       TranslateGenericCPoly()                        *//************************************************************************/static OGRFeature *TranslateGenericCPoly( NTFFileReader *poReader,                                          OGRNTFLayer *poLayer,                                          NTFRecord **papoGroup ){/* -------------------------------------------------------------------- *//*      First we do validation of the grouping.                         *//* -------------------------------------------------------------------- */    if( papoGroup[0]->GetType() != NRT_CPOLY )        return NULL;        if( papoGroup[1] == NULL ||         (papoGroup[1]->GetType() != NRT_GEOMETRY          && papoGroup[1]->GetType() != NRT_GEOMETRY3D) )         return NULL;        if( papoGroup[1] != NULL         && papoGroup[2]->GetType() != NRT_ATTREC )        return NULL;/* -------------------------------------------------------------------- *//*      collect information for whole complex polygon.                  *//* -------------------------------------------------------------------- */    OGRFeature  *poFeature = new OGRFeature( poLayer->GetLayerDefn() );    // CPOLY_ID    poFeature->SetField( "CPOLY_ID", atoi(papoGroup[0]->GetField( 3, 8 )) );        // ATTREC Attributes    AddGenericAttributes( poReader, papoGroup, poFeature );        // Read point geometry    if( papoGroup[1] != NULL         && (papoGroup[1]->GetType() == NRT_GEOMETRY            || papoGroup[1]->GetType() == NRT_GEOMETRY3D) )    {        poFeature->SetGeometryDirectly(            poReader->ProcessGeometry(papoGroup[1]));        poFeature->SetField( "GEOM_ID",                              atoi(papoGroup[1]->GetField(3,8)) );    }    /* -------------------------------------------------------------------- *//*      Collect the chains for each of the rings, and just aggregate    *//*      these into the master list without any concept of where the     *//*      boundaries are.  The boundary information will be emmitted      *//*      in the RingStart field.                                         *//* -------------------------------------------------------------------- */    int         nNumLink = 0, iLink;    int         anPolyId[MAX_LINK*2];    nNumLink = atoi(papoGroup[0]->GetField(9,12));    for( iLink = 0; iLink < nNumLink; iLink++ )    {        anPolyId[iLink] = atoi(papoGroup[0]->GetField(13 + iLink*7,                                                      18 + iLink*7));    }    // NUM_PARTS    poFeature->SetField( "NUM_PARTS", nNumLink );    // POLY_ID    poFeature->SetField( "POLY_ID", nNumLink, anPolyId );    return poFeature;}/************************************************************************//*                       EstablishGenericLayers()                       *//************************************************************************/void OGRNTFDataSource::EstablishGenericLayers(){    int         iType;    /* -------------------------------------------------------------------- *//*      Pick an initial NTFFileReader to build the layers against.      *//* -------------------------------------------------------------------- */    for( int iFile = 0; iFile < nNTFFileCount; iFile++ )    {        NTFFileReader   *poPReader = NULL;        int             n3DFlag = 0;                poPReader = papoNTFFileReader[iFile];        if( poPReader->GetProductId() != NPC_UNKNOWN )            continue;/* -------------------------------------------------------------------- *//*      If any of the generic classes are 3D, then assume all our       *//*      geometry should be marked as 3D.                                *//* -------------------------------------------------------------------- */        for( iType = 0; iType < 99; iType++ )        {            NTFGenericClass     *poClass = aoGenericClass + iType;                    if( poClass->nFeatureCount > 0 && poClass->b3D )                n3DFlag = wkb25DBit;        }        /* -------------------------------------------------------------------- *//*      Create layers for all recognised layer types with features.     *//* -------------------------------------------------------------------- */        for( iType = 0; iType < 99; iType++ )        {            NTFGenericClass     *poClass = aoGenericClass + iType;                    if( poClass->nFeatureCount == 0 )                continue;            if( iType == NRT_POINTREC )            {                poPReader->                    EstablishLayer( "GENERIC_POINT",                                     (OGRwkbGeometryType) (wkbPoint | n3DFlag),                                    TranslateGenericPoint,                                    NRT_POINTREC, poClass,                                    "POINT_ID", OFTInteger, 6, 0,                                    NULL );            }            else if( iType == NRT_LINEREC )            {                poPReader->                    EstablishLayer( "GENERIC_LINE",                                     (OGRwkbGeometryType)                                     (wkbLineString | n3DFlag),                                    TranslateGenericLine,                                    NRT_LINEREC, poClass,                                    "LINE_ID", OFTInteger, 6, 0,                                    NULL );            }            else if( iType == NRT_TEXTREC )            {                poPReader->                    EstablishLayer( "GENERIC_TEXT",                                     (OGRwkbGeometryType)                                     (wkbPoint | n3DFlag),                                    TranslateGenericText,                                    NRT_TEXTREC, poClass,                                    "TEXT_ID", OFTInteger, 6, 0,                                    NULL );            }            else if( iType == NRT_NAMEREC )            {                poPReader->                    EstablishLayer( "GENERIC_NAME",                                     (OGRwkbGeometryType)                                     (wkbPoint | n3DFlag),                                    TranslateGenericName,                                    NRT_NAMEREC, poClass,                                    "NAME_ID", OFTInteger, 6, 0,                                    NULL );            }            else if( iType == NRT_NODEREC )            {                poPReader->                    EstablishLayer( "GENERIC_NODE",                                    (OGRwkbGeometryType)                                     (wkbPoint | n3DFlag),                                    TranslateGenericNode,                                    NRT_NODEREC, poClass,                                    "NODE_ID", OFTInteger, 6, 0,                                    "NUM_LINKS", OFTInteger, 4, 0,                                    "GEOM_ID_OF_LINK", OFTIntegerList, 6, 0,                                    "DIR", OFTIntegerList, 1, 0,                                    NULL );            }            else if( iType == NRT_COLLECT )            {                poPReader->                    EstablishLayer( "GENERIC_COLLECTION", wkbNone,                                    TranslateGenericCollection,                                    NRT_COLLECT, poClass,                                    "COLL_ID", OFTInteger, 6, 0,                                    "NUM_PARTS", OFTInteger, 4, 0,                                    "TYPE", OFTIntegerList, 2, 0,                                    "ID", OFTIntegerList, 6, 0,                                    NULL );            }            else if( iType == NRT_POLYGON )            {                poPReader->                    EstablishLayer( "GENERIC_POLY",                                     (OGRwkbGeometryType) (wkbPoint | n3DFlag),                                    TranslateGenericPoly,                                    NRT_POLYGON, poClass,                                    "POLY_ID", OFTInteger, 6, 0,                                    "NUM_PARTS", OFTInteger, 4, 0,                                     "DIR", OFTIntegerList, 1, 0,                                    "GEOM_ID_OF_LINK", OFTIntegerList, 6, 0,                                    "RingStart", OFTIntegerList, 6, 0,                                    NULL );            }            else if( iType == NRT_CPOLY )            {                poPReader->                    EstablishLayer( "GENERIC_CPOLY",                                     (OGRwkbGeometryType) (wkbPoint | n3DFlag),                                    TranslateGenericCPoly,                                    NRT_CPOLY, poClass,                                    "CPOLY_ID", OFTInteger, 6, 0,                                    "NUM_PARTS", OFTInteger, 4, 0,                                     "POLY_ID", OFTIntegerList, 1, 0,                                    NULL );            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -