本文整理汇总了C++中OGRGeometry::setCoordinateDimension方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::setCoordinateDimension方法的具体用法?C++ OGRGeometry::setCoordinateDimension怎么用?C++ OGRGeometry::setCoordinateDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::setCoordinateDimension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFeatureViaCopy
OGRErr OGRPGDumpLayer::CreateFeatureViaCopy( OGRFeature *poFeature )
{
int i;
CPLString osCommand;
/* First process geometry */
for( i = 0; i < poFeature->GetGeomFieldCount(); i++ )
{
OGRGeometry *poGeometry = poFeature->GetGeomFieldRef(i);
char *pszGeom = NULL;
if ( NULL != poGeometry /* && (bHasWkb || bHasPostGISGeometry || bHasPostGISGeography) */)
{
OGRPGDumpGeomFieldDefn* poGFldDefn =
(OGRPGDumpGeomFieldDefn*) poFeature->GetGeomFieldDefnRef(i);
poGeometry->closeRings();
poGeometry->setCoordinateDimension( poGFldDefn->nCoordDimension );
//CheckGeomTypeCompatibility(poGeometry);
/*if (bHasWkb)
pszGeom = GeometryToBYTEA( poGeometry );
else*/
pszGeom = OGRGeometryToHexEWKB( poGeometry, poGFldDefn->nSRSId );
}
if (osCommand.size() > 0)
osCommand += "\t";
if ( pszGeom )
{
osCommand += pszGeom,
CPLFree( pszGeom );
}
else
{
osCommand += "\\N";
}
}
/* Next process the field id column */
int nFIDIndex = -1;
if( bFIDColumnInCopyFields )
{
if (osCommand.size() > 0)
osCommand += "\t";
nFIDIndex = poFeatureDefn->GetFieldIndex( pszFIDColumn );
/* Set the FID */
if( poFeature->GetFID() != OGRNullFID )
{
osCommand += CPLString().Printf("%ld ", poFeature->GetFID());
}
else
{
osCommand += "\\N" ;
}
}
/* Now process the remaining fields */
int nFieldCount = poFeatureDefn->GetFieldCount();
int bAddTab = osCommand.size() > 0;
for( i = 0; i < nFieldCount; i++ )
{
if (i == nFIDIndex)
continue;
const char *pszStrValue = poFeature->GetFieldAsString(i);
char *pszNeedToFree = NULL;
if (bAddTab)
osCommand += "\t";
bAddTab = TRUE;
if( !poFeature->IsFieldSet( i ) )
{
osCommand += "\\N" ;
continue;
}
int nOGRFieldType = poFeatureDefn->GetFieldDefn(i)->GetType();
// We need special formatting for integer list values.
if( nOGRFieldType == OFTIntegerList )
{
int nCount, nOff = 0, j;
const int *panItems = poFeature->GetFieldAsIntegerList(i,&nCount);
pszNeedToFree = (char *) CPLMalloc(nCount * 13 + 10);
strcpy( pszNeedToFree, "{" );
for( j = 0; j < nCount; j++ )
{
if( j != 0 )
strcat( pszNeedToFree+nOff, "," );
nOff += strlen(pszNeedToFree+nOff);
//.........这里部分代码省略.........
示例2: CreateFeatureViaInsert
OGRErr OGRPGDumpLayer::CreateFeatureViaInsert( OGRFeature *poFeature )
{
CPLString osCommand;
int i = 0;
int bNeedComma = FALSE;
OGRErr eErr = OGRERR_FAILURE;
int bEmptyInsert = FALSE;
if( NULL == poFeature )
{
CPLError( CE_Failure, CPLE_AppDefined,
"NULL pointer to OGRFeature passed to CreateFeatureViaInsert()." );
return eErr;
}
/* -------------------------------------------------------------------- */
/* Form the INSERT command. */
/* -------------------------------------------------------------------- */
osCommand.Printf( "INSERT INTO %s (", pszSqlTableName );
for(i = 0; i < poFeatureDefn->GetGeomFieldCount(); i++ )
{
OGRGeometry *poGeom = poFeature->GetGeomFieldRef(i);
if( poGeom != NULL )
{
if( bNeedComma )
osCommand += ", ";
OGRGeomFieldDefn* poGFldDefn = poFeature->GetGeomFieldDefnRef(i);
osCommand = osCommand + OGRPGDumpEscapeColumnName(poGFldDefn->GetNameRef()) + " ";
bNeedComma = TRUE;
}
}
if( poFeature->GetFID() != OGRNullFID && pszFIDColumn != NULL )
{
if( bNeedComma )
osCommand += ", ";
osCommand = osCommand + OGRPGDumpEscapeColumnName(pszFIDColumn) + " ";
bNeedComma = TRUE;
}
for( i = 0; i < poFeatureDefn->GetFieldCount(); i++ )
{
if( !poFeature->IsFieldSet( i ) )
continue;
if( !bNeedComma )
bNeedComma = TRUE;
else
osCommand += ", ";
osCommand = osCommand
+ OGRPGDumpEscapeColumnName(poFeatureDefn->GetFieldDefn(i)->GetNameRef());
}
if (!bNeedComma)
bEmptyInsert = TRUE;
osCommand += ") VALUES (";
/* Set the geometry */
bNeedComma = FALSE;
for(i = 0; i < poFeatureDefn->GetGeomFieldCount(); i++ )
{
OGRGeometry *poGeom = poFeature->GetGeomFieldRef(i);
if( poGeom != NULL )
{
char *pszWKT = NULL;
OGRPGDumpGeomFieldDefn* poGFldDefn =
(OGRPGDumpGeomFieldDefn*) poFeature->GetGeomFieldDefnRef(i);
poGeom->closeRings();
poGeom->setCoordinateDimension( poGFldDefn->nCoordDimension );
if( bNeedComma )
osCommand += ", ";
if( bWriteAsHex )
{
char* pszHex = OGRGeometryToHexEWKB( poGeom, poGFldDefn->nSRSId );
osCommand += "'";
if (pszHex)
osCommand += pszHex;
osCommand += "'";
CPLFree(pszHex);
}
else
{
poGeom->exportToWkt( &pszWKT );
if( pszWKT != NULL )
{
osCommand +=
CPLString().Printf(
"GeomFromEWKT('SRID=%d;%s'::TEXT) ", poGFldDefn->nSRSId, pszWKT );
OGRFree( pszWKT );
//.........这里部分代码省略.........