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


C++ OGRRegisterAll函数代码示例

本文整理汇总了C++中OGRRegisterAll函数的典型用法代码示例。如果您正苦于以下问题:C++ OGRRegisterAll函数的具体用法?C++ OGRRegisterAll怎么用?C++ OGRRegisterAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

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

示例2: setlocale

bool MyApp::OnInit()
{
#ifdef __LINUX__
setlocale (LC_ALL,"POSIX");
#endif

 register_all_file_formats();
#if GILVIEWER_USE_GDAL
    OGRRegisterAll();
#endif // GILVIEWER_USE_GDAL
	try
	{
		if ( InitFrame() )
			m_mainFrameDock->Show();
		else
			exit(0);


	}
	catch( std::exception &e )
	{
		wxString message;
		message << wxString(e.what(), *wxConvCurrent);
		wxMessageBox( message );
	}
	catch( ... )
	{
		wxMessageBox( _("Unhandled exception ...") );
	}

	return true;
}
开发者ID:ew1773,项目名称:fullanalyze,代码行数:32,代码来源:FullAnalyze.cpp

示例3: createDatabaseURI

void QgsNewOgrConnection::testConnection()
{
  QString uri;
  uri = createDatabaseURI( cmbDatabaseTypes->currentText(),
                           txtHost->text(),
                           txtDatabase->text(),
                           txtPort->text(),
                           mAuthSettingsDatabase->configId(),
                           mAuthSettingsDatabase->username(),
                           mAuthSettingsDatabase->password(),
                           true );
  QgsDebugMsg( "Connecting using uri = " + uri );
  OGRRegisterAll();
  OGRDataSourceH       poDS;
  OGRSFDriverH         pahDriver;
  CPLErrorReset();
  poDS = OGROpen( uri.toUtf8().constData(), false, &pahDriver );
  if ( !poDS )
  {
    QMessageBox::information( this, tr( "Test Connection" ), tr( "Connection failed - Check settings and try again.\n\nExtended error information:\n%1" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
  }
  else
  {
    QMessageBox::information( this, tr( "Test Connection" ), tr( "Connection to %1 was successful." ).arg( uri ) );
    OGRReleaseDataSource( poDS );
  }
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:27,代码来源:qgsnewogrconnection.cpp

示例4: OGRRegisterAll

void QgsApplication::registerOgrDrivers()
{
  if ( 0 >= OGRGetDriverCount() )
  {
    OGRRegisterAll();
  }
}
开发者ID:brushtyler,项目名称:Quantum-GIS,代码行数:7,代码来源:qgsapplication.cpp

示例5: database

/*!
  \brief Open database (OGR datasource)

  \param handle pointer to dbHandle (db name and schema)

  \return DB_OK on success
  \return DB_FAILED on failure
*/
int db__driver_open_database(dbHandle * handle)
{
    const char *name;
    dbConnection connection;

    init_error();
    db_get_connection(&connection);
    name = db_get_handle_dbname(handle);

    /* if name is empty use connection.databaseName */
    if (strlen(name) == 0)
	name = connection.databaseName;

    G_debug(3, "db_driver_open_database() name = '%s'", name);

    OGRRegisterAll();

    hDs = OGROpen(name, TRUE, NULL);

    if (hDs == NULL) {
	append_error(_("Unable to open OGR data source"));
	report_error();
	return DB_FAILED;
    }

    G_debug(3, "Datasource opened");

    return DB_OK;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:37,代码来源:db.c

示例6: init_ogr

    void init_ogr(const std::string& outfile) {
        OGRRegisterAll();

        const char* driver_name = "SQLite";
        OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver_name);
        if (driver == NULL) {
            std::cerr << driver_name << " driver not available.\n";
            exit(1);
        }

        CPLSetConfigOption("OGR_SQLITE_SYNCHRONOUS", "FALSE");
        const char* options[] = { "SPATIALITE=TRUE", NULL };

        m_data_source = driver->CreateDataSource(outfile.c_str(), const_cast<char**>(options));
        if (m_data_source == NULL) {
            std::cerr << "Creation of output file failed.\n";
            exit(1);
        }

        m_layer_point   = init_layer("planet_osm_point",   m_fields_nodes, wkbPoint);
        m_layer_line    = init_layer("planet_osm_line",    m_fields_ways,  wkbLineString);
        m_layer_polygon = init_layer("planet_osm_polygon", m_fields_areas, wkbMultiPolygon);

        stringv fields_roads;
        fields_roads.push_back("railway");
        fields_roads.push_back("highway");
        fields_roads.push_back("boundary");
        m_layer_roads = init_layer("planet_osm_roads", fields_roads, wkbLineString);
    }
开发者ID:aidiandin,项目名称:hot-exports,代码行数:29,代码来源:cde.cpp

示例7: QgsDebugMsg

bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
{
  QgsDebugMsg( "mPath = " + mPath );
  OGRRegisterAll();
  OGRSFDriverH hDriver;
  OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver );

  if ( !hDataSource )
    return false;

  QString  driverName = OGR_Dr_GetName( hDriver );
  OGR_DS_Destroy( hDataSource );

  // we are able to assign CRS only to shapefiles :-(
  if ( driverName == "ESRI Shapefile" )
  {
    QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) );
    QString wkt = crs.toWkt();

    // save ordinary .prj file
    OGRSpatialReferenceH hSRS = OSRNewSpatialReference( wkt.toLocal8Bit().data() );
    OSRMorphToESRI( hSRS ); // this is the important stuff for shapefile .prj
    char* pszOutWkt = NULL;
    OSRExportToWkt( hSRS, &pszOutWkt );
    QFile prjFile( layerName + ".prj" );
    if ( prjFile.open( QIODevice::WriteOnly ) )
    {
      QTextStream prjStream( &prjFile );
      prjStream << pszOutWkt << endl;
      prjFile.close();
    }
    else
    {
      QgsMessageLog::logMessage( tr( "Couldn't open file %1.prj" ).arg( layerName ), tr( "OGR" ) );
      return false;
    }
    OSRDestroySpatialReference( hSRS );
    CPLFree( pszOutWkt );

    // save qgis-specific .qpj file (maybe because of better wkt compatibility?)
    QFile qpjFile( layerName + ".qpj" );
    if ( qpjFile.open( QIODevice::WriteOnly ) )
    {
      QTextStream qpjStream( &qpjFile );
      qpjStream << wkt.toLocal8Bit().data() << endl;
      qpjFile.close();
    }
    else
    {
      QgsMessageLog::logMessage( tr( "Couldn't open file %1.qpj" ).arg( layerName ), tr( "OGR" ) );
      return false;
    }

    return true;
  }

  // It it is impossible to assign a crs to an existing layer
  // No OGR_L_SetSpatialRef : http://trac.osgeo.org/gdal/ticket/4032
  return false;
}
开发者ID:LingboTang,项目名称:QGIS,代码行数:60,代码来源:qgsogrdataitems.cpp

