• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OGROpen函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


示例3: log

void AttributeFilter::ready(PointContext ctx)
{
    m_gdal_debug = std::shared_ptr<pdal::gdal::Debug>(
        new pdal::gdal::Debug(isDebug(), log()));

    for (auto& dim_par : m_dimensions)
    {
        Dimension::Id::Enum t = ctx.findDim(dim_par.first);
        dim_par.second.dim = t;

        if (dim_par.second.isogr)
        {

            OGRDSPtr ds = OGRDSPtr(OGROpen(dim_par.second.datasource.c_str(), 0, 0), OGRDataSourceDeleter());
            if (!ds)
            {
                std::ostringstream oss;
                oss << "Unable to open data source '" << dim_par.second.datasource <<"'";
                throw pdal_error(oss.str());
            }
            dim_par.second.ds = ds;
        }

    }
}
开发者ID:rskelly,项目名称:PDAL,代码行数:25,代码来源:AttributeFilter.cpp


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


示例5: CPLSetConfigOption

QgsShapeFile::QgsShapeFile( QString name, QString encoding )
{
  fileName = name;
  features = 0;
  QgsApplication::registerOgrDrivers();

  QSettings settings;
  CPLSetConfigOption( "SHAPE_ENCODING", settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() ? "" : 0 );

  ogrDataSource = OGROpen( TO8F( fileName ), false, NULL );
  if ( ogrDataSource != NULL )
  {
    valid = true;
    ogrLayer = OGR_DS_GetLayer( ogrDataSource, 0 );
    features = OGR_L_GetFeatureCount( ogrLayer, true );
  }
  else
    valid = false;
  setDefaultTable();
  // init the geometry types
  geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"
  << "MULTILINESTRING" << "MULTIPOLYGON" << "GEOMETRYCOLLECTION";

  codec = QTextCodec::codecForName( encoding.toLocal8Bit().constData() );
  if ( !codec )
    codec = QTextCodec::codecForLocale();
  Q_ASSERT( codec );
}
开发者ID:ChowZenki,项目名称:QGIS,代码行数:28,代码来源:qgsshapefile.cpp


示例6: ogrDataSource

QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
    : QgsAbstractFeatureIteratorFromSource<QgsOgrFeatureSource>( source, ownSource, request )
    , ogrDataSource( 0 )
    , ogrLayer( 0 )
    , mSubsetStringSet( false )
    , mGeometrySimplifier( NULL )
{
  mFeatureFetched = false;

  ogrDataSource = OGROpen( TO8F( mSource->mFilePath ), false, NULL );

  if ( mSource->mLayerName.isNull() )
  {
    ogrLayer = OGR_DS_GetLayer( ogrDataSource, mSource->mLayerIndex );
  }
  else
  {
    ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( mSource->mLayerName ) );
  }

  if ( !mSource->mSubsetString.isEmpty() )
  {
    ogrLayer = QgsOgrUtils::setSubsetString( ogrLayer, ogrDataSource, mSource->mEncoding, mSource->mSubsetString );
    mSubsetStringSet = true;
  }

  mFetchGeometry = ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) || !( mRequest.flags() & QgsFeatureRequest::NoGeometry );
  QgsAttributeList attrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : mSource->mFields.allAttributesList();

  // make sure we fetch just relevant fields
  // unless it's a VRT data source filtered by geometry as we don't know which
  // attributes make up the geometry and OGR won't fetch them to evaluate the
  // filter if we choose to ignore them (fixes #11223)
  if (( mSource->mDriverName != "VRT" && mSource->mDriverName != "OGR_VRT" ) || mRequest.filterType() != QgsFeatureRequest::FilterRect )
  {
    QgsOgrUtils::setRelevantFields( ogrLayer, mSource->mFields.count(), mFetchGeometry, attrs );
  }

  // spatial query to select features
  if ( mRequest.filterType() == QgsFeatureRequest::FilterRect )
  {
    OGRGeometryH filter = 0;
    QString wktExtent = QString( "POLYGON((%1))" ).arg( mRequest.filterRect().asPolygon() );
    QByteArray ba = wktExtent.toAscii();
    const char *wktText = ba;

    OGR_G_CreateFromWkt(( char ** )&wktText, NULL, &filter );
    QgsDebugMsg( "Setting spatial filter using " + wktExtent );
    OGR_L_SetSpatialFilter( ogrLayer, filter );
    OGR_G_DestroyGeometry( filter );
  }
  else
  {
    OGR_L_SetSpatialFilter( ogrLayer, 0 );
  }

  //start with first feature
  rewind();
}
开发者ID:pavol-git,项目名称:QGIS,代码行数:59,代码来源:qgsogrfeatureiterator.cpp


