本文整理汇总了C++中OGRGeomFieldDefn::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeomFieldDefn::GetType方法的具体用法?C++ OGRGeomFieldDefn::GetType怎么用?C++ OGRGeomFieldDefn::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeomFieldDefn
的用法示例。
在下文中一共展示了OGRGeomFieldDefn::GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReportOnLayer
static void ReportOnLayer( OGRLayer * poLayer, int bVerbose )
{
OGRFeatureDefn *poDefn = poLayer->GetLayerDefn();
/* -------------------------------------------------------------------- */
/* Report various overall information. */
/* -------------------------------------------------------------------- */
printf( "\n" );
printf( "Layer name: %s\n", poLayer->GetName() );
if( bVerbose )
{
int nGeomFieldCount =
poLayer->GetLayerDefn()->GetGeomFieldCount();
if( nGeomFieldCount > 1 )
{
for(int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
printf( "Geometry (%s): %s\n", poGFldDefn->GetNameRef(),
OGRGeometryTypeToName( poGFldDefn->GetType() ) );
}
}
else
{
printf( "Geometry: %s\n",
OGRGeometryTypeToName( poLayer->GetGeomType() ) );
}
printf( "Feature Count: " CPL_FRMT_GIB "\n", poLayer->GetFeatureCount() );
OGREnvelope oExt;
if( nGeomFieldCount > 1 )
{
for(int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
if (poLayer->GetExtent(iGeom, &oExt, TRUE) == OGRERR_NONE)
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
CPLprintf("Extent (%s): (%f, %f) - (%f, %f)\n",
poGFldDefn->GetNameRef(),
oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
}
}
}
else if ( poLayer->GetExtent(&oExt, TRUE) == OGRERR_NONE)
{
CPLprintf("Extent: (%f, %f) - (%f, %f)\n",
oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
}
char *pszWKT;
if( nGeomFieldCount > 1 )
{
for(int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
OGRSpatialReference* poSRS = poGFldDefn->GetSpatialRef();
if( poSRS == NULL )
pszWKT = CPLStrdup( "(unknown)" );
else
{
poSRS->exportToPrettyWkt( &pszWKT );
}
printf( "SRS WKT (%s):\n%s\n",
poGFldDefn->GetNameRef(), pszWKT );
CPLFree( pszWKT );
}
}
else
{
if( poLayer->GetSpatialRef() == NULL )
pszWKT = CPLStrdup( "(unknown)" );
else
{
poLayer->GetSpatialRef()->exportToPrettyWkt( &pszWKT );
}
printf( "Layer SRS WKT:\n%s\n", pszWKT );
CPLFree( pszWKT );
}
if( strlen(poLayer->GetFIDColumn()) > 0 )
printf( "FID Column = %s\n",
poLayer->GetFIDColumn() );
for(int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
if( nGeomFieldCount == 1 &&
EQUAL(poGFldDefn->GetNameRef(), "") && poGFldDefn->IsNullable() )
//.........这里部分代码省略.........
示例2: if
//.........这里部分代码省略.........
/* -------------------------------------------------------------------- */
/* Process each data source layer. */
/* -------------------------------------------------------------------- */
for( int iLayer = 0; iLayer < poDS->GetLayerCount(); iLayer++ )
{
OGRLayer *poLayer = poDS->GetLayer(iLayer);
if( poLayer == nullptr )
{
printf("FAILURE: Couldn't fetch advertised layer %d!\n",
iLayer);
exit(1);
}
if( !bAllLayers )
{
printf("%d: %s", iLayer + 1, poLayer->GetName());
const int nGeomFieldCount =
poLayer->GetLayerDefn()->GetGeomFieldCount();
if( nGeomFieldCount > 1 )
{
printf(" (");
for( int iGeom = 0; iGeom < nGeomFieldCount; iGeom++ )
{
if( iGeom > 0 )
printf(", ");
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->
GetGeomFieldDefn(iGeom);
printf(
"%s",
OGRGeometryTypeToName(
poGFldDefn->GetType()));
}
printf(")");
}
else if( poLayer->GetGeomType() != wkbUnknown )
printf(" (%s)",
OGRGeometryTypeToName(
poLayer->GetGeomType()));
printf("\n");
}
else
{
if( iRepeat != 0 )
poLayer->ResetReading();
ReportOnLayer(poLayer, pszWHERE,
pszGeomField, poSpatialFilter,
bListMDD, bShowMetadata, papszExtraMDDomains,
bFeatureCount, bExtent, pszWKTFormat);
}
}
}
else
{
/* -------------------------------------------------------------------- */
/* Process specified data source layers. */
/* -------------------------------------------------------------------- */
for( char** papszIter = papszLayers;
*papszIter != nullptr;
++papszIter )
{
示例3: oField
OGRFeatureDefn *OGRUnionLayer::GetLayerDefn()
{
if( poFeatureDefn != NULL )
return poFeatureDefn;
poFeatureDefn = new OGRFeatureDefn( osName );
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType(wkbNone);
int iCompareFirstIndex = 0;
if( osSourceLayerFieldName.size() )
{
OGRFieldDefn oField(osSourceLayerFieldName, OFTString);
poFeatureDefn->AddFieldDefn(&oField);
iCompareFirstIndex = 1;
}
if( eFieldStrategy == FIELD_SPECIFIED )
{
int i;
for(i = 0; i < nFields; i++)
poFeatureDefn->AddFieldDefn(papoFields[i]);
for(i = 0; i < nGeomFields; i++)
{
poFeatureDefn->AddGeomFieldDefn(new OGRUnionLayerGeomFieldDefn(papoGeomFields[i]), FALSE);
OGRUnionLayerGeomFieldDefn* poGeomFieldDefn =
(OGRUnionLayerGeomFieldDefn* ) poFeatureDefn->GetGeomFieldDefn(i);
if( poGeomFieldDefn->bGeomTypeSet == FALSE ||
poGeomFieldDefn->bSRSSet == FALSE )
{
for(int iLayer = 0; iLayer < nSrcLayers; iLayer++)
{
OGRFeatureDefn* poSrcFeatureDefn =
papoSrcLayers[iLayer]->GetLayerDefn();
int nIndex =
poSrcFeatureDefn->GetGeomFieldIndex(poGeomFieldDefn->GetNameRef());
if( nIndex >= 0 )
{
OGRGeomFieldDefn* poSrcGeomFieldDefn =
poSrcFeatureDefn->GetGeomFieldDefn(nIndex);
if( poGeomFieldDefn->bGeomTypeSet == FALSE )
{
poGeomFieldDefn->bGeomTypeSet = TRUE;
poGeomFieldDefn->SetType(poSrcGeomFieldDefn->GetType());
}
if( poGeomFieldDefn->bSRSSet == FALSE )
{
poGeomFieldDefn->bSRSSet = TRUE;
poGeomFieldDefn->SetSpatialRef(poSrcGeomFieldDefn->GetSpatialRef());
if( i == 0 && poGlobalSRS == NULL )
{
poGlobalSRS = poSrcGeomFieldDefn->GetSpatialRef();
if( poGlobalSRS != NULL )
poGlobalSRS->Reference();
}
}
break;
}
}
}
}
}
else if( eFieldStrategy == FIELD_FROM_FIRST_LAYER )
{
OGRFeatureDefn* poSrcFeatureDefn = papoSrcLayers[0]->GetLayerDefn();
int i;
for(i = 0; i < poSrcFeatureDefn->GetFieldCount(); i++)
poFeatureDefn->AddFieldDefn(poSrcFeatureDefn->GetFieldDefn(i));
for(i = 0; nGeomFields != - 1 && i < poSrcFeatureDefn->GetGeomFieldCount(); i++)
{
OGRGeomFieldDefn* poFldDefn = poSrcFeatureDefn->GetGeomFieldDefn(i);
poFeatureDefn->AddGeomFieldDefn(
new OGRUnionLayerGeomFieldDefn(poFldDefn), FALSE);
}
}
else if (eFieldStrategy == FIELD_UNION_ALL_LAYERS )
{
if( nGeomFields == 1 )
{
poFeatureDefn->AddGeomFieldDefn(
new OGRUnionLayerGeomFieldDefn(papoGeomFields[0]), FALSE);
}
for(int iLayer = 0; iLayer < nSrcLayers; iLayer++)
{
OGRFeatureDefn* poSrcFeatureDefn =
papoSrcLayers[iLayer]->GetLayerDefn();
/* Add any field that is found in the source layers */
int i;
for(i = 0; i < poSrcFeatureDefn->GetFieldCount(); i++)
{
OGRFieldDefn* poSrcFieldDefn = poSrcFeatureDefn->GetFieldDefn(i);
int nIndex =
poFeatureDefn->GetFieldIndex(poSrcFieldDefn->GetNameRef());
if( nIndex < 0 )
poFeatureDefn->AddFieldDefn(poSrcFieldDefn);
else
{
//.........这里部分代码省略.........
示例4: ReportOnLayer
static void ReportOnLayer( OGRLayer * poLayer, const char *pszWHERE,
const char* pszGeomField,
OGRGeometry *poSpatialFilter,
bool bListMDD,
bool bShowMetadata,
char** papszExtraMDDomains,
bool bFeatureCount,
bool bExtent,
const char* pszWKTFormat )
{
OGRFeatureDefn *poDefn = poLayer->GetLayerDefn();
/* -------------------------------------------------------------------- */
/* Set filters if provided. */
/* -------------------------------------------------------------------- */
if( pszWHERE != nullptr )
{
if( poLayer->SetAttributeFilter(pszWHERE) != OGRERR_NONE )
{
printf("FAILURE: SetAttributeFilter(%s) failed.\n", pszWHERE);
exit(1);
}
}
if( poSpatialFilter != nullptr )
{
if( pszGeomField != nullptr )
{
const int iGeomField = poDefn->GetGeomFieldIndex(pszGeomField);
if( iGeomField >= 0 )
poLayer->SetSpatialFilter(iGeomField, poSpatialFilter);
else
printf("WARNING: Cannot find geometry field %s.\n",
pszGeomField);
}
else
{
poLayer->SetSpatialFilter(poSpatialFilter);
}
}
/* -------------------------------------------------------------------- */
/* Report various overall information. */
/* -------------------------------------------------------------------- */
if( !bSuperQuiet )
{
printf("\n");
printf("Layer name: %s\n", poLayer->GetName());
}
GDALInfoReportMetadata(static_cast<GDALMajorObjectH>(poLayer),
bListMDD,
bShowMetadata,
papszExtraMDDomains);
if( bVerbose )
{
const int nGeomFieldCount =
poLayer->GetLayerDefn()->GetGeomFieldCount();
if( nGeomFieldCount > 1 )
{
for(int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
printf("Geometry (%s): %s\n", poGFldDefn->GetNameRef(),
OGRGeometryTypeToName(poGFldDefn->GetType()));
}
}
else
{
printf("Geometry: %s\n",
OGRGeometryTypeToName(poLayer->GetGeomType()));
}
if( bFeatureCount )
printf("Feature Count: " CPL_FRMT_GIB "\n",
poLayer->GetFeatureCount());
OGREnvelope oExt;
if( bExtent && nGeomFieldCount > 1 )
{
for( int iGeom = 0;iGeom < nGeomFieldCount; iGeom ++ )
{
if( poLayer->GetExtent(iGeom, &oExt, TRUE) == OGRERR_NONE )
{
OGRGeomFieldDefn* poGFldDefn =
poLayer->GetLayerDefn()->GetGeomFieldDefn(iGeom);
CPLprintf("Extent (%s): (%f, %f) - (%f, %f)\n",
poGFldDefn->GetNameRef(),
oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
}
}
}
else if( bExtent && poLayer->GetExtent(&oExt, TRUE) == OGRERR_NONE )
{
CPLprintf("Extent: (%f, %f) - (%f, %f)\n",
oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY);
}
//.........这里部分代码省略.........