示例8: OGRRegisterAll

void CShapefileLayer::OpenShapefile(const std::string& filename)
{
	m_FileName_ = filename;
	OGRRegisterAll();
	std::string pszDriverName = "ESRI Shapefile";
	//CPLSetConfigOption("SHAPE_ENCODING", "");				//支持中文

	OGRSFDriver* poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszDriverName.c_str());
	m_pDataSource_ = poDriver->Open(m_FileName_.c_str(), false);				//打开shapefile文件,获取数据源
	if(m_pDataSource_ == NULL)
	{
		m_bExistFile_ = false;
		return;
	}
	m_pLayer_ = m_pDataSource_->GetLayer(0);						//获取shapefile第0层
	if(m_pLayer_ == NULL)
	{
		m_bExistFile_ = false;
		return ;
	}
	int theFeatureCount = m_pLayer_->GetFeatureCount();				//层里面的数据数量
    OGRFeature *poFeature = NULL;									//读取的数据指针
	m_pLayer_->ResetReading();										//重新读取
	m_ShapefileType_ = m_pLayer_->GetLayerDefn()->GetGeomType();	//类型
	m_bExistFile_ = true;
}
开发者ID:vtronxy,项目名称:MapEngineES2.0,代码行数:26,代码来源:ShapefileLayer.cpp

示例9: load