示例7: NinjaOGRContain

/**
 * \brief Convenience function to check if a geometry is contained in a OGR
 *        datasource for a given layer.
 *
 * The passed geometry is a wkt representation of a geometry of type GeomType.
 * pszFile is opened, and the passed geometry is queried against all
 * geometries in pszLayer.  If the passed geometry is contained in *any* of the
 * geomtries in the layer, TRUE is returned.  FALSE is returned otherwise,
 * including errors.  The SRS of all geometries is assumed to be the same.
 *
 * \param pszWkt Well-known text representation of a geometry.
 * \param pszFile File to open
 * \param pszLayer Layer to extract geometry from, if NULL, use layer 0.
 * \return TRUE if pszWkt is contained in any geometry in pszLayer, FALSE
 *         otherwise, include errors
 */
int NinjaOGRContain(const char *pszWkt, const char *pszFile,
                    const char *pszLayer)
{
    int bContains = FALSE;
    if( pszWkt == NULL || pszFile == NULL )
    {
        return FALSE;
    }
    CPLDebug( "WINDNINJA", "Checking for containment of %s in %s:%s",
              pszWkt, pszFile, pszLayer ? pszLayer : "" );
    OGRGeometryH hTestGeometry = NULL;
    int err = OGR_G_CreateFromWkt( (char**)&pszWkt, NULL, &hTestGeometry );
    if( hTestGeometry == NULL || err != CE_None )
    {
        return FALSE;
    }
    OGRDataSourceH hDS = OGROpen( pszFile, 0, NULL );
    if( hDS == NULL )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "Failed to open datasource: %s", pszFile );
        OGR_G_DestroyGeometry( hTestGeometry );
        bContains = FALSE;
        return bContains;
    }
    OGRLayerH hLayer;
    if( pszLayer == NULL )
    {
        hLayer = OGR_DS_GetLayer( hDS, 0 );
    }
    else
    {
        hLayer = OGR_DS_GetLayerByName( hDS, pszLayer );
    }
    OGRFeatureH hFeature;
    if( hLayer != NULL )
    {
        OGRGeometryH hGeometry;
        OGR_L_ResetReading( hLayer );
        while( ( hFeature = OGR_L_GetNextFeature( hLayer ) ) != NULL )
        {
            hGeometry = OGR_F_GetGeometryRef( hFeature );
            if( OGR_G_Contains( hGeometry, hTestGeometry ) )
            {
                bContains = TRUE;
                OGR_F_Destroy( hFeature );
                break;
            }
            OGR_F_Destroy( hFeature );
        }
    }
    OGR_G_DestroyGeometry( hTestGeometry );
    OGR_DS_Destroy( hDS );
    return bContains;
}
开发者ID:firelab,项目名称:windninja,代码行数:71,代码来源:gdal_util.cpp


示例8: open

/* OGRDataSourceH CPL_DLL OGROpen(const char *, int, OGRSFDriverH *)
    CPL_WARN_UNUSED_RESULT;

{ok, DataSource} = lgeo_ogr:open("test/polygon.shp").
{ok, DataSource} = lgeo_ogr:open("test/polygon.shp", 1).

*/
static ERL_NIF_TERM
open(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    int update = 0; // read-only (default)
    OGRDataSourceH datasource;
    ERL_NIF_TERM eterm;
    /*
    OGRSFDriverH  *pahDriver;
    ERL_NIF_TERM eterm1, eterm2;
    */

    unsigned len;
    if (argc > 0 && !enif_get_list_length(env, argv[0], &len)) {
        return enif_make_badarg(env);
    }
    char * filename = enif_alloc(sizeof(char)*(len+1));

    if(!enif_get_string(env, argv[0], filename, len+1, ERL_NIF_LATIN1)) {
        return enif_make_badarg(env);
    }

    if (argc == 2 && !enif_get_int(env, argv[1], &update)) {
        return enif_make_badarg(env);
    }

    datasource = OGROpen(filename, update, NULL);
    //datasource = OGROpen(filename, upadate, pahDriver);

    enif_free(filename);
    if(datasource == NULL) {
        return enif_make_atom(env, "undefined");
    }

    OGRDataSourceH **hDS = \
        enif_alloc_resource(OGR_DS_RESOURCE, sizeof(OGRDataSourceH*));
    *hDS = datasource;

    /*
    OGRSFDriverH **hDriver = \
        enif_alloc_resource(OGR_D_RESOURCE, sizeof(OGRSFDriverH*));
    *hDriver = *pahDriver;
    */

    eterm = enif_make_resource(env, hDS);
    enif_release_resource(hDS);
    return enif_make_tuple2(env, enif_make_atom(env, "ok"), eterm);
    /*
    eterm2 = enif_make_resource(env, hDriver);
    enif_release_resource(hDriver);
    return enif_make_tuple2(env, eterm1, eterm1);
    */
}
开发者ID:namjae,项目名称:lgeo,代码行数:59,代码来源:lgeo_ogr.c


