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


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

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


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

示例1: FindNearestPoint

GNMGFID GNMGenericNetwork::FindNearestPoint(const OGRPoint* poPoint,
                                    const std::vector<OGRLayer*>& paPointLayers,
                                    double dfTolerance)
{
    VALIDATE_POINTER1(poPoint, "GNMGenericNetwork::FindNearestPoint", -1);
    double dfMinX = poPoint->getX() - dfTolerance;
    double dfMinY = poPoint->getY() - dfTolerance;
    double dfMaxX = poPoint->getX() + dfTolerance;
    double dfMaxY = poPoint->getY() + dfTolerance;

    OGRFeature *poFeature;

    for(size_t i = 0; i < paPointLayers.size(); ++i)
    {
        OGRLayer *poLayer = paPointLayers[i];

        poLayer->SetSpatialFilterRect(dfMinX, dfMinY,
                                      dfMaxX, dfMaxY);
        poLayer->ResetReading();
        while((poFeature = poLayer->GetNextFeature()) != NULL)
        {
            GNMGFID nRetFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_GFID);
            OGRFeature::DestroyFeature(poFeature);
            return nRetFID;
        }
    }

    return -1;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:29,代码来源:gnmgenericnetwork.cpp

示例2: GetGeomediaSRS

OGRSpatialReference* OGRGeomediaDataSource::GetGeomediaSRS(const char* pszGCoordSystemTable,
                                                      const char* pszGCoordSystemGUID)
{
    if (pszGCoordSystemTable == NULL || pszGCoordSystemGUID == NULL)
        return NULL;

    OGRLayer* poGCoordSystemTable = GetLayerByName(pszGCoordSystemTable);
    if (poGCoordSystemTable == NULL)
        return NULL;

    poGCoordSystemTable->ResetReading();

    OGRFeature* poFeature;
    while((poFeature = poGCoordSystemTable->GetNextFeature()) != NULL)
    {
        const char* pszCSGUID = poFeature->GetFieldAsString("CSGUID");
        if (pszCSGUID && strcmp(pszCSGUID, pszGCoordSystemGUID) == 0)
        {
            OGRSpatialReference* poSRS = OGRGetGeomediaSRS(poFeature);
            delete poFeature;
            return poSRS;
        }

        delete poFeature;
    }

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

示例3: read_samplenum

//本函数返回矢量点的数目
int CGouTIN::read_samplenum(const char* pDataSource,const char* pLayerName,char** pSpatialRefWkt)
{
	//将类CIDW做参数
	OGRRegisterAll();
	OGRDataSource *poDS=OGRSFDriverRegistrar::Open(pDataSource,FALSE);
	//OGRDataSource *poDS=OGRSFDriverRegistrar::Open("point.shp",FALSE);
	if( poDS == NULL )
	{
		printf( "[ERROR] zmw Open failed.\n" );
		exit( 1 );
	}


	OGRLayer *poLayer = poDS->GetLayerByName(pLayerName);
	//cout<<f3.c_str()<<endl;
	//cout<<"here2"<<endl;
	//OGRSpatialReference * sref= poLayer->GetSpatialRef();
	//sref->exportToWkt(pSpatialRefWkt);
	//cout<<"here3"<<endl;
	OGRFeature *poFeature;

	poLayer->ResetReading();
	//cout<<"here4"<<endl;
	int count = 0;//统计散点数
	while((poFeature=poLayer->GetNextFeature())!=NULL)
	{
		count++;
	}
	OGRDataSource::DestroyDataSource( poDS );
	return count;
}
开发者ID:lspatial,项目名称:spstatics_parallel,代码行数:32,代码来源:GouTIN.cpp

示例4: FixIndexes

int FGdbDataSource::FixIndexes()
{
    int bRet = TRUE;
    if( m_pConnection && m_pConnection->IsFIDHackInProgress() )
    {
        m_pConnection->CloseGeodatabase();

        char* apszDrivers[2];
        apszDrivers[0] = (char*) "OpenFileGDB";
        apszDrivers[1] = NULL;
        const char* pszSystemCatalog = CPLFormFilename(m_osFSName, "a00000001.gdbtable", NULL);
        GDALDataset* poOpenFileGDBDS = (GDALDataset*)
            GDALOpenEx(pszSystemCatalog, GDAL_OF_VECTOR,
                       apszDrivers, NULL, NULL);
        if( poOpenFileGDBDS == NULL || poOpenFileGDBDS->GetLayer(0) == NULL )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "Cannot open %s with OpenFileGDB driver. "
                     "Should not happen. Some layers will be corrupted",
                     pszSystemCatalog);
            bRet = FALSE;
        }
        else
        {
            OGRLayer* poLayer = poOpenFileGDBDS->GetLayer(0);
            size_t count = m_layers.size();
            for(size_t i = 0; i < count; ++i )
            {
                if( m_layers[i]->m_oMapOGRFIDToFGDBFID.size() == 0)
                    continue;
                CPLString osFilter = "name = '";
                osFilter += m_layers[i]->GetName();
                osFilter += "'";
                poLayer->SetAttributeFilter(osFilter);
                poLayer->ResetReading();
                OGRFeature* poF = poLayer->GetNextFeature();
                if( poF == NULL )
                {
                    CPLError(CE_Failure, CPLE_AppDefined,
                             "Cannot find filename for layer %s",
                             m_layers[i]->GetName());
                    bRet = FALSE;
                }
                else
                {
                    if( !m_layers[i]->EditIndexesForFIDHack(CPLFormFilename(m_osFSName,
                                        CPLSPrintf("a%08x", (int)poF->GetFID()), NULL)) )
                    {
                        bRet = FALSE;
                    }
                }
                delete poF;
            }
        }
        GDALClose(poOpenFileGDBDS);

        m_pConnection->SetFIDHackInProgress(FALSE);
    }
    return bRet;
}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:60,代码来源:FGdbDatasource.cpp

