本文整理汇总了C++中OGRLayer::ResetReading方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLayer::ResetReading方法的具体用法?C++ OGRLayer::ResetReading怎么用?C++ OGRLayer::ResetReading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRLayer
的用法示例。
在下文中一共展示了OGRLayer::ResetReading方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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");
}
}
示例4: 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;
}
示例5: 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;
}
示例6:
//---------------------------------------------------------
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 );
}
示例7: 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;
}
示例8: GetLayer
OGRLayer* OGRGeoJSONDataSource::GetLayer( int nLayer )
{
if( 0 <= nLayer || nLayer < nLayers_ )
{
CPLAssert( NULL != papoLayers_[nLayer] );
OGRLayer* poLayer = papoLayers_[nLayer];
/* Return layer in readable state. */
poLayer->ResetReading();
return poLayer;
}
return NULL;
}
示例9: 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;
}
示例10: 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);
}
示例11: GetFirstStationLine
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;
}
}
示例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();
}
示例13: OGRPointToLatLon
bool OGRPointToLatLon(double &x, double &y, OGRDataSourceH hDS,
const char *datum) {
char *pszPrj = NULL;
OGRSpatialReference *poSrcSRS;
OGRSpatialReference oSourceSRS, oTargetSRS;
OGRCoordinateTransformation *poCT;
if (hDS == NULL) {
return false;
}
OGRLayer *poLayer;
poLayer = (OGRLayer *)OGR_DS_GetLayer(hDS, 0);
poLayer->ResetReading();
poSrcSRS = poLayer->GetSpatialRef();
if (poSrcSRS == NULL) {
return false;
}
oTargetSRS.SetWellKnownGeogCS(datum);
poCT = OGRCreateCoordinateTransformation(poSrcSRS, &oTargetSRS);
if (poCT == NULL) {
return false;
}
if (!poCT->Transform(1, &x, &y)) {
OGRCoordinateTransformation::DestroyCT(poCT);
return false;
}
OGRCoordinateTransformation::DestroyCT(poCT);
return true;
}
示例14: loadCountyShapes
bool MapWidget::loadCountyShapes()
{
OGRRegisterAll();
std::string filename = g_dataDirectory + "/counties/tl_2009_48_county00.shp";
OGRDataSource * dataSource = OGRSFDriverRegistrar::Open(filename.c_str(), false);
if(dataSource == NULL)
{
put_flog(LOG_ERROR, "could not open %s", filename.c_str());
return false;
}
OGRLayer * layer = dataSource->GetLayerByName("tl_2009_48_county00");
layer->ResetReading();
OGRFeature * feature;
while((feature = layer->GetNextFeature()) != NULL)
{
// get county FIPS code
int nodeId = feature->GetFieldAsInteger("COUNTYFP00");
if(nodeId == 0)
{
put_flog(LOG_WARN, "invalid county");
}
// add a new county to the counties map corresponding to this nodeId
boost::shared_ptr<MapShape> county(new MapShape());
counties_[nodeId] = county;
OGRGeometry * geometry = feature->GetGeometryRef();
if(geometry != NULL && geometry->getGeometryType() == wkbPolygon)
{
OGRPolygon * polygon = (OGRPolygon *)geometry;
OGRLinearRing * ring = polygon->getExteriorRing();
for(int i=0; i<ring->getNumPoints(); i++)
{
// x is longitude, y latitude
county->addVertex(ring->getY(i), ring->getX(i));
}
// set the centroid
OGRPoint centroidPoint;
if(polygon->Centroid(¢roidPoint) == OGRERR_NONE)
{
county->setCentroid(centroidPoint.getY(), centroidPoint.getX());
}
else
{
put_flog(LOG_WARN, "no polygon centroid");
}
}
else
{
put_flog(LOG_WARN, "no polygon geometry");
}
OGRFeature::DestroyFeature(feature);
}
OGRDataSource::DestroyDataSource(dataSource);
return true;
}
示例15: createObstaclesTables
bool ShortNavigation::createObstaclesTables()
{
// OGRLayer* layer;
status = true;
if ( !status==false ) {
qDebug()<<"bool ShortNavigation::createObstaclesTables()";
/// POINT_OFFSET is the area around the obstacle,
/// so is it's value is 5, it will draw 10 m^2
//float POINT_OFFSET = settingsManager->getPOffset();
float POINT_OFFSET = 5; //test values, above comment from old code
//float NOT_ALLOWED_DEPTH = settingsManager->getMinDepth();
float NOT_ALLOWED_DEPTH = 2; //test values, above comment from old code
/// signsound with depth from 0 to this value are
/// taken in consideration for the obstacles layer
//float SIGNSOUND_THRESHOLD = settingsManager->getSignsound();
float SIGNSOUND_THRESHOLD = 1; //test values, above comment from old code
// ##################################################
// list of polygon layers considered obstacles
QList<QString> polygon_layers;
polygon_layers.append("generarea_r");
// list of point layers to be considered as obstacles
QList<QString> point_layers;
point_layers.append("rock_p");
point_layers.append("wreck_p");
point_layers.append("navaid_p");
point_layers.append("signsound_p");
// line layers to be considered as obstacles
QList<QString> line_layers;
line_layers.append("depthcont_l");
//####################################################
for (int i = 0 ; i < this->chartObjects.size(); i++) {
// qDebug() << "chartObjects size" << chartObjects.size();
if(this->chartObjects.at(i)->getTableName() == "generarea_r") {
for (int j = 0 ; j < this->chartObjects.at(i)->getCoordinateGeometry().size();j++) {
this->polyObstacles.append(this->chartObjects.at(i)->getCoordinateGeometry().at(j));
}
}
if(this->chartObjects.at(i)->getTableName() == "depthcont_l") {
for (int j = 0 ; j < this->chartObjects.at(i)->getCoordinateGeometry().size();j++) { //TODO: parse line from polygon
//this->lineObstacles.append(this->chartObjects.at(i)->getCoordinateGeometry().at(j)); //Not used in Shortnavigation -> can be removed!
}
}
if(this->chartObjects.at(i)->getTableName() == "rock_p") {
for (int j = 0 ; j < this->chartObjects.at(i)->getCoordinateGeometry().size();j++) { //need to check how vectors are written from DB. is getfeaturecount = polygonvector.size ?
for(int k = 0; k < this->chartObjects.at(i)->getCoordinateGeometry().at(j).size();k++) {
this->pointObstacles.append(this->chartObjects.at(i)->getCoordinateGeometry().at(j).at(k));
}
}
}
if(this->chartObjects.at(i)->getTableName() == "wreck_p") {
for (int j = 0 ; j < this->chartObjects.at(i)->getCoordinateGeometry().size();j++) {
for(int k = 0; k < this->chartObjects.at(i)->getCoordinateGeometry().at(j).size();k++) {
this->pointObstacles.append(this->chartObjects.at(i)->getCoordinateGeometry().at(j).at(k));
}
}
}
if(this->chartObjects.at(i)->getTableName() == "navaid_p") {
for (int j = 0 ; j < this->chartObjects.at(i)->getCoordinateGeometry().size();j++) {
for(int k = 0; k < this->chartObjects.at(i)->getCoordinateGeometry().at(j).size();k++) {
this->pointObstacles.append(this->chartObjects.at(i)->getCoordinateGeometry().at(j).at(k));
}
}
}
if(this->chartObjects.at(i)->getTableName() == "signsound_p") {
QVector<QPolygonF> qpoint;
QList<QPointF> listqpoint;
OGRLayer* layer;
OGRFeatureDefn *poFDefn;
OGRFeature *poFeature;
qpoint = this->chartObjects.at(i)->getCoordinateGeometry();
for(int n = 0; n < qpoint.size(); n++){
listqpoint = qpoint.value(n).toList();
}
layer = this->chartObjects.at(i)->getFeatureData();
layer->ResetReading();
QString /*sql("SELECT * FROM *"); //FIX THIS! //*/ sql("SELECT * FROM ( SELECT DISTINCT Intersects( wkb_geometry, ");
for(int m= 0; m < layer->GetFeatureCount();m++ ) {
poFDefn = layer->GetLayerDefn();
poFeature = layer->GetNextFeature();
for(int j = 0; j < poFDefn->GetFieldCount(); j++ ){
OGRFieldDefn *poFieldDefn = poFDefn->GetFieldDefn( j );
QString str = poFieldDefn->GetNameRef();
if(str.contains("depth") == true) {
if (poFeature->GetFieldAsDouble(j) < SIGNSOUND_THRESHOLD) { //parse out depths above signsound threshold since they are not obstacles
pointObstacles.append(listqpoint.at(m));
}
//.........这里部分代码省略.........