示例9: OGROpen

int QGisImporter::getGeometryType(QString const & path) {
  int ret = -1;

  // Well, this code is legacy, but fsck it :-P
  // Should not be compatible GDAL >= 2.0

  // TODO: Anyway, Mapserver code should provide similar mechanisms,
  // I'm probably re-inventing the wheel here.

  OGRDataSourceH  hDS;
  hDS = OGROpen(path.toStdString().c_str(), 0, NULL);
  if(hDS == NULL)
  {
    return -1;
  }

  int layerCount = OGR_DS_GetLayerCount(hDS);

  if (layerCount <= 0) {
    OGRReleaseDataSource( hDS );
    return -1;
  }

  OGRLayerH layer =  OGR_DS_GetLayer (hDS, 0);
  OGRwkbGeometryType geomType = OGR_L_GetGeomType(layer);

  // TODO: Might be a little naïve ...
  switch(geomType) {
    case wkbUnknown:
      ret = -1;
      break;
    case wkbPoint:
    case wkbMultiPoint:
      ret = MS_LAYER_POINT;
      break;
    case wkbLineString:
    case wkbMultiLineString:
      ret = MS_LAYER_LINE;
      break;
    case wkbPolygon:
    case wkbMultiPolygon:
    case wkbGeometryCollection:
      ret = MS_LAYER_POLYGON;
      break;
    default:
      ret = -1;
  }
  OGRReleaseDataSource(hDS);

  return ret;
}
开发者ID:QMapfileEditor,项目名称:QMapfileEditor,代码行数:51,代码来源:qgisimporter.cpp


示例10: QgsAbstractFeatureIterator

QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request )
    : QgsAbstractFeatureIterator( request )
    , P( p )
    , ogrDataSource( 0 )
    , ogrLayer( 0 )
    , mSubsetStringSet( false )
    , mGeometrySimplifier( NULL )
{
  mFeatureFetched = false;

  ogrDataSource = OGROpen( TO8F( P->filePath() ), false, NULL );

  if ( P->layerName().isNull() )
  {
    ogrLayer = OGR_DS_GetLayer( ogrDataSource, P->layerIndex() );
  }
  else
  {
    ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( p->layerName() ) );
  }

  if ( !P->subsetString().isEmpty() )
  {
    ogrLayer = P->setSubsetString( ogrLayer, ogrDataSource );
    mSubsetStringSet = true;
  }

  ensureRelevantFields();

  // spatial query to select features
  if ( mRequest.filterType() == QgsFeatureRequest::FilterRect )
  {
    OGRGeometryH filter = 0;
    QString wktExtent = QString( "POLYGON((%1))" ).arg( mRequest.filterRect().asPolygon() );
    QByteArray ba = wktExtent.toAscii();
    const char *wktText = ba;

    OGR_G_CreateFromWkt(( char ** )&wktText, NULL, &filter );
    QgsDebugMsg( "Setting spatial filter using " + wktExtent );
    OGR_L_SetSpatialFilter( ogrLayer, filter );
    OGR_G_DestroyGeometry( filter );
  }
  else
  {
    OGR_L_SetSpatialFilter( ogrLayer, 0 );
  }

  //start with first feature
  rewind();
}
开发者ID:AndrewBMartin,项目名称:QGIS,代码行数:50,代码来源:qgsogrfeatureiterator.cpp


