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


C++ OGRSFDriver类代码示例

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


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

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

示例2: GetGDALDriverManager

Handle<Value> GDALDrivers::getNames(const Arguments& args)
{
	HandleScope scope;
	int gdal_count = GetGDALDriverManager()->GetDriverCount();
	int i, ogr_count = 0;
	std::string name;

	#if GDAL_VERSION_MAJOR < 2
		ogr_count = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
	#endif

	int n = gdal_count + ogr_count;

	Local<Array> driver_names = Array::New(n);

	for (i = 0; i < gdal_count; ++i) {
		GDALDriver *driver = GetGDALDriverManager()->GetDriver(i);
		name = driver->GetDescription();
		#if GDAL_VERSION_MAJOR < 2
		if(name == "VRT") name = "VRT:raster";
		#endif
		driver_names->Set(i, SafeString::New(name.c_str()));
	}

	for (; i < n; ++i) {
		OGRSFDriver *driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i - gdal_count);
		name = driver->GetName();
		#if GDAL_VERSION_MAJOR < 2
		if(name == "VRT") name = "VRT:vector";
		#endif
		driver_names->Set(i, SafeString::New(name.c_str()));
	}
	return scope.Close(driver_names);
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:34,代码来源:gdal_drivers.cpp

示例3: RegisterOGRGeoconcept

void RegisterOGRGeoconcept()

{
    OGRSFDriver* poDriver = new OGRGeoconceptDriver;
    poDriver->SetMetadataItem( GDAL_DMD_EXTENSIONS, "gxt txt" );

    poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST,
"<CreationOptionList>"
"  <Option name='EXTENSION' type='string-select' description='indicates the "
"GeoConcept export file extension. TXT was used by earlier releases of "
"GeoConcept. GXT is currently used.' default='GXT'>"
"    <Value>GXT</Value>"
"    <Value>TXT</Value>"
"  </Option>"
"  <Option name='CONFIG' type='string' description='path to the GCT file that "
"describes the GeoConcept types definitions.'/>"
"</CreationOptionList>");

    poDriver->SetMetadataItem( GDAL_DS_LAYER_CREATIONOPTIONLIST,
"<LayerCreationOptionList>"
"  <Option name='FEATURETYPE' type='string' description='TYPE.SUBTYPE : "
"defines the feature to be created. The TYPE corresponds to one of the Name "
"found in the GCT file for a type section. The SUBTYPE corresponds to one of "
"the Name found in the GCT file for a sub-type section within the previous "
"type section'/>"
"</LayerCreationOptionList>" );
    poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );

    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( poDriver );
}
开发者ID:OSGeo,项目名称:gdal,代码行数:30,代码来源:ogrgeoconceptdriver.cpp

示例4: Get_Description

//---------------------------------------------------------
CSG_String COGR_Driver::Get_Description(int iDriver)
{
	OGRSFDriver	*pDriver	= m_pManager->GetDriver(iDriver);
	CSG_String	s;

	s	+= pDriver->TestCapability(ODrCCreateDataSource)	? SG_T("\n[x] ") : SG_T("\n[ ] ");
	s	+= _TL("create data source");

	s	+= pDriver->TestCapability(ODrCDeleteDataSource)	? SG_T("\n[x] ") : SG_T("\n[ ] ");
	s	+= _TL("delete data source");

/*	s	+= pDriver->TestCapability(ODsCCreateLayer)			? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("create layer");

	s	+= pDriver->TestCapability(ODsCDeleteLayer)			? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("delete layer");

	s	+= pDriver->TestCapability(OLCDeleteFeature)		? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("delete feature");

	s	+= pDriver->TestCapability(OLCRandomRead)			? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("random read");

	s	+= pDriver->TestCapability(OLCRandomWrite)			? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("random write");

	s	+= pDriver->TestCapability(OLCSequentialWrite)		? SG_T("\n[x]") : SG_T("\n[ ]");
	s	+= _TL("sequential write");
/**/

	return( SG_STR_MBTOSG(s) );
}
开发者ID:am2222,项目名称:SAGA-GIS,代码行数:33,代码来源:ogr_driver.cpp

示例5: while

