本文整理汇总了C++中OGRPoint::setM方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRPoint::setM方法的具体用法?C++ OGRPoint::setM怎么用?C++ OGRPoint::setM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRPoint
的用法示例。
在下文中一共展示了OGRPoint::setM方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importFromWkt_Bracketed
OGRErr OGRMultiPoint::importFromWkt_Bracketed( char ** ppszInput,
int bHasM, int bHasZ )
{
/* -------------------------------------------------------------------- */
/* Skip MULTIPOINT keyword. */
/* -------------------------------------------------------------------- */
char szToken[OGR_WKT_TOKEN_MAX] = {};
const char *pszInput = *ppszInput;
pszInput = OGRWktReadToken( pszInput, szToken );
if( bHasZ || bHasM )
{
// Skip Z, M or ZM.
pszInput = OGRWktReadToken( pszInput, szToken );
}
/* -------------------------------------------------------------------- */
/* Read points till we get to the closing bracket. */
/* -------------------------------------------------------------------- */
OGRRawPoint *paoPoints = NULL;
double *padfZ = NULL;
double *padfM = NULL;
while( (pszInput = OGRWktReadToken( pszInput, szToken )) != NULL
&& (EQUAL(szToken, "(") || EQUAL(szToken, ",")) )
{
const char* pszNext = OGRWktReadToken( pszInput, szToken );
if( EQUAL(szToken, "EMPTY") )
{
OGRPoint *poGeom = new OGRPoint(0.0, 0.0);
poGeom->empty();
const OGRErr eErr = addGeometryDirectly( poGeom );
if( eErr != OGRERR_NONE )
{
CPLFree( paoPoints );
delete poGeom;
return eErr;
}
pszInput = pszNext;
continue;
}
int flagsFromInput = flags;
int nMaxPoint = 0;
int nPointCount = 0;
pszInput = OGRWktReadPointsM( pszInput, &paoPoints, &padfZ, &padfM,
&flagsFromInput,
&nMaxPoint, &nPointCount );
if( pszInput == NULL || nPointCount != 1 )
{
CPLFree( paoPoints );
CPLFree( padfZ );
CPLFree( padfM );
return OGRERR_CORRUPT_DATA;
}
if( (flagsFromInput & OGR_G_3D) && !(flags & OGR_G_3D) )
{
flags |= OGR_G_3D;
bHasZ = TRUE;
}
if( (flagsFromInput & OGR_G_MEASURED) && !(flags & OGR_G_MEASURED) )
{
flags |= OGR_G_MEASURED;
bHasM = TRUE;
}
OGRPoint *poPoint = new OGRPoint(paoPoints[0].x, paoPoints[0].y);
if( bHasM )
{
if( padfM != NULL )
poPoint->setM(padfM[0]);
else
poPoint->setM(0.0);
}
if( bHasZ )
{
if( padfZ != NULL )
poPoint->setZ(padfZ[0]);
else
poPoint->setZ(0.0);
}
const OGRErr eErr = addGeometryDirectly( poPoint );
if( eErr != OGRERR_NONE )
{
CPLFree( paoPoints );
CPLFree( padfZ );
CPLFree( padfM );
delete poPoint;
return eErr;
}
}
/* -------------------------------------------------------------------- */
/* Cleanup. */
//.........这里部分代码省略.........
示例2: importFromWkt
OGRErr OGRMultiPoint::importFromWkt( char ** ppszInput )
{
const char *pszInputBefore = *ppszInput;
int bHasZ = FALSE;
int bHasM = FALSE;
bool bIsEmpty = false;
OGRErr eErr = importPreambuleFromWkt(ppszInput, &bHasZ, &bHasM, &bIsEmpty);
flags = 0;
if( eErr != OGRERR_NONE )
return eErr;
if( bHasZ ) flags |= OGR_G_3D;
if( bHasM ) flags |= OGR_G_MEASURED;
if( bIsEmpty )
return OGRERR_NONE;
char szToken[OGR_WKT_TOKEN_MAX] = {};
const char *pszInput = *ppszInput;
eErr = OGRERR_NONE;
const char* pszPreScan = OGRWktReadToken( pszInput, szToken );
OGRWktReadToken( pszPreScan, szToken );
// Do we have an inner bracket?
if( EQUAL(szToken,"(") || EQUAL(szToken, "EMPTY") )
{
*ppszInput = const_cast<char *>(pszInputBefore);
return importFromWkt_Bracketed( ppszInput, bHasM, bHasZ );
}
if( bHasZ || bHasM )
{
return OGRERR_CORRUPT_DATA;
}
/* -------------------------------------------------------------------- */
/* Read the point list which should consist of exactly one point. */
/* -------------------------------------------------------------------- */
OGRRawPoint *paoPoints = NULL;
double *padfZ = NULL;
double *padfM = NULL;
int flagsFromInput = flags;
int nMaxPoint = 0;
int nPointCount = 0;
pszInput = OGRWktReadPointsM( pszInput, &paoPoints, &padfZ, &padfM,
&flagsFromInput,
&nMaxPoint, &nPointCount );
if( pszInput == NULL )
{
CPLFree( paoPoints );
CPLFree( padfZ );
CPLFree( padfM );
return OGRERR_CORRUPT_DATA;
}
if( (flagsFromInput & OGR_G_3D) && !(flags & OGR_G_3D) )
{
flags |= OGR_G_3D;
bHasZ = TRUE;
}
if( (flagsFromInput & OGR_G_MEASURED) && !(flags & OGR_G_MEASURED) )
{
flags |= OGR_G_MEASURED;
bHasM = TRUE;
}
/* -------------------------------------------------------------------- */
/* Transform raw points into point objects. */
/* -------------------------------------------------------------------- */
for( int iGeom = 0; iGeom < nPointCount && eErr == OGRERR_NONE; iGeom++ )
{
OGRPoint *poPoint =
new OGRPoint(paoPoints[iGeom].x, paoPoints[iGeom].y);
if( bHasM )
{
if( padfM != NULL )
poPoint->setM(padfM[iGeom]);
else
poPoint->setM(0.0);
}
if( bHasZ )
{
if( padfZ != NULL )
poPoint->setZ(padfZ[iGeom]);
else
poPoint->setZ(0.0);
}
eErr = addGeometryDirectly( poPoint );
if( eErr != OGRERR_NONE )
{
CPLFree( paoPoints );
CPLFree( padfZ );
CPLFree( padfM );
delete poPoint;
return eErr;
}
}
CPLFree( paoPoints );
//.........这里部分代码省略.........