示例11: OGRDSPtr

void AttributeFilter::ready(PointTableRef table)
{
    if (m_value != m_value)
    {
        m_ds = OGRDSPtr(OGROpen(m_datasource.c_str(), 0, 0),
            OGRDataSourceDeleter());
        if (!m_ds)
        {
            std::ostringstream oss;
            oss << getName() << ": Unable to open data source '" <<
                    m_datasource << "'";
            throw pdal_error(oss.str());
        }
    }
}
开发者ID:kirkjens,项目名称:PDAL,代码行数:15,代码来源:AttributeFilter.cpp


示例12: QString

QgsFeatureList QgsOgrUtils::stringToFeatureList( const QString& string, const QgsFields& fields, QTextCodec* encoding )
{
  QgsFeatureList features;
  if ( string.isEmpty() )
    return features;

  QString randomFileName = QString( "/vsimem/%1" ).arg( QUuid::createUuid().toString() );

  // create memory file system object from string buffer
  QByteArray ba = string.toUtf8();
  VSIFCloseL( VSIFileFromMemBuffer( TO8( randomFileName ), reinterpret_cast< GByte* >( ba.data() ),
                                    static_cast< vsi_l_offset >( ba.size() ), FALSE ) );

  OGRDataSourceH hDS = OGROpen( TO8( randomFileName ), false, nullptr );
  if ( !hDS )
  {
    VSIUnlink( TO8( randomFileName ) );
    return features;
  }

  OGRLayerH ogrLayer = OGR_DS_GetLayer( hDS, 0 );
  if ( !ogrLayer )
  {
    OGR_DS_Destroy( hDS );
    VSIUnlink( TO8( randomFileName ) );
    return features;
  }

  OGRFeatureH oFeat;
  while (( oFeat = OGR_L_GetNextFeature( ogrLayer ) ) )
  {
    QgsFeature feat = readOgrFeature( oFeat, fields, encoding );
    if ( feat.isValid() )
      features << feat;

    OGR_F_Destroy( oFeat );
  }

  OGR_DS_Destroy( hDS );
  VSIUnlink( TO8( randomFileName ) );

  return features;
}
开发者ID:mterente,项目名称:QGIS,代码行数:43,代码来源:qgsogrutils.cpp


示例13: GDALWConnect

GDALWConnection * GDALWConnect(char * source) {
	GDALWConnection * conn = NULL;
	OGRFeatureDefnH featureDefn;
	int fieldCount, i;
	OGRRegisterAll();
	conn = malloc(sizeof(GDALWConnection));
	if (conn == NULL) {
		fprintf(stderr, "Could not allocate memory\n");
		return NULL;
	}
	conn->handler = OGROpen(source, 0 , &(conn->driver));
	if (conn->handler == NULL) {
		free(conn);
		return NULL;
	}


	conn->layer = OGR_DS_GetLayer(conn->handler, 0);
	if (conn->layer == NULL) {
		OGRReleaseDataSource(conn->handler);
		free(conn);
		return NULL;
	}

	conn->layername = (const char *) OGR_L_GetName(conn->layer);

	featureDefn = OGR_L_GetLayerDefn(conn->layer);
	fieldCount = OGR_FD_GetFieldCount(featureDefn);
	conn->numFieldDefinitions = fieldCount;
	conn->fieldDefinitions = malloc(fieldCount * sizeof(OGRFieldDefnH));
	if (conn->fieldDefinitions == NULL) {
		OGRReleaseDataSource(conn->handler);
		free(conn);
		fprintf(stderr, "Could not allocate memory\n");
		return NULL;
	}
	for (i=0 ; i<fieldCount ; i++) {
		conn->fieldDefinitions[i] = OGR_FD_GetFieldDefn(featureDefn, i);
	}

	return conn;
}
开发者ID:MonetDB,项目名称:MonetDB,代码行数:42,代码来源:shp.c


示例14: OGROpen

QVector<QgsDataItem*> QgsOgrDataCollectionItem::createChildren()
{
  QVector<QgsDataItem*> children;

  OGRSFDriverH hDriver;
  OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), false, &hDriver );
  if ( !hDataSource )
    return children;
  int numLayers = OGR_DS_GetLayerCount( hDataSource );

  for ( int i = 0; i < numLayers; i++ )
  {
    QgsOgrLayerItem* item = dataItemForLayer( this, QString(), mPath, hDataSource, i );
    children.append( item );
  }

  OGR_DS_Destroy( hDataSource );

  return children;
}
开发者ID:LingboTang,项目名称:QGIS,代码行数:20,代码来源:qgsogrdataitems.cpp


