本文整理汇总了C++中OGRLayer::SetStyleTable方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLayer::SetStyleTable方法的具体用法?C++ OGRLayer::SetStyleTable怎么用?C++ OGRLayer::SetStyleTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRLayer
的用法示例。
在下文中一共展示了OGRLayer::SetStyleTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
//.........这里部分代码省略.........