shared_ptr<OGRDataSource> OgrUtilities::createDataSource(QString url)
{
  const char* driverName = NULL;
  int i = 0;
  while (extensions[i][0] != NULL)
  {
    if (url.endsWith(extensions[i][0]))
    {
      driverName = extensions[i][1];
    }
    i++;
  }
  i = 0;
  while (beginName[i][0] != NULL)
  {
    if (url.startsWith(beginName[i][0]))
    {
      driverName = beginName[i][1];
    }
    i++;
  }
  if (driverName == NULL)
  {
    throw HootException("No driver found for: " + url);
  }

  OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
  if (driver == 0)
  {
    throw HootException("Error getting driver by name: " + QString(driverName));
  }

  // if the user specifies a shapefile then crop off the .shp and create a directory.
  if (url.toLower().endsWith(".shp"))
  {
    url = url.mid(0, url.length() - 4);
  }

  shared_ptr<OGRDataSource> result(driver->CreateDataSource(url.toAscii()));
  if (result == NULL)
  {
    throw HootException("Unable to create data source: " + url +
                        " (" + QString(CPLGetLastErrorMsg()) + ")");
  }
  result->SetDriver(driver);

  if (QString(driverName) == "FileGDB")
  {
    long v = GDAL_VERSION_MAJOR * 1000000 + GDAL_VERSION_MINOR * 1000 + GDAL_VERSION_REV;
    long lowest = 1 * 1000000 + 10 * 1000 + 1;
    if (v < lowest)
    {
      LOG_WARN("Writing to FileGDB with GDAL v" << GDAL_RELEASE_NAME << ". FileGDB with a GDAL "
               "v1.9.0 is known to create files that can't be read by ArcMap 10.2. "
               "GDAL v1.10.1 is known to work.");
    }
  }

  return result;
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:60,代码来源:OgrUtilities.cpp

示例6: RegisterOGRCouchDB

void RegisterOGRCouchDB()

{
    OGRSFDriver* poDriver = new OGRCouchDBDriver;
    poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "CouchDB / GeoCouch" );
    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( poDriver );
}
开发者ID:samalone,项目名称:gdal-ios,代码行数:7,代码来源:ogrcouchdbdriver.cpp

示例7: OGR_Dr_CreateDataSource

OGRDataSourceH OGR_Dr_CreateDataSource( OGRSFDriverH hDriver,
                                        const char *pszName, 
                                        char ** papszOptions )

{
    VALIDATE_POINTER1( hDriver, "OGR_Dr_CreateDataSource", NULL );

    OGRSFDriver* poDriver = (OGRSFDriver *) hDriver;
    CPLAssert( NULL != poDriver );

    OGRDataSource* poDS = NULL;
    poDS = poDriver->CreateDataSource( pszName, papszOptions );

    /* This fix is explained in Ticket #1223 */
    if( NULL != poDS )
    {
        poDS->SetDriver( poDriver );
        CPLAssert( NULL != poDS->GetDriver() );
    }
    else
    {
        CPLDebug( "OGR", "CreateDataSource operation failed. NULL pointer returned." );
    }

    return (OGRDataSourceH) poDS;
}
开发者ID:afarnham,项目名称:gdal,代码行数:26,代码来源:ogrsfdriver.cpp

示例8: Create