示例5:

//---------------------------------------------------------
CSG_Shapes * COGR_DataSource::Read_Shapes(int iLayer)
{
	OGRLayer	*pLayer	= Get_Layer(iLayer);

	//-----------------------------------------------------
	if( pLayer && Get_Type(iLayer) != SHAPE_TYPE_Undefined )
	{
		int				iField;
		OGRFeature		*pFeature;
		OGRFeatureDefn	*pDef		= pLayer->GetLayerDefn();
		CSG_Shapes		*pShapes	= SG_Create_Shapes(Get_Type(iLayer), CSG_String(pDef->GetName()));

		for(iField=0; iField<pDef->GetFieldCount(); iField++)
		{
			OGRFieldDefn	*pDefField	= pDef->GetFieldDefn(iField);

			pShapes->Add_Field(pDefField->GetNameRef(), COGR_Driver::Get_Type(pDefField->GetType()));
		}

		pLayer->ResetReading();

		//-------------------------------------------------
		while( (pFeature = pLayer->GetNextFeature()) != NULL && SG_UI_Process_Get_Okay(false) )
		{
			OGRGeometry	*pGeometry	= pFeature->GetGeometryRef();

			if( pGeometry != NULL )
			{
				CSG_Shape	*pShape	= pShapes->Add_Shape();

				for(iField=0; iField<pDef->GetFieldCount(); iField++)
				{
					OGRFieldDefn	*pDefField	= pDef->GetFieldDefn(iField);

					switch( pDefField->GetType() )
					{
					default:			pShape->Set_Value(iField, SG_STR_MBTOSG(pFeature->GetFieldAsString (iField)));	break;
					case OFTString:		pShape->Set_Value(iField, SG_STR_MBTOSG(pFeature->GetFieldAsString (iField)));	break;
					case OFTInteger:	pShape->Set_Value(iField, pFeature->GetFieldAsInteger(iField));	break;
					case OFTReal:		pShape->Set_Value(iField, pFeature->GetFieldAsDouble (iField));	break;
					}
				}

				//-----------------------------------------
				if( _Read_Geometry(pShape, pGeometry) == false )
				{
					pShapes->Del_Shape(pShape);
				}
			}

			OGRFeature::DestroyFeature(pFeature);
		}

		return( pShapes );
	}

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

示例6: LoadSamples

void MSN_Helper::LoadSamples(Config &config, Matrix &mat)
{
	if(config.bShapefile)
	{
		OGRRegisterAll();
		string pLayerName = StringGetFileName(config.sSamples);
		OGRDataSource* poDS = OGRSFDriverRegistrar::Open(config.sSamples.c_str(),FALSE);
		OGRLayer* poLayer = poDS->GetLayerByName(pLayerName.c_str());
	
		config.nSamples = poLayer->GetFeatureCount();
		mat.Resize(config.nSamples, 4);

		OGRPoint *poPoint;
		OGRFeature * pFeature =poLayer->GetNextFeature();
		for(unsigned long i=1; i<=config.nSamples; i++)
		{
			//样本取值字段名为value,double型
			poPoint = (OGRPoint *)pFeature->GetGeometryRef();
			mat[i][1] = poPoint->getX();
			mat[i][2] = poPoint->getY();
			mat[i][3] = pFeature->GetFieldAsInteger("stratum");
			mat[i][4] = pFeature->GetFieldAsDouble("value");
			pFeature = poLayer->GetNextFeature();
		}

		OGRDataSource::DestroyDataSource( poDS );
	}
	else
	{
		double x, y, v, stratum;
		string sline;
		ifstream infile(config.sSamples.c_str());
		infile >> config.nSamples;

		mat.Resize(config.nSamples, 4);
		for(unsigned long i=1; i<=config.nSamples; i++)
		{
			infile >> x >> y >> stratum >> v;
			mat[i][1] = x;
			mat[i][2] = y;
			mat[i][3] = stratum;
			mat[i][4] = v;
		}
		infile.close();
	}
}
开发者ID:lspatial,项目名称:spstatics_parallel,代码行数:46,代码来源:MSN_Helper.cpp

示例7: OGR2SQLITE_ogr_geocode_set_result

static
void OGR2SQLITE_ogr_geocode_set_result(sqlite3_context* pContext,
                                       OGRLayerH hLayer,
                                       const char* pszField)
{
    if( hLayer == NULL )
        sqlite3_result_null (pContext);
    else
    {
        OGRLayer* poLayer = (OGRLayer*)hLayer;
        OGRFeatureDefn* poFDefn = poLayer->GetLayerDefn();
        OGRFeature* poFeature = poLayer->GetNextFeature();
        int nIdx = -1;
        if( poFeature == NULL )
            sqlite3_result_null (pContext);
        else if( strcmp(pszField, "geometry") == 0 &&
                 poFeature->GetGeometryRef() != NULL )
        {
            GByte* pabyGeomBLOB = NULL;
            int nGeomBLOBLen = 0;
            if( OGRSQLiteLayer::ExportSpatiaLiteGeometry(
                        poFeature->GetGeometryRef(), 4326, wkbNDR, FALSE, FALSE, FALSE,
                        &pabyGeomBLOB,
                        &nGeomBLOBLen ) != CE_None )
            {
                sqlite3_result_null (pContext);
            }
            else
            {
                sqlite3_result_blob (pContext, pabyGeomBLOB, nGeomBLOBLen, CPLFree);
            }
        }
        else if( (nIdx = poFDefn->GetFieldIndex(pszField)) >= 0 &&
                 poFeature->IsFieldSet(nIdx) )
        {
            OGRFieldType eType = poFDefn->GetFieldDefn(nIdx)->GetType();
            if( eType == OFTInteger )
                sqlite3_result_int(pContext,
                                   poFeature->GetFieldAsInteger(nIdx));
            else if( eType == OFTInteger64 )
                sqlite3_result_int64(pContext,
                                     poFeature->GetFieldAsInteger64(nIdx));
            else if( eType == OFTReal )
                sqlite3_result_double(pContext,
                                      poFeature->GetFieldAsDouble(nIdx));
            else
                sqlite3_result_text(pContext,
                                    poFeature->GetFieldAsString(nIdx),
                                    -1, SQLITE_TRANSIENT);
        }
        else
            sqlite3_result_null (pContext);
        delete poFeature;
        OGRGeocodeFreeResult(hLayer);
    }
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:56,代码来源:ogrsqlitesqlfunctions.cpp

示例8: compareIntersectionResults

bool AoIIntersection::compareIntersectionResults( OGRDataSource *resultData, IntersectionSummary *origSummary )
{
  bool success = true;
  IntersectionSummary resultSummary;

  OGRLayer *resultLayer;
  resultSummary.numLayers = resultData->GetLayerCount();

  if ( resultSummary.numLayers != origSummary->numLayers )
    {
      printf( "Test results: Layer count mismatch.\n" );
      success = false;
    }

  for (int layerCt = 0; layerCt < resultSummary.numLayers; ++layerCt)
  {
    resultLayer = resultData->GetLayer( layerCt );
    if ( resultLayer == NULL )
    {
      printf( "Test results: Layer count mismatch.\n" );
      success = false;
    }

    // get field indices for the fields we wrote
    int acreIndex = resultLayer->GetLayerDefn()->GetFieldIndex( "Acres in AoI" );
    int areaIndex = resultLayer->GetLayerDefn()->GetFieldIndex( "Percent of AOI" );
    resultLayer->ResetReading();
    OGRFeature *resultFeature;
    while( (resultFeature = resultLayer->GetNextFeature()) != NULL )
    {
      double acres = resultFeature->GetFieldAsDouble( acreIndex );
      double area = resultFeature->GetFieldAsDouble( areaIndex );
      resultSummary.totalPercentOfAoI += area;
      resultSummary.totalIntersectionAcres += acres;
    }
  }

  if ( resultSummary.totalPercentOfAoI != origSummary->totalPercentOfAoI )
  {
    printf( "Test results: Percent of AoI mismatch.\n" );
    success = false;
  }
  if ( resultSummary.totalIntersectionAcres != origSummary->totalIntersectionAcres )
  {
    printf( "Test results: Acreage mismatch.\n" );
    success = false;
  }

return success;
}
开发者ID:gideonmay,项目名称:minervagis,代码行数:50,代码来源:AoIIntersection.cpp

示例9: main

int main() {
    // Read in raster data for night time lights
    int band_number = 1; // only one band, starts with one
    Raster* raster = import_raster("raster.tif", band_number);

    // Read in shapefile data containing municipality administrative regions
    int layer_number = 0; // only one layer, starts with zero
    OGRLayer* shapelayer = import_shapefile("MEX_adm2.shp", layer_number);

    shapelayer->SetAttributeFilter("ID_1 = 1834");       // Filter for Yucatan
    const int idx_of_number_field = 5;             // Column number of municipality number
    const int idx_of_name_field = 6;               // Column number of municipality name

    OGRFeature* poFeature;
    int feature_ctr = 0;
    while( (poFeature = shapelayer->GetNextFeature()) != NULL ) {
        cerr << "Feature: " << feature_ctr++ << "\t";
        int feature_num = poFeature->GetFieldAsInteger(idx_of_number_field);
        string feature_name = poFeature->GetFieldAsString(idx_of_name_field);

        OGRFeatureDefn *poFDefn = shapelayer->GetLayerDefn();
        for( int iField = 0; iField < poFDefn->GetFieldCount(); iField++ ) {
            OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn( iField );
            if( poFieldDefn->GetType() == OFTString )  cerr << poFeature->GetFieldAsString(iField) << ",";
        }

        OGRGeometry* poGeometry = poFeature->GetGeometryRef();
        if( poGeometry != NULL) {
            // For contiguous regions
            if ( wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon ) {
                cerr << " polygon" << endl;
                report_raster_data_within_polygon(raster, (OGRPolygon *) poGeometry, feature_num, feature_name);
            // For disjoint regions
            } else if ( wkbFlatten(poGeometry->getGeometryType()) == wkbMultiPolygon ) {
                cerr << " multipolygon" << endl;
                OGRMultiPolygon *multipolygon = (OGRMultiPolygon *) poGeometry;
                for (int i = 0; i<multipolygon->getNumGeometries(); i++) {
                    report_raster_data_within_polygon(raster, (OGRPolygon*) multipolygon->getGeometryRef(i), feature_num, feature_name);
                }
            // Is this really the right shapefile?
            } else {
                cerr << "No polygon or multipolygon geometry for this feature: " << poGeometry->getGeometryName() << endl;
            }
        } else {
            cerr << "No geometry for this feature" << endl;
        }
    }
    OGRFeature::DestroyFeature( poFeature );
}
开发者ID:PulliamLab-UFL,项目名称:dengue,代码行数:49,代码来源:clip_raster_by_region.cpp

示例10: LoadShapes

			bool LoadShapes(GDALDataset* dataset, QueryIntermediateData& qid)
			{
				OGRLayer* waterLayer = dataset->GetLayerByName("water");
				if (!waterLayer) return true; // requested layer may not be present in requested dataset

				waterLayer->ResetReading();

				OGRFeature* feature;
				while ((feature = waterLayer->GetNextFeature()) != NULL)
				{
					auto geo = feature->GetGeometryRef();
					auto featureId = feature->GetFID();

					if (qid.transform)
					{
						if (geo->transform(qid.transform) != OGRERR_NONE)
						{
							continue;
						}
					}

					if (geo->getGeometryType() == wkbMultiPolygon)
					{
						auto mp = (OGRMultiPolygon*)geo;
						const int numPolys = mp->getNumGeometries();
						for (int p = 0; p < numPolys; p++)
						{
							auto poly = new Polygon((OGRPolygon*)mp->getGeometryRef(p), featureId);

							qid.waterPolyQuadtree.Insert(poly);
							qid.waterPolygons.push_back(poly);
						}
					}
					else if (geo->getGeometryType() == wkbPolygon)
					{
						auto poly = new Polygon((OGRPolygon*)geo, featureId);

						qid.waterPolyQuadtree.Insert(poly);
						qid.waterPolygons.push_back(poly);
					}

					OGRFeature::DestroyFeature(feature);
				}

				return true;
			}
开发者ID:Hemofektik,项目名称:Druckwelle,代码行数:46,代码来源:OSMSDF.cpp

示例11: getAvailShapes

/** @brief Get list of shapes from file, optional search by name
  *
  * read in shape file, extract shapes return as list
  * optional string argument returns only matching shapes (by string.find)
  * (!case sensitive!)
  */
void getAvailShapes(vector<OGRFeature*>* availShapes_p, const string selected = "")
{

    OGRRegisterAll();

    OGRDataSource * poDS;

    string path = "../admin_level_6/shape_al6/admin_level_6.shp";

    if (exists(path))
    {
        poDS = OGRSFDriverRegistrar::Open(path.c_str());
        if (poDS == NULL)
        {
            cout << "Data read error" << endl;
            exit (1);
        }
    }
    else
    {
        cout << "File not found" << endl;
        exit(1);
    }

//    cout << "Found " << poDS->GetLayerCount() << "Layers in File" << endl;
    OGRLayer *poLayer;
    OGRFeature *poFeature;
    poLayer = poDS->GetLayer(0);
    poLayer->ResetReading();
    while ( (poFeature = poLayer->GetNextFeature()) != NULL)
    {
        if (selected.empty())
        {
            availShapes_p->push_back(poFeature);
        }
        else
        {
            if (string(poFeature->GetFieldAsString(1)).find(selected) != string::npos)
                availShapes_p->push_back(poFeature);
            else
                OGRFeature::DestroyFeature(poFeature);
        }
    }

    OGRDataSource::DestroyDataSource(poDS);
}
开发者ID:Chaos99,项目名称:OSMGarminPortal,代码行数:52,代码来源:main.cpp

示例12: OGRMultiPolygon

MapExtruder::MapExtruder(const char* map2dFile,double height)
{
	_map2dFile = map2dFile;
	_height = height;

	OGRRegisterAll();
	OGRDataSource *poDS = OGRSFDriverRegistrar::Open(_map2dFile,FALSE);
	if( poDS == NULL)
	{
		printf("Open failed.\n");
		exit(1);
	}
	_map2d = new OGRMultiPolygon();
	
	OGRLayer *poLayer;
	poLayer = poDS->GetLayer(0);

	OGRFeature *poFeature;
	poLayer->ResetReading();
	while((poFeature = poLayer->GetNextFeature())!=NULL)
	{
		OGRGeometry *poGeometry;
		poGeometry = poFeature ->GetGeometryRef();
		if(poGeometry!=NULL)
		{	
		   	if(poGeometry ->getGeometryType()==wkbPolygon)
			   _map2d->addGeometry((OGRPolygon*) poGeometry);
			if(poGeometry ->getGeometryType()==wkbMultiPolygon)
			{
				int nPolygons = ((OGRMultiPolygon*)poGeometry)->getNumGeometries();
				for(int i=0;i<nPolygons;i++)
					_map2d->addGeometry((OGRPolygon*)(((OGRMultiPolygon*)poGeometry)->getGeometryRef(i)));
			}

		}
	}

   extrusion();
}
开发者ID:HEShuang,项目名称:3DCityLoD,代码行数:39,代码来源:MapExtruder.cpp

示例13: LoadStyle

// *************************************************************
//		LoadStyle()
// *************************************************************
CStringW OgrStyleHelper::LoadStyle(GDALDataset* dataset, CStringW styleTableName, CStringW layerName, CStringW styleName)
{
	USES_CONVERSION;
	CStringW sql;
	sql.Format(L"SELECT style FROM %s WHERE layername = '%s' AND stylename = '%s'", styleTableName, layerName, styleName);

	CStringW xml = L"";

	bool found = false;
	CPLErrorReset();
	OGRLayer* layer = dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), NULL, NULL);
	if (layer) {
		OGRFeature* ft = layer->GetNextFeature();
		if (ft) {
			const char* s = ft->GetFieldAsString(0);
			if (s) {
				xml = OgrHelper::OgrString2Unicode(s);
			}
			OGRFeature::DestroyFeature(ft);
		}
		dataset->ReleaseResultSet(layer);
	}
	return xml;
}
开发者ID:liuzhumei,项目名称:MapWinGIS,代码行数:27,代码来源:OgrStyle.cpp

