本文整理汇总了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");
}
}
示例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;
}
示例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 );
}
}
示例4: OGRRegisterAll
void QgsApplication::registerOgrDrivers()
{
if ( 0 >= OGRGetDriverCount() )
{
OGRRegisterAll();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
};
示例12: GdalTestData
GdalTestData()
{
GDALAllRegister();
OGRRegisterAll();
fetch = NULL;
poDS = NULL;
pszFilename =
CPLFormFilename( NULL, CPLGenerateTempFilename( "GDAL_TEST" ), ".tif" );
}
示例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;
};
示例14: OGRRegisterAll
//--------------------------------------------------------------
void
GeoData::setup()
{
#ifdef USE_OGR
OGRRegisterAll();
datasource = OGRSFDriverRegistrar::Open(dataSourceName.c_str(), FALSE);
#endif
startThread(true, false); // blocking, non-verbose
}
示例15: CPLSetErrorHandler
rspfGdalFactory* rspfGdalFactory::instance()
{
if(!theInstance)
{
theInstance = new rspfGdalFactory;
CPLSetErrorHandler((CPLErrorHandler)CPLQuietErrorHandler);
GDALAllRegister();
OGRRegisterAll();
}
return theInstance;
}