本文整理汇总了C++中OGRFieldDefn::GetSubType方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRFieldDefn::GetSubType方法的具体用法?C++ OGRFieldDefn::GetSubType怎么用?C++ OGRFieldDefn::GetSubType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRFieldDefn
的用法示例。
在下文中一共展示了OGRFieldDefn::GetSubType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
OGRErr OGRLayerWithTransaction::AlterFieldDefn( int iField,
OGRFieldDefn* poNewFieldDefn,
int nFlags )
{
if( !m_poDecoratedLayer ) return OGRERR_FAILURE;
OGRErr eErr = m_poDecoratedLayer->AlterFieldDefn(iField, poNewFieldDefn, nFlags);
if( m_poFeatureDefn && eErr == OGRERR_NONE )
{
OGRFieldDefn* poSrcFieldDefn = m_poDecoratedLayer->GetLayerDefn()->GetFieldDefn(iField);
OGRFieldDefn* poDstFieldDefn = m_poFeatureDefn->GetFieldDefn(iField);
poDstFieldDefn->SetName(poSrcFieldDefn->GetNameRef());
poDstFieldDefn->SetType(poSrcFieldDefn->GetType());
poDstFieldDefn->SetSubType(poSrcFieldDefn->GetSubType());
poDstFieldDefn->SetWidth(poSrcFieldDefn->GetWidth());
poDstFieldDefn->SetPrecision(poSrcFieldDefn->GetPrecision());
poDstFieldDefn->SetDefault(poSrcFieldDefn->GetDefault());
poDstFieldDefn->SetNullable(poSrcFieldDefn->IsNullable());
}
return eErr;
}
示例2: OGRGeoJSONWriteAttributes
json_object* OGRGeoJSONWriteAttributes( OGRFeature* poFeature )
{
CPLAssert( NULL != poFeature );
json_object* poObjProps = json_object_new_object();
CPLAssert( NULL != poObjProps );
OGRFeatureDefn* poDefn = poFeature->GetDefnRef();
for( int nField = 0; nField < poDefn->GetFieldCount(); ++nField )
{
json_object* poObjProp;
OGRFieldDefn* poFieldDefn = poDefn->GetFieldDefn( nField );
CPLAssert( NULL != poFieldDefn );
OGRFieldType eType = poFieldDefn->GetType();
OGRFieldSubType eSubType = poFieldDefn->GetSubType();
if( !poFeature->IsFieldSet(nField) )
{
poObjProp = NULL;
}
else if( OFTInteger == eType )
{
if( eSubType == OFSTBoolean )
poObjProp = json_object_new_boolean(
poFeature->GetFieldAsInteger( nField ) );
else
poObjProp = json_object_new_int(
poFeature->GetFieldAsInteger( nField ) );
}
else if( OFTInteger64 == eType )
{
if( eSubType == OFSTBoolean )
poObjProp = json_object_new_boolean(
(json_bool)poFeature->GetFieldAsInteger64( nField ) );
else
poObjProp = json_object_new_int64(
poFeature->GetFieldAsInteger64( nField ) );
}
else if( OFTReal == eType )
{
poObjProp = json_object_new_double(
poFeature->GetFieldAsDouble(nField) );
}
else if( OFTString == eType )
{
poObjProp = json_object_new_string(
poFeature->GetFieldAsString(nField) );
}
else if( OFTIntegerList == eType )
{
int nSize = 0;
const int* panList = poFeature->GetFieldAsIntegerList(nField, &nSize);
poObjProp = json_object_new_array();
for(int i=0;i<nSize;i++)
{
if( eSubType == OFSTBoolean )
json_object_array_add(poObjProp,
json_object_new_boolean(panList[i]));
else
json_object_array_add(poObjProp,
json_object_new_int(panList[i]));
}
}
else if( OFTInteger64List == eType )
{
int nSize = 0;
const GIntBig* panList = poFeature->GetFieldAsInteger64List(nField, &nSize);
poObjProp = json_object_new_array();
for(int i=0;i<nSize;i++)
{
if( eSubType == OFSTBoolean )
json_object_array_add(poObjProp,
json_object_new_boolean((json_bool)panList[i]));
else
json_object_array_add(poObjProp,
json_object_new_int64(panList[i]));
}
}
else if( OFTRealList == eType )
{
int nSize = 0;
const double* padfList = poFeature->GetFieldAsDoubleList(nField, &nSize);
poObjProp = json_object_new_array();
for(int i=0;i<nSize;i++)
{
json_object_array_add(poObjProp,
json_object_new_double(padfList[i]));
}
}
else if( OFTStringList == eType )
{
char** papszStringList = poFeature->GetFieldAsStringList(nField);
poObjProp = json_object_new_array();
for(int i=0; papszStringList && papszStringList[i]; i++)
{
json_object_array_add(poObjProp,
json_object_new_string(papszStringList[i]));
}
}
else
//.........这里部分代码省略.........
示例3: ReportOnLayer
//.........这里部分代码省略.........
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() )
break;
printf( "Geometry Column ");
if( nGeomFieldCount > 1 )
printf("%d ", iGeom + 1);
if( !poGFldDefn->IsNullable() )
printf("NOT NULL ");
printf("= %s\n", poGFldDefn->GetNameRef() );
}
for( int iAttr = 0; iAttr < poDefn->GetFieldCount(); iAttr++ )
{
OGRFieldDefn *poField = poDefn->GetFieldDefn( iAttr );
const char* pszType = (poField->GetSubType() != OFSTNone) ?
CPLSPrintf("%s(%s)",
poField->GetFieldTypeName( poField->GetType() ),
poField->GetFieldSubTypeName(poField->GetSubType())) :
poField->GetFieldTypeName( poField->GetType() );
printf( "%s: %s (%d.%d)",
poField->GetNameRef(),
pszType,
poField->GetWidth(),
poField->GetPrecision() );
if( !poField->IsNullable() )
printf(" NOT NULL");
if( poField->GetDefault() != NULL )
printf(" DEFAULT %s", poField->GetDefault() );
printf( "\n" );
}
}
/* -------------------------------------------------------------------- */
/* Read, and dump features. */
/* -------------------------------------------------------------------- */
OGRFeature *poFeature = NULL;
while( (poFeature = poLayer->GetNextFeature()) != NULL )
{
poFeature->DumpReadable( NULL );
OGRFeature::DestroyFeature( poFeature );
}
}
示例4: ReportOnLayer
//.........这里部分代码省略.........
CPLFree(pszWKT);
if( poSRS )
{
displayDataAxisMapping(poSRS);
}
}
}
else
{
char *pszWKT = nullptr;
auto poSRS = poLayer->GetSpatialRef();
if( poSRS == nullptr )
{
pszWKT = CPLStrdup("(unknown)");
}
else
{
poSRS->exportToPrettyWkt(&pszWKT);
}
printf("Layer SRS WKT:\n%s\n", pszWKT);
CPLFree(pszWKT);
if( poSRS )
{
displayDataAxisMapping(poSRS);
}
}
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() )
break;
printf("Geometry Column ");
if( nGeomFieldCount > 1 )
printf("%d ", iGeom + 1);
if( !poGFldDefn->IsNullable() )
printf("NOT NULL ");
printf("= %s\n", poGFldDefn->GetNameRef());
}
for( int iAttr = 0; iAttr < poDefn->GetFieldCount(); iAttr++ )
{
OGRFieldDefn *poField = poDefn->GetFieldDefn(iAttr);
const char* pszType = (poField->GetSubType() != OFSTNone)
? CPLSPrintf(
"%s(%s)",
poField->GetFieldTypeName(poField->GetType()),
poField->GetFieldSubTypeName(poField->GetSubType()))
: poField->GetFieldTypeName(poField->GetType());
printf("%s: %s (%d.%d)",
poField->GetNameRef(),
pszType,
poField->GetWidth(),
poField->GetPrecision());
if( !poField->IsNullable() )
printf(" NOT NULL");
if( poField->GetDefault() != nullptr )
printf(" DEFAULT %s", poField->GetDefault());
printf("\n");
}
}
/* -------------------------------------------------------------------- */
/* Read, and dump features. */
/* -------------------------------------------------------------------- */
if( nFetchFID == OGRNullFID && !bSummaryOnly )
{
OGRFeature *poFeature = nullptr;
while( (poFeature = poLayer->GetNextFeature()) != nullptr )
{
if( !bSuperQuiet )
poFeature->DumpReadable(nullptr, papszOptions);
OGRFeature::DestroyFeature(poFeature);
}
}
else if( nFetchFID != OGRNullFID )
{
OGRFeature *poFeature = poLayer->GetFeature(nFetchFID);
if( poFeature == nullptr )
{
printf("Unable to locate feature id " CPL_FRMT_GIB
" on this layer.\n",
nFetchFID);
}
else
{
poFeature->DumpReadable(nullptr, papszOptions);
OGRFeature::DestroyFeature(poFeature);
}
}
}
示例5: Compile
OGRErr OGRFeatureQuery::Compile( OGRFeatureDefn *poDefn,
const char * pszExpression,
int bCheck,
swq_custom_func_registrar* poCustomFuncRegistrar )
{
/* -------------------------------------------------------------------- */
/* Clear any existing expression. */
/* -------------------------------------------------------------------- */
if( pSWQExpr != NULL )
{
delete (swq_expr_node *) pSWQExpr;
pSWQExpr = NULL;
}
/* -------------------------------------------------------------------- */
/* Build list of fields. */
/* -------------------------------------------------------------------- */
char **papszFieldNames;
swq_field_type *paeFieldTypes;
int iField;
int nFieldCount = poDefn->GetFieldCount() + SPECIAL_FIELD_COUNT +
poDefn->GetGeomFieldCount();
papszFieldNames = (char **)
CPLMalloc(sizeof(char *) * nFieldCount );
paeFieldTypes = (swq_field_type *)
CPLMalloc(sizeof(swq_field_type) * nFieldCount );
for( iField = 0; iField < poDefn->GetFieldCount(); iField++ )
{
OGRFieldDefn *poField = poDefn->GetFieldDefn( iField );
papszFieldNames[iField] = (char *) poField->GetNameRef();
switch( poField->GetType() )
{
case OFTInteger:
{
if( poField->GetSubType() == OFSTBoolean )
paeFieldTypes[iField] = SWQ_BOOLEAN;
else
paeFieldTypes[iField] = SWQ_INTEGER;
break;
}
case OFTInteger64:
{
if( poField->GetSubType() == OFSTBoolean )
paeFieldTypes[iField] = SWQ_BOOLEAN;
else
paeFieldTypes[iField] = SWQ_INTEGER64;
break;
}
case OFTReal:
paeFieldTypes[iField] = SWQ_FLOAT;
break;
case OFTString:
paeFieldTypes[iField] = SWQ_STRING;
break;
case OFTDate:
case OFTTime:
case OFTDateTime:
paeFieldTypes[iField] = SWQ_TIMESTAMP;
break;
default:
paeFieldTypes[iField] = SWQ_OTHER;
break;
}
}
iField = 0;
while (iField < SPECIAL_FIELD_COUNT)
{
papszFieldNames[poDefn->GetFieldCount() + iField] = (char *) SpecialFieldNames[iField];
paeFieldTypes[poDefn->GetFieldCount() + iField] = SpecialFieldTypes[iField];
++iField;
}
for( iField = 0; iField < poDefn->GetGeomFieldCount(); iField++ )
{
OGRGeomFieldDefn *poField = poDefn->GetGeomFieldDefn( iField );
int iDstField = poDefn->GetFieldCount() + SPECIAL_FIELD_COUNT + iField;
papszFieldNames[iDstField] = (char *) poField->GetNameRef();
if( *papszFieldNames[iDstField] == '\0' )
papszFieldNames[iDstField] = (char*) OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAME;
paeFieldTypes[iDstField] = SWQ_GEOMETRY;
}
/* -------------------------------------------------------------------- */
/* Try to parse. */
/* -------------------------------------------------------------------- */
OGRErr eErr = OGRERR_NONE;
CPLErr eCPLErr;
//.........这里部分代码省略.........
示例6: ICreateFeature
//.........这里部分代码省略.........
pszPrefix, poFieldDefn->GetNameRef(),
pszGeometry,
pszPrefix, poFieldDefn->GetNameRef() );
CPLFree( pszGeometry );
}
}
// Write all "set" fields.
for( int iField = 0; iField < poFeatureDefn->GetFieldCount(); iField++ )
{
OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn( iField );
if( poFeature->IsFieldSet( iField ) && iField != nGMLIdIndex )
{
OGRFieldType eType = poFieldDefn->GetType();
if (eType == OFTStringList )
{
char ** papszIter = poFeature->GetFieldAsStringList( iField );
while( papszIter != NULL && *papszIter != NULL )
{
char *pszEscaped = OGRGetXML_UTF8_EscapedString( *papszIter );
GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix,
bRemoveAppPrefix, poFieldDefn, pszEscaped);
CPLFree( pszEscaped );
papszIter ++;
}
}
else if (eType == OFTIntegerList )
{
int nCount = 0;
const int* panVals = poFeature->GetFieldAsIntegerList( iField, &nCount );
if( poFieldDefn->GetSubType() == OFSTBoolean )
{
for(int i = 0; i < nCount; i++)
{
/* 0 and 1 are OK, but the canonical representation is false and true */
GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix,
bRemoveAppPrefix, poFieldDefn,
panVals[i] ? "true" : "false");
}
}
else
{
for(int i = 0; i < nCount; i++)
{
GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix,
bRemoveAppPrefix, poFieldDefn,
CPLSPrintf("%d", panVals[i]));
}
}
}
else if (eType == OFTInteger64List )
{
int nCount = 0;
const GIntBig* panVals = poFeature->GetFieldAsInteger64List( iField, &nCount );
if( poFieldDefn->GetSubType() == OFSTBoolean )
{
for(int i = 0; i < nCount; i++)
{
/* 0 and 1 are OK, but the canonical representation is false and true */
GMLWriteField(poDS, fp, bWriteSpaceIndentation, pszPrefix,
bRemoveAppPrefix, poFieldDefn,
panVals[i] ? "true" : "false");
}