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

📄 ogrtigerdatasource.cpp

📁 支持各种栅格图像和矢量图像读取的库
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/************************************************************************/const char *OGRTigerDataSource::GetOption( const char * pszOption ){    return CSLFetchNameValue( papszOptions, pszOption );}/************************************************************************//*                             GetModule()                              *//************************************************************************/const char *OGRTigerDataSource::GetModule( int iModule ){    if( iModule < 0 || iModule >= nModules )        return NULL;    else        return papszModules[iModule];}/************************************************************************//*                            CheckModule()                             *//*                                                                      *//*      This is used by the writer to check if this module has been     *//*      written to before.                                              *//************************************************************************/int OGRTigerDataSource::CheckModule( const char *pszModule ){    int         i;    for( i = 0; i < nModules; i++ )    {        if( EQUAL(pszModule,papszModules[i]) )            return TRUE;    }    return FALSE;}/************************************************************************//*                             AddModule()                              *//************************************************************************/void OGRTigerDataSource::AddModule( const char *pszModule ){    if( CheckModule( pszModule ) )        return;    papszModules = CSLAddString( papszModules, pszModule );    nModules++;}/************************************************************************//*                           BuildFilename()                            *//************************************************************************/char *OGRTigerDataSource::BuildFilename( const char *pszModuleName,                                    const char *pszExtension ){    char        *pszFilename;    char        szLCExtension[3];/* -------------------------------------------------------------------- *//*      Force the record type to lower case if the filename appears     *//*      to be in lower case.                                            *//* -------------------------------------------------------------------- */    if( *pszExtension >= 'A' && *pszExtension <= 'Z' && *pszModuleName == 't' )    {        szLCExtension[0] = (*pszExtension) + 'a' - 'A';        szLCExtension[1] = '\0';        pszExtension = szLCExtension;    }/* -------------------------------------------------------------------- *//*      Build the filename.                                             *//* -------------------------------------------------------------------- */    pszFilename = (char *) CPLMalloc(strlen(GetDirPath())                                     + strlen(pszModuleName)                                     + strlen(pszExtension) + 10);    if( strlen(GetDirPath()) == 0 )        sprintf( pszFilename, "%s%s",                 pszModuleName, pszExtension );    else        sprintf( pszFilename, "%s/%s%s",                 GetDirPath(), pszModuleName, pszExtension );    return pszFilename;}/************************************************************************//*                           TestCapability()                           *//************************************************************************/int OGRTigerDataSource::TestCapability( const char *pszCap ){    if( EQUAL(pszCap,ODsCCreateLayer) )        return GetWriteMode();    else        return FALSE;}/************************************************************************//*                               Create()                               *//************************************************************************/int OGRTigerDataSource::Create( const char *pszNameIn, char **papszOptions ){    VSIStatBuf      stat;    /* -------------------------------------------------------------------- *//*      Try to create directory if it doesn't already exist.            *//* -------------------------------------------------------------------- */    if( CPLStat( pszNameIn, &stat ) != 0 )    {        VSIMkdir( pszNameIn, 0755 );    }    if( CPLStat( pszNameIn, &stat ) != 0 || !VSI_ISDIR(stat.st_mode) )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "%s is not a directory, nor can be directly created as one.",                  pszName );        return FALSE;    }/* -------------------------------------------------------------------- *//*      Store various information.                                      *//* -------------------------------------------------------------------- */    pszPath = CPLStrdup( pszNameIn );    pszName = CPLStrdup( pszNameIn );    bWriteMode = TRUE;    SetOptionList( papszOptions );/* -------------------------------------------------------------------- *//*      Work out the version.                                           *//* -------------------------------------------------------------------- *///    nVersionCode = 1000; /* census 2000 */    nVersionCode = 1002; /* census 2002 */    if( GetOption("VERSION") != NULL )    {        nVersionCode = atoi(GetOption("VERSION"));        nVersionCode = MAX(0,MIN(9999,nVersionCode));    }    nVersion = TigerClassifyVersion(nVersionCode);    return TRUE;}/************************************************************************//*                            CreateLayer()                             *//************************************************************************/OGRLayer *OGRTigerDataSource::CreateLayer( const char *pszLayerName,                                            OGRSpatialReference *poSpatRef,                                            OGRwkbGeometryType eGType,                                            char **papszOptions ){    OGRTigerLayer       *poLayer = NULL;    if( GetLayer( pszLayerName ) != NULL )        return GetLayer( pszLayerName );    if( poSpatRef != NULL &&         (!poSpatRef->IsGeographic()          || !EQUAL(poSpatRef->GetAttrValue("DATUM"),                   "North_American_Datum_1983")) )    {        CPLError( CE_Warning, CPLE_AppDefined,                   "Requested coordinate system wrong for Tiger, "                   "forcing to GEOGCS NAD83." );    }    if( EQUAL(pszLayerName,"PIP") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerPIP( this, NULL ) );    }    else if( EQUAL(pszLayerName,"ZipPlus4") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerZipPlus4( this, NULL ) );    }    else if( EQUAL(pszLayerName,"TLIDRange") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerTLIDRange( this, NULL ) );    }    else if( EQUAL(pszLayerName,"PolyChainLink") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerPolyChainLink( this, NULL ) );    }    else if( EQUAL(pszLayerName,"CompleteChain") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerCompleteChain( this, NULL ) );    }    else if( EQUAL(pszLayerName,"AltName") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerAltName( this, NULL ) );    }    else if( EQUAL(pszLayerName,"FeatureIds") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerFeatureIds( this, NULL ) );    }    else if( EQUAL(pszLayerName,"ZipCodes") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerZipCodes( this, NULL ) );    }    else if( EQUAL(pszLayerName,"Landmarks") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerLandmarks( this, NULL ) );    }    else if( EQUAL(pszLayerName,"AreaLandmarks") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerAreaLandmarks( this, NULL ) );    }    else if( EQUAL(pszLayerName,"KeyFeatures") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerKeyFeatures( this, NULL ) );    }    else if( EQUAL(pszLayerName,"EntityNames") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerEntityNames( this, NULL ) );    }    else if( EQUAL(pszLayerName,"IDHistory") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerIDHistory( this, NULL ) );    }    else if( EQUAL(pszLayerName,"Polygon") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerPolygon( this, NULL ) );    }    else if( EQUAL(pszLayerName,"PolygonCorrections") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerPolygonCorrections( this, NULL ) );    }    else if( EQUAL(pszLayerName,"PolygonEconomic") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerPolygonEconomic( this, NULL ) );    }    else if( EQUAL(pszLayerName,"SpatialMetadata") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerSpatialMetadata( this, NULL ) );    }    else if( EQUAL(pszLayerName,"ZeroCellID") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerZeroCellID( this, NULL ) );    }    else if( EQUAL(pszLayerName,"OverUnder") )    {        poLayer = new OGRTigerLayer( this,                                     new TigerOverUnder( this, NULL ) );    }    if( poLayer == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "Unable to create layer %s, not a known TIGER/Line layer.",                  pszLayerName );    }    else        AddLayer( poLayer );    return poLayer;}/************************************************************************//*                         DeleteModuleFiles()                          *//************************************************************************/void OGRTigerDataSource::DeleteModuleFiles( const char *pszModule ){    char        **papszDirFiles = CPLReadDir( GetDirPath() );    int         i, nCount = CSLCount(papszDirFiles);        for( i = 0; i < nCount; i++ )    {        if( EQUALN(pszModule,papszDirFiles[i],strlen(pszModule)) )        {            const char  *pszFilename;            pszFilename = CPLFormFilename( GetDirPath(),                                            papszDirFiles[i],                                            NULL );            if( VSIUnlink( pszFilename ) != 0 )            {                CPLDebug( "OGR_TIGER", "Failed to unlink %s", pszFilename );            }        }    }    CSLDestroy( papszDirFiles );}

⌨️ 快捷键说明

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