示例14: Open

int OGRAmigoCloudDataSource::Open( const char * pszFilename,
                                   char** papszOpenOptionsIn,
                                   int bUpdateIn )

{

    bReadWrite = CPL_TO_BOOL(bUpdateIn);

    pszName = CPLStrdup( pszFilename );
    pszProjectId = CPLStrdup(pszFilename + strlen("AMIGOCLOUD:"));
    char* pchSpace = strchr(pszProjectId, ' ');
    if( pchSpace )
        *pchSpace = '\0';
    if( pszProjectId[0] == 0 )
    {
        CPLError(CE_Failure, CPLE_AppDefined, "Missing project id");
        return FALSE;
    }

    osAPIKey = CSLFetchNameValueDef(papszOpenOptionsIn, "AMIGOCLOUD_API_KEY",
                                    CPLGetConfigOption("AMIGOCLOUD_API_KEY", ""));

    if (osAPIKey.empty())
    {
        osAPIKey = OGRAMIGOCLOUDGetOptionValue(pszFilename, "AMIGOCLOUD_API_KEY");
    }
    if (osAPIKey.empty())
    {
        CPLError(CE_Failure, CPLE_AppDefined, "AMIGOCLOUD_API_KEY is not defined.\n");
        return FALSE;
    }

    OGRLayer* poSchemaLayer = ExecuteSQLInternal("SELECT current_schema()");
    if( poSchemaLayer )
    {
        OGRFeature* poFeat = poSchemaLayer->GetNextFeature();
        if( poFeat )
        {
            if( poFeat->GetFieldCount() == 1 )
            {
                osCurrentSchema = poFeat->GetFieldAsString(0);
            }
            delete poFeat;
        }
        ReleaseResultSet(poSchemaLayer);
    }
    if( osCurrentSchema.empty() )
        return FALSE;

    CPLString osDatasets = OGRAMIGOCLOUDGetOptionValue(pszFilename, "datasets");
    if (!osDatasets.empty())
    {
        char** papszTables = CSLTokenizeString2(osDatasets, ",", 0);
        for(int i=0;papszTables && papszTables[i];i++)
        {

            papoLayers = (OGRAmigoCloudTableLayer**) CPLRealloc(
                papoLayers, (nLayers + 1) * sizeof(OGRAmigoCloudTableLayer*));

            papoLayers[nLayers ++] = new OGRAmigoCloudTableLayer(this, papszTables[i]);
        }
        CSLDestroy(papszTables);

        // If OVERWRITE: YES, truncate the layer.
        if( nLayers==1 &&
            CPLFetchBool(papszOpenOptionsIn, "OVERWRITE", false) )
        {
           TruncateDataset(papoLayers[0]->GetTableName());
        }
        return TRUE;
    } else {
        // If 'datasets' word is in the filename, but no dataset id specified,
        // print the list of available datasets
        if(std::string(pszFilename).find("datasets") != std::string::npos)
            ListDatasets();
    }

    return TRUE;
}
开发者ID:ksshannon,项目名称:gdal,代码行数:79,代码来源:ogramigoclouddatasource.cpp