/* From https://github.com/iamaleksey/iconverl/blob/master/c_src/iconverl.c */
static int
load(ErlNifEnv *env, void **priv, ERL_NIF_TERM load_info)
{
    OGRRegisterAll();

    OGR_DS_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_ds_resource", &datasource_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_F_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_f_resource", &feature_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_FD_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_fd_resource", &feature_defn_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_FLD_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_fld_resource", &field_defn_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_G_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_g_resource", &geometry_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_D_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_d_resource", NULL,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    OGR_L_RESOURCE = enif_open_resource_type(
        env, NULL, "ogr_l_resource", &layer_destroy,
        ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER, NULL);

    return 0;
}
开发者ID:namjae,项目名称:lgeo,代码行数:36,代码来源:lgeo_ogr.c

示例10: readFile

    virtual ReadResult readFile(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
    {
        if (OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount() == 0)
            OGRRegisterAll();

        // Try to open data source
        OGRDataSource* file = OGRSFDriverRegistrar::Open(fileName.c_str());
        if (!file)
            return 0;

        bool useRandomColorByFeature = false;
        bool addGroupPerFeature = false;
        if (options)
        {
            if (options->getOptionString().find("UseRandomColorByFeature") != std::string::npos)
                useRandomColorByFeature = true;
            if (options->getOptionString().find("useRandomColorByFeature") != std::string::npos)
                useRandomColorByFeature = true;
            if (options->getOptionString().find("addGroupPerFeature") != std::string::npos)
                addGroupPerFeature = true;
        }

        osg::Group* group = new osg::Group;

        for (int i = 0; i < file->GetLayerCount(); i++)
        {
            osg::Group* node = readLayer(file->GetLayer(i), file->GetName(), useRandomColorByFeature, addGroupPerFeature);
            if (node)
                group->addChild( node );
        }
        OGRDataSource::DestroyDataSource( file );
        return group;
    }
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:33,代码来源:ReaderWriterOGR.cpp

示例11: simplet_init

// Initialize libraries, register the atexit handler and set up error reporting.
void
simplet_init(){
  if(initialized) return;
  simplet_error_init();
  OGRRegisterAll();
  atexit(cleanup);
  initialized = 1;
};
开发者ID:chronicon,项目名称:simple-tiles,代码行数:9,代码来源:init.c

示例12: GdalTestData

 GdalTestData()
 {
     GDALAllRegister();
     OGRRegisterAll();
     fetch = NULL;
     poDS  = NULL;
     pszFilename =
         CPLFormFilename( NULL, CPLGenerateTempFilename( "GDAL_TEST" ), ".tif" );
 }
开发者ID:psuliuxf,项目名称:windninja,代码行数:9,代码来源:test_gdal_fetch.cpp

示例13: simplet_init

// Initialize libraries, register the atexit handler and set up error reporting.
void simplet_init() {
  if (initialized) return;
  CPLSetConfigOption("OGR_ENABLE_PARTIAL_REPROJECTION", "ON");
#ifdef DEBUG
  CPLSetConfigOption("CPL_DEBUG", "ON");
#endif
  OGRRegisterAll();
  GDALAllRegister();
  atexit(cleanup);
  initialized = 1;
};
开发者ID:propublica,项目名称:simple-tiles,代码行数:12,代码来源:init.c

示例14: OGRRegisterAll

//--------------------------------------------------------------
void
GeoData::setup()
{
#ifdef USE_OGR
	OGRRegisterAll();
	
    datasource = OGRSFDriverRegistrar::Open(dataSourceName.c_str(), FALSE);
#endif

	startThread(true, false); // blocking, non-verbose
}
开发者ID:paulreimer,项目名称:ofSoniphenologicAL,代码行数:12,代码来源:GeoData.cpp

示例15: CPLSetErrorHandler

rspfGdalFactory* rspfGdalFactory::instance()
{
   if(!theInstance)
   {
      theInstance = new rspfGdalFactory;
      CPLSetErrorHandler((CPLErrorHandler)CPLQuietErrorHandler);
      GDALAllRegister();
      OGRRegisterAll();
   }
   return theInstance;
}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:11,代码来源:rspfGdalFactory.cpp


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