示例15: QStringLiteral

QgsFeatureList QgsOgrUtils::stringToFeatureList( const QString &string, const QgsFields &fields, QTextCodec *encoding )
{
  QgsFeatureList features;
  if ( string.isEmpty() )
    return features;

  QString randomFileName = QStringLiteral( "/vsimem/%1" ).arg( QUuid::createUuid().toString() );

  // create memory file system object from string buffer
  QByteArray ba = string.toUtf8();
  VSIFCloseL( VSIFileFromMemBuffer( randomFileName.toUtf8().constData(), reinterpret_cast< GByte * >( ba.data() ),
                                    static_cast< vsi_l_offset >( ba.size() ), FALSE ) );

  gdal::ogr_datasource_unique_ptr hDS( OGROpen( randomFileName.toUtf8().constData(), false, nullptr ) );
  if ( !hDS )
  {
    VSIUnlink( randomFileName.toUtf8().constData() );
    return features;
  }

  OGRLayerH ogrLayer = OGR_DS_GetLayer( hDS.get(), 0 );
  if ( !ogrLayer )
  {
    hDS.reset();
    VSIUnlink( randomFileName.toUtf8().constData() );
    return features;
  }

  gdal::ogr_feature_unique_ptr oFeat;
  while ( oFeat.reset( OGR_L_GetNextFeature( ogrLayer ) ), oFeat )
  {
    QgsFeature feat = readOgrFeature( oFeat.get(), fields, encoding );
    if ( feat.isValid() )
      features << feat;
  }

  hDS.reset();
  VSIUnlink( randomFileName.toUtf8().constData() );

  return features;
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:41,代码来源:qgsogrutils.cpp


示例16: OGRDSPtr

void AttributeFilter::ready(PointTableRef table)
{
    for (auto& dim_par : m_dimensions)
    {
        Dimension::Id::Enum t = table.layout()->findDim(dim_par.first);
        dim_par.second.dim = t;

        if (dim_par.second.isogr)
        {

            OGRDSPtr ds = OGRDSPtr(OGROpen(dim_par.second.datasource.c_str(), 0, 0), OGRDataSourceDeleter());
            if (!ds)
            {
                std::ostringstream oss;
                oss << "Unable to open data source '" << dim_par.second.datasource <<"'";
                throw pdal_error(oss.str());
            }
            dim_par.second.ds = ds;
        }

    }
}
开发者ID:mpgerlek,项目名称:PDAL-old,代码行数:22,代码来源:AttributeFilter.cpp


示例17: OGROpen

int wxStation::GetFirstStationLine(const char *xFilename)
{
    OGRDataSourceH hDS;
    OGRLayer *poLayer;
    OGRFeature *poFeature;
    OGRLayerH hLayer;
    GIntBig iBig = 1;

    hDS = OGROpen( xFilename, FALSE, NULL );
    if(hDS == NULL)
    {
        return -1; //very bad!
    }
    poLayer = (OGRLayer*)OGR_DS_GetLayer( hDS, 0 );
    hLayer=OGR_DS_GetLayer(hDS,0);
    OGR_L_ResetReading(hLayer);
    poLayer->ResetReading();
    poFeature = poLayer->GetFeature(iBig);
    if (poFeature==NULL)
    {
        return -1; //If there are no stations in the csv!
    }
    std::string start_datetime(poFeature->GetFieldAsString(15));

    if(start_datetime.empty()==true)
    {
        return 1;
    }
    if(start_datetime.empty()==false)
    {
        return 2;
    }






}
开发者ID:firelab,项目名称:windninja,代码行数:39,代码来源:wxStation.cpp


示例18: QgsLayerItem

QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem* parent,
                                  const QString& name, const QString& path, const QString& uri, LayerType layerType )
    : QgsLayerItem( parent, name, path, uri, layerType, "ogr" )
{
  mToolTip = uri;
  setState( Populated ); // children are not expected

  OGRRegisterAll();
  OGRSFDriverH hDriver;
  OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver );

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

    if ( driverName == "ESRI Shapefile" )
      mCapabilities |= SetCrs;

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


