本文整理汇总了C++中OGRStyleTool::SetUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRStyleTool::SetUnit方法的具体用法?C++ OGRStyleTool::SetUnit怎么用?C++ OGRStyleTool::SetUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRStyleTool
的用法示例。
在下文中一共展示了OGRStyleTool::SetUnit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteTEXT
OGRErr OGRDXFWriterLayer::WriteTEXT( OGRFeature *poFeature )
{
WriteValue( 0, "MTEXT" );
WriteCore( poFeature );
WriteValue( 100, "AcDbEntity" );
WriteValue( 100, "AcDbMText" );
/* -------------------------------------------------------------------- */
/* Do we have styling information? */
/* -------------------------------------------------------------------- */
OGRStyleTool *poTool = nullptr;
OGRStyleMgr oSM;
if( poFeature->GetStyleString() != nullptr )
{
oSM.InitFromFeature( poFeature );
if( oSM.GetPartCount() > 0 )
poTool = oSM.GetPart(0);
}
/* ==================================================================== */
/* Process the LABEL tool. */
/* ==================================================================== */
double dfDx = 0.0;
double dfDy = 0.0;
if( poTool && poTool->GetType() == OGRSTCLabel )
{
OGRStyleLabel *poLabel = (OGRStyleLabel *) poTool;
GBool bDefault;
/* -------------------------------------------------------------------- */
/* Color */
/* -------------------------------------------------------------------- */
if( poLabel->ForeColor(bDefault) != nullptr && !bDefault )
WriteValue( 62, ColorStringToDXFColor(
poLabel->ForeColor(bDefault) ) );
/* -------------------------------------------------------------------- */
/* Angle */
/* -------------------------------------------------------------------- */
const double dfAngle = poLabel->Angle(bDefault);
if( !bDefault )
WriteValue( 50, dfAngle );
/* -------------------------------------------------------------------- */
/* Height - We need to fetch this in georeferenced units - I'm */
/* doubt the default translation mechanism will be much good. */
/* -------------------------------------------------------------------- */
poTool->SetUnit( OGRSTUGround );
const double dfHeight = poLabel->Size(bDefault);
if( !bDefault )
WriteValue( 40, dfHeight );
/* -------------------------------------------------------------------- */
/* Anchor / Attachment Point */
/* -------------------------------------------------------------------- */
const int nAnchor = poLabel->Anchor(bDefault);
if( !bDefault )
{
const static int anAnchorMap[] =
{ -1, 7, 8, 9, 4, 5, 6, 1, 2, 3, 7, 8, 9 };
if( nAnchor > 0 && nAnchor < 13 )
WriteValue( 71, anAnchorMap[nAnchor] );
}
/* -------------------------------------------------------------------- */
/* Offset */
/* -------------------------------------------------------------------- */
dfDx = poLabel->SpacingX(bDefault);
dfDy = poLabel->SpacingY(bDefault);
/* -------------------------------------------------------------------- */
/* Escape the text, and convert to ISO8859. */
/* -------------------------------------------------------------------- */
const char *pszText = poLabel->TextString( bDefault );
if( pszText != nullptr && !bDefault )
{
CPLString osEscaped = TextEscape( pszText );
while( osEscaped.size() > 250 )
{
WriteValue( 3, osEscaped.substr( 0, 250 ).c_str() );
osEscaped.erase( 0, 250 );
}
WriteValue( 1, osEscaped );
}
/* -------------------------------------------------------------------- */
/* Store the text style in the map. */
/* -------------------------------------------------------------------- */
std::map<CPLString, CPLString> oTextStyleDef =
PrepareTextStyleDefinition( poLabel );
CPLString osStyleName;
//.........这里部分代码省略.........
示例2: WriteTEXT
OGRErr OGRDXFWriterLayer::WriteTEXT( OGRFeature *poFeature )
{
WriteValue( 0, "MTEXT" );
WriteCore( poFeature );
WriteValue( 100, "AcDbEntity" );
WriteValue( 100, "AcDbMText" );
/* -------------------------------------------------------------------- */
/* Do we have styling information? */
/* -------------------------------------------------------------------- */
OGRStyleTool *poTool = NULL;
OGRStyleMgr oSM;
if( poFeature->GetStyleString() != NULL )
{
oSM.InitFromFeature( poFeature );
if( oSM.GetPartCount() > 0 )
poTool = oSM.GetPart(0);
}
/* ==================================================================== */
/* Process the LABEL tool. */
/* ==================================================================== */
if( poTool && poTool->GetType() == OGRSTCLabel )
{
OGRStyleLabel *poLabel = (OGRStyleLabel *) poTool;
GBool bDefault;
/* -------------------------------------------------------------------- */
/* Color */
/* -------------------------------------------------------------------- */
if( poLabel->ForeColor(bDefault) != NULL && !bDefault )
WriteValue( 62, ColorStringToDXFColor(
poLabel->ForeColor(bDefault) ) );
/* -------------------------------------------------------------------- */
/* Angle */
/* -------------------------------------------------------------------- */
double dfAngle = poLabel->Angle(bDefault);
// The DXF2000 reference says this is in radians, but in files
// I see it seems to be in degrees. Perhaps this is version dependent?
if( !bDefault )
WriteValue( 50, dfAngle );
/* -------------------------------------------------------------------- */
/* Height - We need to fetch this in georeferenced units - I'm */
/* doubt the default translation mechanism will be much good. */
/* -------------------------------------------------------------------- */
poTool->SetUnit( OGRSTUGround );
double dfHeight = poLabel->Size(bDefault);
if( !bDefault )
WriteValue( 40, dfHeight );
/* -------------------------------------------------------------------- */
/* Anchor / Attachment Point */
/* -------------------------------------------------------------------- */
int nAnchor = poLabel->Anchor(bDefault);
if( !bDefault )
{
const static int anAnchorMap[] =
{ -1, 7, 8, 9, 4, 5, 6, 1, 2, 3, 7, 8, 9 };
if( nAnchor > 0 && nAnchor < 13 )
WriteValue( 71, anAnchorMap[nAnchor] );
}
/* -------------------------------------------------------------------- */
/* Escape the text, and convert to ISO8859. */
/* -------------------------------------------------------------------- */
const char *pszText = poLabel->TextString( bDefault );
if( pszText != NULL && !bDefault )
{
CPLString osEscaped = TextEscape( pszText );
WriteValue( 1, osEscaped );
}
}
delete poTool;
/* -------------------------------------------------------------------- */
/* Write the location. */
/* -------------------------------------------------------------------- */
OGRPoint *poPoint = (OGRPoint *) poFeature->GetGeometryRef();
WriteValue( 10, poPoint->getX() );
if( !WriteValue( 20, poPoint->getY() ) )
return OGRERR_FAILURE;
if( poPoint->getGeometryType() == wkbPoint25D )
{
if( !WriteValue( 30, poPoint->getZ() ) )
return OGRERR_FAILURE;
}
//.........这里部分代码省略.........