本文整理汇总了C++中OGRPoint::getCoordinateDimension方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRPoint::getCoordinateDimension方法的具体用法?C++ OGRPoint::getCoordinateDimension怎么用?C++ OGRPoint::getCoordinateDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRPoint
的用法示例。
在下文中一共展示了OGRPoint::getCoordinateDimension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportToWkt
OGRErr OGRMultiPoint::exportToWkt( char ** ppszDstText ) const
{
int nMaxString = getNumGeometries() * 20 + 128;
int nRetLen = 0;
if( getNumGeometries() == 0 )
{
*ppszDstText = CPLStrdup("MULTIPOINT(EMPTY)");
return OGRERR_NONE;
}
*ppszDstText = (char *) VSIMalloc( nMaxString );
if( *ppszDstText == NULL )
return OGRERR_NOT_ENOUGH_MEMORY;
sprintf( *ppszDstText, "%s (", getGeometryName() );
for( int i = 0; i < getNumGeometries(); i++ )
{
OGRPoint *poPoint = (OGRPoint *) getGeometryRef( i );
if( i > 0 )
strcat( *ppszDstText + nRetLen, "," );
nRetLen += strlen(*ppszDstText + nRetLen);
if( nMaxString < nRetLen + 100 )
{
nMaxString = nMaxString * 2;
*ppszDstText = (char *) CPLRealloc(*ppszDstText,nMaxString);
}
if( poPoint->getCoordinateDimension() == 3 )
OGRMakeWktCoordinate( *ppszDstText + nRetLen,
poPoint->getX(),
poPoint->getY(),
poPoint->getZ() );
else
OGRMakeWktCoordinate( *ppszDstText + nRetLen,
poPoint->getX(),
poPoint->getY(),
0.0 );
}
strcat( *ppszDstText+nRetLen, ")" );
return OGRERR_NONE;
}
示例2: if
static bool OGR2KMLGeometryAppend( OGRGeometry *poGeometry,
char **ppszText, size_t *pnLength,
size_t *pnMaxLength, char *szAltitudeMode )
{
/* -------------------------------------------------------------------- */
/* 2D Point */
/* -------------------------------------------------------------------- */
if( poGeometry->getGeometryType() == wkbPoint )
{
OGRPoint* poPoint = static_cast<OGRPoint*>(poGeometry);
if (poPoint->getCoordinateDimension() == 0)
{
_GrowBuffer( *pnLength + 10,
ppszText, pnMaxLength );
strcat( *ppszText + *pnLength, "<Point/>");
*pnLength += strlen( *ppszText + *pnLength );
}
else
{
char szCoordinate[256] = { 0 };
MakeKMLCoordinate( szCoordinate, sizeof(szCoordinate),
poPoint->getX(), poPoint->getY(), 0.0, FALSE );
_GrowBuffer( *pnLength + strlen(szCoordinate) + 60,
ppszText, pnMaxLength );
snprintf( *ppszText + *pnLength, *pnMaxLength - *pnLength,
"<Point><coordinates>%s</coordinates></Point>",
szCoordinate );
*pnLength += strlen( *ppszText + *pnLength );
}
}
/* -------------------------------------------------------------------- */
/* 3D Point */
/* -------------------------------------------------------------------- */
else if( poGeometry->getGeometryType() == wkbPoint25D )
{
char szCoordinate[256] = { 0 };
OGRPoint *poPoint = static_cast<OGRPoint*>(poGeometry);
MakeKMLCoordinate( szCoordinate, sizeof(szCoordinate),
poPoint->getX(), poPoint->getY(), poPoint->getZ(),
true );
if (NULL == szAltitudeMode)
{
_GrowBuffer( *pnLength + strlen(szCoordinate) + 70,
ppszText, pnMaxLength );
snprintf( *ppszText + *pnLength, *pnMaxLength - *pnLength,
"<Point><coordinates>%s</coordinates></Point>",
szCoordinate );
}
else
{
_GrowBuffer( *pnLength + strlen(szCoordinate)
+ strlen(szAltitudeMode) + 70,
ppszText, pnMaxLength );
snprintf( *ppszText + *pnLength, *pnMaxLength - *pnLength,
"<Point>%s<coordinates>%s</coordinates></Point>",
szAltitudeMode, szCoordinate );
}
*pnLength += strlen( *ppszText + *pnLength );
}
/* -------------------------------------------------------------------- */
/* LineString and LinearRing */
/* -------------------------------------------------------------------- */
else if( poGeometry->getGeometryType() == wkbLineString
|| poGeometry->getGeometryType() == wkbLineString25D )
{
const bool bRing = EQUAL(poGeometry->getGeometryName(),"LINEARRING");
if( bRing )
AppendString( ppszText, pnLength, pnMaxLength,
"<LinearRing>" );
else
AppendString( ppszText, pnLength, pnMaxLength,
"<LineString>" );
if (NULL != szAltitudeMode)
{
AppendString( ppszText, pnLength, pnMaxLength, szAltitudeMode);
}
AppendCoordinateList( reinterpret_cast<OGRLineString *>(poGeometry),
ppszText, pnLength, pnMaxLength );
if( bRing )
AppendString( ppszText, pnLength, pnMaxLength,
"</LinearRing>" );
else
AppendString( ppszText, pnLength, pnMaxLength,
"</LineString>" );
}
//.........这里部分代码省略.........
示例3: geom2kml
ElementPtr geom2kml (
OGRGeometry * poOgrGeom,
int extra,
KmlFactory * poKmlFactory )
{
int i;
if ( !poOgrGeom ) {
return NULL;
}
/***** ogr geom vars *****/
OGRPoint *poOgrPoint = NULL;
OGRLineString *poOgrLineString;
OGRPolygon *poOgrPolygon;
OGRGeometryCollection *poOgrMultiGeom;
/***** libkml geom vars *****/
CoordinatesPtr coordinates;
PointPtr poKmlPoint;
LineStringPtr poKmlLineString;
LinearRingPtr poKmlLinearRing;
OuterBoundaryIsPtr poKmlOuterRing;
InnerBoundaryIsPtr poKmlInnerRing;
PolygonPtr poKmlPolygon;
MultiGeometryPtr poKmlMultiGeometry;
ElementPtr poKmlGeometry;
ElementPtr poKmlTmpGeometry;
/***** other vars *****/
double x,
y,
z;
int numpoints = 0;
int nGeom;
OGRwkbGeometryType type = poOgrGeom->getGeometryType ( );
switch ( type ) {
case wkbPoint:
poOgrPoint = ( OGRPoint * ) poOgrGeom;
if (poOgrPoint->getCoordinateDimension() == 0)
{
poKmlGeometry = poKmlPoint = poKmlFactory->CreatePoint ( );
}
else
{
x = poOgrPoint->getX ( );
y = poOgrPoint->getY ( );
if ( x > 180 )
x -= 360;
coordinates = poKmlFactory->CreateCoordinates ( );
coordinates->add_latlng ( y, x );
poKmlGeometry = poKmlPoint = poKmlFactory->CreatePoint ( );
poKmlPoint->set_coordinates ( coordinates );
}
break;
case wkbPoint25D:
poOgrPoint = ( OGRPoint * ) poOgrGeom;
x = poOgrPoint->getX ( );
y = poOgrPoint->getY ( );
z = poOgrPoint->getZ ( );
if ( x > 180 )
x -= 360;
coordinates = poKmlFactory->CreateCoordinates ( );
coordinates->add_latlngalt ( y, x, z );
poKmlGeometry = poKmlPoint = poKmlFactory->CreatePoint ( );
poKmlPoint->set_coordinates ( coordinates );
break;
case wkbLineString:
poOgrLineString = ( OGRLineString * ) poOgrGeom;
if( extra >= 0 )
{
((OGRLinearRing*)poOgrGeom)->closeRings();
}
numpoints = poOgrLineString->getNumPoints ( );
if( extra >= 0 )
{
if( numpoints < 4 &&
CPLTestBool(CPLGetConfigOption("LIBKML_STRICT_COMPLIANCE", "TRUE")) )
{
CPLError(CE_Failure, CPLE_NotSupported, "A linearring should have at least 4 points");
return NULL;
//.........这里部分代码省略.........
示例4: exportToWkt
OGRErr OGRMultiPoint::exportToWkt( char ** ppszDstText,
OGRwkbVariant eWkbVariant ) const
{
int nMaxString = getNumGeometries() * 22 + 128;
int nRetLen = 0;
/* -------------------------------------------------------------------- */
/* Return MULTIPOINT EMPTY if we get no valid points. */
/* -------------------------------------------------------------------- */
if( IsEmpty() )
{
if( getCoordinateDimension() == 3 && eWkbVariant == wkbVariantIso )
*ppszDstText = CPLStrdup("MULTIPOINT Z EMPTY");
else
*ppszDstText = CPLStrdup("MULTIPOINT EMPTY");
return OGRERR_NONE;
}
*ppszDstText = (char *) VSIMalloc( nMaxString );
if( *ppszDstText == NULL )
return OGRERR_NOT_ENOUGH_MEMORY;
if( getCoordinateDimension() == 3 && eWkbVariant == wkbVariantIso )
sprintf( *ppszDstText, "%s Z (", getGeometryName() );
else
sprintf( *ppszDstText, "%s (", getGeometryName() );
int bMustWriteComma = FALSE;
for( int i = 0; i < getNumGeometries(); i++ )
{
OGRPoint *poPoint = (OGRPoint *) getGeometryRef( i );
if (poPoint->IsEmpty())
{
CPLDebug( "OGR", "OGRMultiPoint::exportToWkt() - skipping POINT EMPTY.");
continue;
}
if( bMustWriteComma )
strcat( *ppszDstText + nRetLen, "," );
bMustWriteComma = TRUE;
nRetLen += strlen(*ppszDstText + nRetLen);
if( nMaxString < nRetLen + 100 )
{
nMaxString = nMaxString * 2;
*ppszDstText = (char *) CPLRealloc(*ppszDstText,nMaxString);
}
if( eWkbVariant == wkbVariantIso )
{
strcat( *ppszDstText + nRetLen, "(" );
nRetLen ++;
}
OGRMakeWktCoordinate( *ppszDstText + nRetLen,
poPoint->getX(),
poPoint->getY(),
poPoint->getZ(),
poPoint->getCoordinateDimension() );
if( eWkbVariant == wkbVariantIso )
{
strcat( *ppszDstText + nRetLen, ")" );
nRetLen ++;
}
}
strcat( *ppszDstText+nRetLen, ")" );
return OGRERR_NONE;
}