int OGRGPSBabelWriteDataSource::Create( const char * pszName,
                                        char **papszOptions )
{
    OGRSFDriver* poGPXDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("GPX");
    if (poGPXDriver == NULL)
    {
        CPLError(CE_Failure, CPLE_AppDefined, "GPX driver is necessary for GPSBabel write support");
        return FALSE;
    }

    if (!EQUALN(pszName, "GPSBABEL:", 9))
    {
        const char* pszOptionGPSBabelDriverName =
                CSLFetchNameValue(papszOptions, "GPSBABEL_DRIVER");
        if (pszOptionGPSBabelDriverName != NULL)
            pszGPSBabelDriverName = CPLStrdup(pszOptionGPSBabelDriverName);
        else
        {
            CPLError(CE_Failure, CPLE_AppDefined, "GPSBABEL_DRIVER dataset creation option expected");
            return FALSE;
        }

        pszFilename = CPLStrdup(pszName);
    }
    else
    {
        const char* pszSep = strchr(pszName + 9, ':');
        if (pszSep == NULL)
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                    "Wrong syntax. Expected GPSBabel:driver_name[,options]*:file_name");
            return FALSE;
        }

        pszGPSBabelDriverName = CPLStrdup(pszName + 9);
        *(strchr(pszGPSBabelDriverName, ':')) = '\0';

        pszFilename = CPLStrdup(pszSep+1);
    }

    /* A bit of validation to avoid command line injection */
    if (!OGRGPSBabelDataSource::IsValidDriverName(pszGPSBabelDriverName))
        return FALSE;

    const char* pszOptionUseTempFile = CSLFetchNameValue(papszOptions, "USE_TEMPFILE");
    if (pszOptionUseTempFile == NULL)
        pszOptionUseTempFile = CPLGetConfigOption("USE_TEMPFILE", NULL);
    if (pszOptionUseTempFile && CSLTestBoolean(pszOptionUseTempFile))
        osTmpFileName = CPLGenerateTempFilename(NULL);
    else
        osTmpFileName.Printf("/vsimem/ogrgpsbabeldatasource_%p", this);

    poGPXDS = poGPXDriver->CreateDataSource(osTmpFileName.c_str(), papszOptions);
    if (poGPXDS == NULL)
        return FALSE;

    this->pszName = CPLStrdup(pszName);

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

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

示例10: Usage

void Usage()
{
	OGRSFDriverRegistrar * poR = OGRSFDriverRegistrar::GetRegistrar();
	printf(
	    "Usage: txt2shp -i <input directory>\n"
	    "               -o <output directory>\n"
	    "              [-f <output file format_name>]\n\n"

	    "Note :\n"
	    " You can not put any file except you data files in the input directory."
	    " And the output directory must be empty directory.\n\n"
	);

	printf("Advanced options :\n");
	printf(" -f format_name: output file format name, possible values are:\n");

	for (int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++)
	{
		OGRSFDriver * poDriver = poR->GetDriver(iDriver);

		if (poDriver->TestCapability(ODrCCreateDataSource))
			printf("     -f \"%s\"\n", poDriver->GetName());
	}

	printf(
	    "\nExample :\n"
	    " txt2shp -i you_dir -o you_dir -f \"ESRI Shapefile\"\n\n"
	);
	exit(1);
}
开发者ID:htoooth,项目名称:txt2shp,代码行数:30,代码来源:main.cpp

示例11: RegisterOGRGFT

void RegisterOGRGFT()

{
    OGRSFDriver* poDriver = new OGRGFTDriver;
    poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "Google Fusion Tables" );
    poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "drv_gft.html" );
    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver(poDriver);
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:8,代码来源:ogrgftdriver.cpp

示例12: RegisterOGRMEM

void RegisterOGRMEM()

{
    OGRSFDriver* poDriver = new OGRMemDriver;
    
    poDriver->SetMetadataItem( GDAL_DMD_CREATIONFIELDDATATYPES, "Integer Integer64 Real String Date DateTime Time IntegerList Integer64List RealList StringList Binary" );

    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( poDriver );
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:9,代码来源:ogrmemdriver.cpp

示例13: RegisterOGRIdrisi

void RegisterOGRIdrisi()

{
    OGRSFDriver* poDriver = new OGRIdrisiDriver;
    poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "Idrisi Vector (.vct)" );
    poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "vct" );
    poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver(poDriver);
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:9,代码来源:ogridrisidriver.cpp

示例14: getDriversNames

void TeOGRDriver::getDriversNames(std::vector<std::string>& dnames)
{
	int ndrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
	for(int i = 0; i < ndrivers; ++i)
	{
		OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i);
		dnames.push_back(driver->GetName());
	}
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:9,代码来源:TeOGRDriver.cpp

示例15: RegisterOGRGeomedia

void RegisterOGRGeomedia()

{
    OGRSFDriver* poDriver = new OGRGeomediaDriver;
    poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "Geomedia .mdb" );
    poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "mdb" );
    poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "drv_geomedia.html" );
    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver(poDriver);
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:9,代码来源:ogrgeomediadriver.cpp


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