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


C++ OGRLayer::GetName方法代码示例

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


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

示例1: DeleteLayer

OGRErr GNMDatabaseNetwork::DeleteLayer(int nIndex)
{
    if(NULL == m_poDS)
    {
        CPLError(CE_Failure, CPLE_FileIO, "Network not opened." );
        return OGRERR_FAILURE;
    }

    OGRLayer* poNetworkLayer = GetLayer(nIndex);

    CPLDebug("GNM", "Delete network layer '%s'", poNetworkLayer->GetName());

    int nDeleteIndex = -1;
    for(int i = 0; i < m_poDS->GetLayerCount(); ++i)
    {
        OGRLayer* poLayer = m_poDS->GetLayer(i);
        if(EQUAL(poNetworkLayer->GetName(), poLayer->GetName()))
        {
            nDeleteIndex = i;
            break;
        }
    }

    if(m_poDS->DeleteLayer(nDeleteIndex) != OGRERR_NONE)
    {
        return OGRERR_FAILURE;
    }

    return GNMGenericNetwork::DeleteLayer(nIndex);
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:30,代码来源:gnmdbnetwork.cpp

示例2: CheckNetworkExist

int GNMDatabaseNetwork::CheckNetworkExist(const char *pszFilename, char **papszOptions)
{
    // check if path exist
    // if path exist check if network already present and OVERWRITE option
    // else create the path

    if(FormName(pszFilename, papszOptions) != CE_None)
    {
        return TRUE;
    }

    if(NULL == m_poDS)
    {
        m_poDS = (GDALDataset*) GDALOpenEx( m_soNetworkFullName, GDAL_OF_VECTOR |
                                      GDAL_OF_UPDATE, NULL, NULL, papszOptions );
    }

    const bool bOverwrite = CPLFetchBool(papszOptions, "OVERWRITE", false);

    std::vector<int> anDeleteLayers;
    int i;
    for(i = 0; i < m_poDS->GetLayerCount(); ++i)
    {
        OGRLayer* poLayer = m_poDS->GetLayer(i);
        if(NULL == poLayer)
            continue;

        if(EQUAL(poLayer->GetName(), GNM_SYSLAYER_META) ||
           EQUAL(poLayer->GetName(), GNM_SYSLAYER_GRAPH) ||
           EQUAL(poLayer->GetName(), GNM_SYSLAYER_FEATURES) )
        {
            anDeleteLayers.push_back(i);
        }
    }

    if(anDeleteLayers.empty())
        return FALSE;

    if( bOverwrite )
    {
        for(i = (int)anDeleteLayers.size(); i > 0; i--)
        {
            CPLDebug("GNM", "Delete layer: %d", i);
            if(m_poDS->DeleteLayer(anDeleteLayers[i - 1]) != OGRERR_NONE)
                return TRUE;
        }
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:53,代码来源:gnmdbnetwork.cpp

示例3: main

//#include "s57.h"
int main(int argc, char **argv)

{
    OGRRegisterAll();

    OGRDataSource       *poDS;
    printf("Opening %s\n",argv[1]);
    poDS = OGRSFDriverRegistrar::Open( argv[1], FALSE );
    if( poDS == NULL )
    {
        printf( "Open failed.\n" );
        exit( 1 );
    }

    OGRLayer  *poLayer;
    int layers = poDS->GetLayerCount();
    for (int layer =0 ; layer< layers; layer++) {
        poLayer = poDS->GetLayer(layer);
        if (poLayer == NULL) continue;
        printf("%d, %s, %s",layer, poLayer->GetName(), OGRGeometryTypeToName(poLayer->GetGeomType()));
        poLayer->ResetReading();
        OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();  
        int iField;
        for( iField = 0; iField < poFDefn->GetFieldCount(); iField++ )
        {
            OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn( iField );
            printf(", %s",poFieldDefn->GetNameRef());
        }
        printf("\n");
    }

}
开发者ID:dvj,项目名称:dnc2enc,代码行数:33,代码来源:util.cpp

示例4: OGRMDBLayer

OGRLayer *OGRMDBDataSource::GetLayerByName( const char* pszName )

{
    if (pszName == NULL)
        return NULL;
    OGRLayer* poLayer = OGRDataSource::GetLayerByName(pszName);
    if (poLayer)
        return poLayer;

    for( int i = 0; i < nLayersWithInvisible; i++ )
    {
        poLayer = papoLayersInvisible[i];

        if( strcmp( pszName, poLayer->GetName() ) == 0 )
            return poLayer;
    }

    OGRMDBTable* poTable = poDB->GetTable(pszName);
    if (poTable == NULL)
        return NULL;

    OGRMDBLayer* poMDBLayer = new OGRMDBLayer( this, poTable );
    if( poMDBLayer->BuildFeatureDefn() != CE_None )
    {
        delete poMDBLayer;
        return NULL;
    }

    papoLayersInvisible = (OGRMDBLayer**)CPLRealloc(papoLayersInvisible,
                            (nLayersWithInvisible+1) * sizeof(OGRMDBLayer*));
    papoLayersInvisible[nLayersWithInvisible++] = poMDBLayer;

    return poMDBLayer;
}
开发者ID:0004c,项目名称:node-gdal,代码行数:34,代码来源:ogrmdbdatasource.cpp

示例5: OGRGeomediaTableLayer

OGRLayer *OGRGeomediaDataSource::GetLayerByName( const char* pszName )

{
    if (pszName == NULL)
        return NULL;
    OGRLayer* poLayer = OGRDataSource::GetLayerByName(pszName);
    if (poLayer)
        return poLayer;

    for( int i = 0; i < nLayersWithInvisible; i++ )
    {
        poLayer = papoLayersInvisible[i];

        if( strcmp( pszName, poLayer->GetName() ) == 0 )
            return poLayer;
    }

    OGRGeomediaTableLayer  *poGeomediaLayer;

    poGeomediaLayer = new OGRGeomediaTableLayer( this );

    if( poGeomediaLayer->Initialize(pszName, NULL, NULL) != CE_None )
    {
        delete poGeomediaLayer;
        return NULL;
    }

    papoLayersInvisible = (OGRGeomediaLayer**)CPLRealloc(papoLayersInvisible,
                            (nLayersWithInvisible+1) * sizeof(OGRGeomediaLayer*));
    papoLayersInvisible[nLayersWithInvisible++] = poGeomediaLayer;

    return poGeomediaLayer;
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:33,代码来源:ogrgeomediadatasource.cpp

示例6: getLayerInfo

bool NgwGdalIo::getLayerInfo (NgwLayerInfo &layer_info, QString base_url, int resource_id)
{
    GDALDatasetPtr dataset_p;
    u_openDataset(dataset_p, base_url, resource_id, true);
    if (dataset_p.data() == NULL)
    {
        error = QObject::tr("Unable to open NGW dataset via GDAL");
        return false;
    }

    OGRLayer *layer = dataset_p.data()->GetLayer(0);
    if (layer == NULL)
    {
        error = QObject::tr("Unable to open [0] layer of NGW dataset via GDAL");
        return false;
    }

    OGRFeatureDefn *layer_defn = layer->GetLayerDefn();

    layer_info.name = layer->GetName();
    layer_info.geom_type = Core::g_findGeomTypeNgw(layer->GetGeomType());
    for (int i = 0; i < layer_defn->GetFieldCount(); i++)
    {
        QString s_field_alias = QString("FIELD_%1_ALIAS").arg(i);
        QString alias = layer->GetMetadataItem(s_field_alias.toUtf8().data());

        OGRFieldDefn *field_defn = layer_defn->GetFieldDefn(i);
        layer_info.fields.append({field_defn->GetNameRef(), alias,
                                  Core::g_findFieldTypeNgw(field_defn->GetType())});
    }

    return true;
}
开发者ID:nextgis,项目名称:formbuilder,代码行数:33,代码来源:ngw_gdal_io.cpp

示例7: import_shapefile

OGRLayer* import_shapefile(string shapefile_name, int layer_number) {
    OGRRegisterAll();
    OGRDataSource *poDS;

    poDS = OGRSFDriverRegistrar::Open( shapefile_name.c_str(), FALSE );
    if( poDS == NULL ) { cerr << "Failed to open shapefile" << endl; exit( 1 ); }

    OGRLayer* poLayer = poDS->GetLayer(layer_number);
    cerr << "Shapefile layer name: " << poLayer->GetName() << endl;

//    char* proj[255];
//    poLayer->GetSpatialRef()->exportToWkt(proj);
//    cerr << "Shapefile projection: " << *proj << endl; 

    return poLayer;
}
开发者ID:PulliamLab-UFL,项目名称:dengue,代码行数:16,代码来源:clip_raster_by_region.cpp

示例8: oSpaRef

OGRLayer *GNMDatabaseNetwork::ICreateLayer(const char *pszName,
                                CPL_UNUSED OGRSpatialReference *poSpatialRef,
                                OGRwkbGeometryType eGType, char **papszOptions)
{
    //check if layer with such name exist
    for(int i = 0; i < GetLayerCount(); ++i)
    {
        OGRLayer* pLayer = GetLayer(i);
        if(NULL == pLayer)
            continue;
        if(EQUAL(pLayer->GetName(), pszName))
        {
            CPLError( CE_Failure, CPLE_IllegalArg,
                      "The network layer '%s' already exist.", pszName );
            return NULL;
        }
    }

    OGRSpatialReference oSpaRef(m_soSRS);

    OGRLayer *poLayer = m_poDS->CreateLayer( pszName, &oSpaRef, eGType, papszOptions );
    if( poLayer == NULL )
    {
        CPLError( CE_Failure, CPLE_FileIO, "Layer creation failed." );
        return NULL;
    }

    OGRFieldDefn oField( GNM_SYSFIELD_GFID, GNMGFIDInt );
    if( poLayer->CreateField( &oField ) != OGRERR_NONE )
    {
        CPLError( CE_Failure, CPLE_FileIO, "Creating global identificator field failed." );
        return NULL;
    }


    OGRFieldDefn oFieldBlock(GNM_SYSFIELD_BLOCKED, OFTInteger);
    if( poLayer->CreateField( &oFieldBlock ) != OGRERR_NONE )
    {
        CPLError( CE_Failure, CPLE_FileIO, "Creating is blocking field failed." );
        return NULL;
    }

    GNMGenericLayer* pGNMLayer = new GNMGenericLayer(poLayer, this);
    m_apoLayers.push_back(pGNMLayer);
    return pGNMLayer;
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:46,代码来源:gnmdbnetwork.cpp

示例9: _getLayerByName

OGRLayer* OgrWriter::_getLayerByName(const QString layerName)
{
  // Check if the layer exists in the output.
  int layerCount = _ds->GetLayerCount();
  for (int i = 0; i < layerCount; i++)
  {
    OGRLayer* layer = _ds->GetLayer(i+1);
    if (layer != NULL)
    {
      QString tmpLayerName = QString(layer->GetName());
      if (tmpLayerName == layerName)
      {
        return layer;
      }
    }
  }
  return NULL;
}
开发者ID:digideskio,项目名称:hootenanny,代码行数:18,代码来源:OgrWriter.cpp

示例10: DeleteLayerByName

CPLErr GNMDatabaseNetwork::DeleteLayerByName(const char* pszLayerName)
{
    if(NULL == m_poDS)
        return CE_Failure;

    for(int i = 0; i < m_poDS->GetLayerCount(); ++i)
    {
        OGRLayer* poLayer = m_poDS->GetLayer(i);
        if(NULL == poLayer)
            continue;

        if(EQUAL(poLayer->GetName(), pszLayerName))
            return m_poDS->DeleteLayer(i) == OGRERR_NONE ? CE_None : CE_Failure;
    }

    CPLError(CE_Failure, CPLE_IllegalArg, "The layer %s not exist",
             pszLayerName );
    return CE_Failure;
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:19,代码来源:gnmdbnetwork.cpp

示例11: GetLayer

OGRErr      OGRDataSourceWithTransaction::DeleteLayer(int iIndex)
{
    if( !m_poBaseDataSource ) return OGRERR_FAILURE;
    OGRLayer* poLayer = GetLayer(iIndex);
    CPLString osName;
    if( poLayer )
        osName = poLayer->GetName();
    OGRErr eErr = m_poBaseDataSource->DeleteLayer(iIndex);
    if( eErr == OGRERR_NONE && osName.size())
    {
        std::map<CPLString, OGRLayerWithTransaction*>::iterator oIter = m_oMapLayers.find(osName);
        if(oIter != m_oMapLayers.end())
        {
            delete oIter->second;
            m_oSetLayers.erase(oIter->second);
            m_oMapLayers.erase(oIter);
        }
    }
    return eErr;
}
开发者ID:miccferr,项目名称:wmshp-electron,代码行数:20,代码来源:ogremulatedtransaction.cpp

示例12: LoadNetworkLayer

CPLErr GNMFileNetwork::LoadNetworkLayer(const char *pszLayername)
{
    // check if not loaded
    for(size_t i = 0; i < m_apoLayers.size(); ++i)
    {
        if(EQUAL(m_apoLayers[i]->GetName(), pszLayername))
            return CE_None;
    }

    const char* pszExt = m_poLayerDriver->GetMetadataItem(GDAL_DMD_EXTENSION);

    CPLString soFile = CPLFormFilename(m_soNetworkFullName, pszLayername, pszExt);
    GDALDataset *poDS = (GDALDataset*) GDALOpenEx( soFile, GDAL_OF_VECTOR |
                                            GDAL_OF_UPDATE, NULL, NULL, NULL );
    if( NULL == poDS )
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "Open '%s' file failed",
                  soFile.c_str() );
        return CE_Failure;
    }

    OGRLayer* poLayer = poDS->GetLayer(0);
    if(NULL == poLayer)
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "Layer '%s' is not exist",
                  pszLayername );
        return CE_Failure;
    }

    CPLDebug("GNM", "Layer '%s' loaded", poLayer->GetName());

    GNMGenericLayer* pGNMLayer = new GNMGenericLayer(poLayer, this);
    m_apoLayers.push_back(pGNMLayer);
    m_mpLayerDatasetMap[pGNMLayer] = poDS;

    return CE_None;
}
开发者ID:garnertb,项目名称:gdal,代码行数:37,代码来源:gnmfilenetwork.cpp

示例13: DeleteLayer

OGRErr GNMFileNetwork::DeleteLayer(int nIndex)
{
    OGRLayer* pLayer = GetLayer(nIndex);

    GDALDataset* poDS = m_mpLayerDatasetMap[pLayer];
    if(NULL == poDS)
    {
        return OGRERR_FAILURE;
    }

    CPLDebug("GNM", "Delete network layer '%s'", pLayer->GetName());

    if(poDS->DeleteLayer(0) != OGRERR_NONE)
    {
        return OGRERR_FAILURE;
    }

    GDALClose(poDS);

    // remove pointer from map
    m_mpLayerDatasetMap.erase(pLayer);

    return GNMGenericNetwork::DeleteLayer(nIndex);
}
开发者ID:garnertb,项目名称:gdal,代码行数:24,代码来源:gnmfilenetwork.cpp

示例14: LoadNetworkLayer

CPLErr GNMDatabaseNetwork::LoadNetworkLayer(const char *pszLayername)
{
    // check if not loaded
    for(size_t i = 0; i < m_apoLayers.size(); ++i)
    {
        if(EQUAL(m_apoLayers[i]->GetName(), pszLayername))
            return CE_None;
    }

    OGRLayer* poLayer = m_poDS->GetLayerByName(pszLayername);
    if(NULL == poLayer)
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "Layer '%s' is not exist",
                  pszLayername );
        return CE_Failure;
    }

    CPLDebug("GNM", "Layer '%s' loaded", poLayer->GetName());

    GNMGenericLayer* pGNMLayer = new GNMGenericLayer(poLayer, this);
    m_apoLayers.push_back(pGNMLayer);

    return CE_None;
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:24,代码来源:gnmdbnetwork.cpp

示例15: main


//.........这里部分代码省略.........
    if( pszDataSource == NULL )
        Usage();

/* -------------------------------------------------------------------- */
/*      Open data source.                                               */
/* -------------------------------------------------------------------- */
    OGRDataSource       *poDS = NULL;
    OGRSFDriver         *poDriver = NULL;

    poDS = OGRSFDriverRegistrar::Open( pszDataSource, !bReadOnly, &poDriver );
    if( poDS == NULL && !bReadOnly )
    {
        poDS = OGRSFDriverRegistrar::Open( pszDataSource, FALSE, &poDriver );
        if( poDS != NULL && bVerbose )
        {
            printf( "Had to open data source read-only.\n" );
            bReadOnly = TRUE;
        }
    }

/* -------------------------------------------------------------------- */
/*      Report failure                                                  */
/* -------------------------------------------------------------------- */
    if( poDS == NULL )
    {
        OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
        
        printf( "FAILURE:\n"
                "Unable to open datasource `%s' with the following drivers.\n",
                pszDataSource );

        for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
        {
            printf( "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
        }

        nRet = 1;
        goto end;
    }

    CPLAssert( poDriver != NULL);

/* -------------------------------------------------------------------- */
/*      Some information messages.                                      */
/* -------------------------------------------------------------------- */
    if( bVerbose )
        printf( "INFO: Open of `%s'\n"
                "      using driver `%s' successful.\n",
                pszDataSource, poDriver->GetName() );

    if( bVerbose && !EQUAL(pszDataSource,poDS->GetName()) )
    {
        printf( "INFO: Internal data source name `%s'\n"
                "      different from user name `%s'.\n",
                poDS->GetName(), pszDataSource );
    }

/* -------------------------------------------------------------------- */
/*      Special case for -sql clause.  No source layers required.       */
/* -------------------------------------------------------------------- */
    if( pszSQLStatement != NULL )
    {
        OGRLayer *poResultSet = NULL;

        nRepeatCount = 0;  // skip layer reporting.
开发者ID:,项目名称:,代码行数:66,代码来源:


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