示例19: OGROpen

QgsShapeFile::QgsShapeFile( QString name, QString encoding )
{
  fileName = name;
  features = 0;
  QgsApplication::registerOgrDrivers();
  ogrDataSource = OGROpen( QFile::encodeName( fileName ).constData(), FALSE, NULL );
  if ( ogrDataSource != NULL )
  {
    valid = true;
    ogrLayer = OGR_DS_GetLayer( ogrDataSource, 0 );
    features = OGR_L_GetFeatureCount( ogrLayer, TRUE );
  }
  else
    valid = false;
  setDefaultTable();
  // init the geometry types
  geometries << "NULL" << "POINT" << "LINESTRING" << "POLYGON" << "MULTIPOINT"
  << "MULTILINESTRING" << "MULTIPOLYGON" << "GEOMETRYCOLLECTION";

  codec = QTextCodec::codecForName( encoding.toLocal8Bit().data() );
  if ( !codec )
    codec = QTextCodec::codecForLocale();
}
开发者ID:HydroCouple,项目名称:FVHMComponent,代码行数:23,代码来源:qgsshapefile.cpp


示例20: main

/* What we need:  specific condition, is walk in , tactic, distance elevation
 * minsteps, maxsteps, waterdrops, pump/roll, fwa id.
 */
int main( int argc, char *argv[] )
{
    GDALAllRegister();
    OGRRegisterAll();

    const char *pszInputfile = NULL;
    const char *pszOutputfile = NULL;
    const char *pszOutputFormat = "CSV";
    char **papszCreateOptions = NULL;
    const char *pszDataPath = NULL;
    const char *pszFpuCode = NULL;
    int nLimit = 0;
    int bProgress = TRUE;
    double dfMaxX, dfMinX, dfMaxY, dfMinY;
    int bLimit = FALSE;
    double dfBuffer = 0.0;

    int i = 1;
    while( i < argc )
    {
        if( EQUAL( argv[i], "-p" ) )
        {
            bProgress = TRUE;
        }
        else if( EQUAL( argv[i], "-d" ) )
        {
            pszDataPath = argv[++i];
        }
        else if( EQUAL( argv[i], "-of" ) )
        {
            pszOutputFormat = argv[++i];
        }        
        else if( EQUAL( argv[i], "-co" ) )
        {
            papszCreateOptions = CSLAddString( papszCreateOptions, argv[++i] );
        }
        else if( EQUAL( argv[i], "-sl" ) )
        {
            dfMaxX = atof(argv[++i]);
            dfMinX = atof(argv[++i]);
            dfMaxY = atof(argv[++i]);
            dfMinY = atof(argv[++i]);
            bLimit = TRUE;
        }
        else if( EQUAL( argv[i], "-fpu" ) )
        {
            pszFpuCode = argv[++i];
        }
        else if( EQUAL( argv[i], "-b" ) )
        {
            dfBuffer = atof( argv[++i] );
        }
        else if( EQUAL( argv[i], "-l" ) )
        {
            nLimit = atoi( argv[++i] );
        }        
        else if( EQUAL( argv[i], "-h" ) )
        {
            Usage();
        }
        else if( pszInputfile == NULL )
        {
            pszInputfile = argv[i];
        }
        else if( pszOutputfile == NULL )
        {
            pszOutputfile = argv[i];
        }
        else
        {
            Usage();
        }
        i++;
    }

    if( pszInputfile == NULL )
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "No input file provided\n");
        Usage();
    }
    if( pszOutputfile == NULL )
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "Invalid output selected, "
                "use database and table or output file\n" );
        Usage();
    }

    pszDataPath = CPLGetConfigOption( "OMFFR_DATA", NULL );

    OGRDataSourceH hInputDS = OGROpen( pszInputfile, FALSE, NULL );
    if( hInputDS == NULL )
    {
        CPLError( CE_Failure, CPLE_OpenFailed, "Cannot open input file\n" );
        Usage();
    }

    int year, num, day;
//.........这里部分代码省略.........
开发者ID:firelab,项目名称:wfips,代码行数:101,代码来源:fig2scenario.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OGRRegisterAll函数代码示例发布时间:2022-05-30
下一篇:
C++ OGRE_NEW_T函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap