本文整理汇总了C++中OGRFeature::StealGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFeature::StealGeometry方法的具体用法?C++ OGRFeature::StealGeometry怎么用?C++ OGRFeature::StealGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFeature
的用法示例。
在下文中一共展示了OGRFeature::StealGeometry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
OGRFeature *OGRWarpedLayer::GetNextFeature()
{
while(TRUE)
{
OGRFeature* poFeature = m_poDecoratedLayer->GetNextFeature();
if( poFeature == NULL )
return NULL;
OGRGeometry* poGeom = poFeature->GetGeometryRef();
if( poGeom == NULL )
return poFeature;
if( poGeom->transform(m_poCT) != OGRERR_NONE )
{
delete poFeature->StealGeometry();
}
else
{
if( m_poFilterGeom != NULL && !FilterGeometry( poGeom ) )
{
delete poFeature;
continue;
}
}
return poFeature;
}
}
示例2:
OGRFeature *OGRWarpedLayer::GetFeature( long nFID )
{
OGRFeature* poFeature = m_poDecoratedLayer->GetFeature(nFID);
if( poFeature != NULL )
{
OGRGeometry* poGeom = poFeature->GetGeometryRef();
if( poGeom != NULL && poGeom->transform(m_poCT) != OGRERR_NONE )
{
delete poFeature->StealGeometry();
}
}
return poFeature;
}
示例3: OGRFeature
OGRFeature *OGRWarpedLayer::SrcFeatureToWarpedFeature(OGRFeature* poSrcFeature)
{
OGRFeature* poFeature = new OGRFeature(GetLayerDefn());
poFeature->SetFrom(poSrcFeature);
poFeature->SetFID(poSrcFeature->GetFID());
OGRGeometry* poGeom = poFeature->GetGeomFieldRef(m_iGeomField);
if( poGeom == NULL )
return poFeature;
if( poGeom->transform(m_poCT) != OGRERR_NONE )
{
delete poFeature->StealGeometry(m_iGeomField);
}
return poFeature;
}
示例4: GetNextRawFeature
OGRFeature* OGRPLScenesLayer::GetNextRawFeature()
{
if( bEOF ||
(!bFilterMustBeClientSideEvaluated && nFeatureCount >= 0 && nNextFID > nFeatureCount) )
return NULL;
if( poGeoJSONLayer == NULL )
{
if( !GetNextPage() )
return NULL;
}
#ifdef notdef
if( CSLTestBoolean(CPLGetConfigOption("OGR_LIMIT_TOO_MANY_FEATURES", "FALSE")) &&
nFeatureCount > nPageSize )
{
bEOF = TRUE;
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
OGRGeometry* poGeom;
const char* pszWKT = "MULTIPOLYGON(((-180 90,180 90,180 -90,-180 -90,-180 90)))";
OGRGeometryFactory::createFromWkt((char**)&pszWKT, poSRS, &poGeom);
poFeature->SetGeometryDirectly(poGeom);
return poFeature;
}
#endif
OGRFeature* poGeoJSONFeature = poGeoJSONLayer->GetNextFeature();
if( poGeoJSONFeature == NULL )
{
osRequestURL = osNextURL;
bStillInFirstPage = FALSE;
if( !GetNextPage() )
return NULL;
poGeoJSONFeature = poGeoJSONLayer->GetNextFeature();
if( poGeoJSONFeature == NULL )
{
bEOF = TRUE;
return NULL;
}
}
OGRFeature* poFeature = new OGRFeature(poFeatureDefn);
poFeature->SetFID(nNextFID++);
OGRGeometry* poGeom = poGeoJSONFeature->StealGeometry();
if( poGeom != NULL )
{
if( poGeom->getGeometryType() == wkbPolygon )
{
OGRMultiPolygon* poMP = new OGRMultiPolygon();
poMP->addGeometryDirectly(poGeom);
poGeom = poMP;
}
poGeom->assignSpatialReference(poSRS);
poFeature->SetGeometryDirectly(poGeom);
}
for(int i=0;i<poFeatureDefn->GetFieldCount();i++)
{
OGRFieldDefn* poFieldDefn = poFeatureDefn->GetFieldDefn(i);
OGRFieldType eType = poFieldDefn->GetType();
int iSrcField = poGeoJSONFeature->GetFieldIndex(poFieldDefn->GetNameRef());
if( iSrcField >= 0 && poGeoJSONFeature->IsFieldSet(iSrcField) )
{
if( eType == OFTInteger )
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsInteger(iSrcField));
else if( eType == OFTReal )
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsDouble(iSrcField));
else
poFeature->SetField(i,
poGeoJSONFeature->GetFieldAsString(iSrcField));
}
}
delete poGeoJSONFeature;
return poFeature;
}
示例5: ReadBlocksSection
void OGRDXFDataSource::ReadBlocksSection()
{
char szLineBuf[257];
int nCode;
OGRDXFLayer *poReaderLayer = (OGRDXFLayer *) GetLayerByName( "Entities" );
iEntitiesSectionOffset = oReader.iSrcBufferFileOffset + oReader.iSrcBufferOffset;
while( (nCode = ReadValue( szLineBuf, sizeof(szLineBuf) )) > -1
&& !EQUAL(szLineBuf,"ENDSEC") )
{
// We are only interested in extracting blocks.
if( nCode != 0 || !EQUAL(szLineBuf,"BLOCK") )
continue;
// Process contents of BLOCK definition till we find the
// first entity.
CPLString osBlockName;
while( (nCode = ReadValue( szLineBuf,sizeof(szLineBuf) )) > 0 )
{
if( nCode == 2 )
osBlockName = szLineBuf;
// anything else we want?
}
if( EQUAL(szLineBuf,"ENDBLK") )
continue;
UnreadValue();
// Now we will process entities till we run out at the ENDBLK code.
// we aggregate the geometries of the features into a multi-geometry,
// but throw away other stuff attached to the features.
OGRFeature *poFeature;
OGRGeometryCollection *poColl = new OGRGeometryCollection();
std::vector<OGRFeature*> apoFeatures;
while( (poFeature = poReaderLayer->GetNextUnfilteredFeature()) != NULL )
{
if( poFeature->GetStyleString() != NULL
&& strstr(poFeature->GetStyleString(),"LABEL") != NULL )
{
apoFeatures.push_back( poFeature );
}
else
{
poColl->addGeometryDirectly( poFeature->StealGeometry() );
delete poFeature;
}
}
if( poColl->getNumGeometries() == 0 )
delete poColl;
else
oBlockMap[osBlockName].poGeometry = SimplifyBlockGeometry(poColl);
if( apoFeatures.size() > 0 )
oBlockMap[osBlockName].apoFeatures = apoFeatures;
}
CPLDebug( "DXF", "Read %d blocks with meaningful geometry.",
(int) oBlockMap.size() );
}
示例6: ReadBlocksSection
void OGRDWGDataSource::ReadBlocksSection()
{
OGRDWGLayer *poReaderLayer = (OGRDWGLayer *) GetLayerByName( "Entities" );
int bMergeBlockGeometries = CSLTestBoolean(
CPLGetConfigOption( "DWG_MERGE_BLOCK_GEOMETRIES", "TRUE" ) );
/* -------------------------------------------------------------------- */
/* Loop over all the block tables, skipping *Model_Space which */
/* we assume is primary entities. */
/* -------------------------------------------------------------------- */
OdDbBlockTableRecordPtr poModelSpace, poBlock;
OdDbBlockTablePtr pTable = GetDB()->getBlockTableId().safeOpenObject();
OdDbSymbolTableIteratorPtr pBlkIter = pTable->newIterator();
for (pBlkIter->start(); ! pBlkIter->done(); pBlkIter->step())
{
poBlock = pBlkIter->getRecordId().safeOpenObject();
CPLString osBlockName = (const char *) poBlock->getName();
if( EQUAL(osBlockName,"*Model_Space") )
{
poModelSpace = poBlock;
continue;
}
poReaderLayer->SetBlockTable( poBlock );
// Now we will process entities till we run out.
// We aggregate the geometries of the features into a multi-geometry,
// but throw away other stuff attached to the features.
OGRFeature *poFeature;
OGRGeometryCollection *poColl = new OGRGeometryCollection();
std::vector<OGRFeature*> apoFeatures;
while( (poFeature = poReaderLayer->GetNextUnfilteredFeature()) != NULL )
{
if( (poFeature->GetStyleString() != NULL
&& strstr(poFeature->GetStyleString(),"LABEL") != NULL)
|| !bMergeBlockGeometries )
{
apoFeatures.push_back( poFeature );
}
else
{
poColl->addGeometryDirectly( poFeature->StealGeometry() );
delete poFeature;
}
}
if( poColl->getNumGeometries() == 0 )
delete poColl;
else
oBlockMap[osBlockName].poGeometry = SimplifyBlockGeometry(poColl);
if( apoFeatures.size() > 0 )
oBlockMap[osBlockName].apoFeatures = apoFeatures;
}
CPLDebug( "DWG", "Read %d blocks with meaningful geometry.",
(int) oBlockMap.size() );
poReaderLayer->SetBlockTable( poModelSpace );
}
示例7: CacheLayer
bool GdaCache::CacheLayer(std::string ext_ds_name,
OGRLayerProxy* ext_layer_proxy)
{
OGRLayer* poSrcLayer = ext_layer_proxy->layer;
// get information from current layer: geomtype, layer_name
// (NOTE: we don't consider coodinator system and translation here)
OGRFeatureDefn *poSrcFDefn = poSrcLayer->GetLayerDefn();
int eGType = poSrcFDefn->GetGeomType();
const char* pszNewLayerName = poSrcLayer->GetName();
int bForceToPolygon = FALSE;
int bForceToMultiPolygon = FALSE;
int bForceToMultiLineString = FALSE;
if( wkbFlatten(eGType) == wkbPolygon )
bForceToPolygon = TRUE;
else if( wkbFlatten(eGType) == wkbMultiPolygon )
bForceToMultiPolygon = TRUE;
else if( wkbFlatten(eGType) == wkbMultiLineString )
bForceToMultiLineString = TRUE;
//Setup coordinate transformation if we need it.
OGRCoordinateTransformation *poCT = NULL;
bool bTransform = FALSE;
OGRSpatialReference *poSourceSRS = NULL;
// todo
OGRSpatialReference *poOutputSRS = new OGRSpatialReference("EPSG:4326");
// Cache
char *papszLCO[] = {"OVERWRITE=yes","FORMAT=Spatialite"};
std::string cache_layer_name = ext_ds_name + "_"+ext_layer_proxy->name;
OGRDataSource *poDstDS = cach_ds_proxy->ds;
OGRLayer *poDstLayer = poDstDS->CreateLayer(cache_layer_name.c_str(),
poOutputSRS,
(OGRwkbGeometryType)eGType,
papszLCO);
if (poDstLayer == NULL) {
// raise create cache failed.
return false;
}
// Process Layer style table
poDstLayer->SetStyleTable( poSrcLayer->GetStyleTable () );
// Add fields. here to copy all field.
int nSrcFieldCount = poSrcFDefn->GetFieldCount();
int iField;
OGRFeatureDefn *poDstFDefn = poDstLayer->GetLayerDefn();
for( iField = 0; iField < nSrcFieldCount; iField++ )
{
OGRFieldDefn* poSrcFieldDefn = poSrcFDefn->GetFieldDefn(iField);
OGRFieldDefn oFieldDefn( poSrcFieldDefn );
// The field may have been already created at layer creation
if (poDstLayer->CreateField( &oFieldDefn ) == OGRERR_NONE)
{
// now that we've created a field, GetLayerDefn() won't return NULL
if (poDstFDefn == NULL)
poDstFDefn = poDstLayer->GetLayerDefn();
}
}
// Transfer feature from Source Layer to Dest Layer
OGRFeature *poFeature;
GIntBig nFeaturesWritten = 0;
poSrcLayer->ResetReading();
while (poFeature = poSrcLayer->GetNextFeature())
{
OGRFeature *poDstFeature = OGRFeature::CreateFeature(
poDstLayer->GetLayerDefn() );
poDstFeature->SetFrom(poFeature);
OGRGeometry *poDstGeometry = poDstFeature->GetGeometryRef();
if (poDstGeometry != NULL)
{
if( bForceToPolygon )
{
poDstFeature->SetGeometryDirectly(
OGRGeometryFactory::forceToPolygon(
poDstFeature->StealGeometry()));
}
else if( bForceToMultiPolygon )
{
poDstFeature->SetGeometryDirectly(
OGRGeometryFactory::forceToMultiPolygon(
poDstFeature->StealGeometry() ) );
}
else if ( bForceToMultiLineString )
{
poDstFeature->SetGeometryDirectly(
OGRGeometryFactory::forceToMultiLineString(
poDstFeature->StealGeometry() ) );
}
}
if( poDstLayer->CreateFeature( poDstFeature ) == OGRERR_NONE )
{
nFeaturesWritten ++;
}
OGRFeature::DestroyFeature( poDstFeature );
//.........这里部分代码省略.........