示例15: ChangeAllBlockState

CPLErr GNMGenericNetwork::ChangeAllBlockState(bool bIsBlock)
{
    if(!m_bIsGraphLoaded && LoadGraph() != CE_None)
    {
        return CE_Failure;
    }

    OGRFeature *poFeature;
    m_poGraphLayer->ResetReading();
    while ((poFeature = m_poGraphLayer->GetNextFeature()) != NULL)
    {
        if(bIsBlock)
        {
            poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_ALL );
        }
        else
        {
            poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_NONE );
        }

        if( m_poGraphLayer->SetFeature( poFeature ) != OGRERR_NONE )
        {
            OGRFeature::DestroyFeature( poFeature );
            CPLError( CE_Failure, CPLE_AppDefined, "Failed to update feature." );
            return CE_Failure;
        }

        OGRFeature::DestroyFeature( poFeature );
    }

    // change all network layers

    for(size_t i = 0; i < m_apoLayers.size(); ++i)
    {
        OGRLayer* poLayer = m_apoLayers[i];
        if(NULL == poLayer)
            continue;
        while ((poFeature = poLayer->GetNextFeature()) != NULL)
        {
            if(bIsBlock)
            {
                poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_ALL );
            }
            else
            {
                poFeature->SetField( GNM_SYSFIELD_BLOCKED, GNM_BLOCK_NONE );
            }

            if( poLayer->SetFeature( poFeature ) != OGRERR_NONE )
            {
                OGRFeature::DestroyFeature( poFeature );
                CPLError( CE_Failure, CPLE_AppDefined, "Failed to update feature." );
                return CE_Failure;
            }

            OGRFeature::DestroyFeature( poFeature );
        }
    }

    m_oGraph.ChangeAllBlockState(bIsBlock);

    return CE_None;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:63,代码来源:gnmgenericnetwork.cpp


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