Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DXF style attribute of TEXT and MTEXT to OGR style string #198

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions gdal/ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT()
bool bHaveZ = false;
int nAttachmentPoint = -1;
CPLString osText;
CPLString styleName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention: use osStyleName

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


while( (nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf))) > 0 )
{
Expand Down Expand Up @@ -524,6 +525,10 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT()
dfAngle = CPLAtof(szLineBuf);
break;

case 7:
styleName = TextUnescape(szLineBuf);
break;

default:
TranslateGenericProperty( poFeature, nCode, szLineBuf );
break;
Expand Down Expand Up @@ -595,8 +600,13 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT()
/* -------------------------------------------------------------------- */
CPLString osStyle;
char szBuffer[64];

if (styleName == "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace that by initialization to "Arial" at declaration time

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed if and changed to setting at declaration time.

{
styleName = "Arial";
}

osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\"",osText.c_str());
osStyle.Printf("LABEL(f:\"%s\",t:\"%s\"", styleName.c_str(), osText.c_str());

if( dfAngle != 0.0 )
{
Expand Down Expand Up @@ -652,6 +662,7 @@ OGRFeature *OGRDXFLayer::TranslateTEXT()
double dfAngle = 0.0;
double dfHeight = 0.0;
CPLString osText;
CPLString styleName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention: use osStyleName

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

bool bHaveZ = false;
int nAnchorPosition = 1;
int nHorizontalAlignment = 0;
Expand Down Expand Up @@ -695,6 +706,10 @@ OGRFeature *OGRDXFLayer::TranslateTEXT()
nVerticalAlignment = atoi(szLineBuf);
break;

case 7:
styleName = TextUnescape(szLineBuf);
break;

default:
TranslateGenericProperty( poFeature, nCode, szLineBuf );
break;
Expand Down Expand Up @@ -804,8 +819,13 @@ OGRFeature *OGRDXFLayer::TranslateTEXT()
CPLString osStyle;
char szBuffer[64];

osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\"",osText.c_str());
if (styleName == "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace that by initialization to "Arial" at declaration time

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed if and changed to setting at declaration time.

{
styleName = "Arial";
}

osStyle.Printf("LABEL(f:\"%s\",t:\"%s\"", styleName.c_str(), osText.c_str());

osStyle += CPLString().Printf(",p:%d", nAnchorPosition);

if( dfAngle != 0.0 )
Expand Down Expand Up @@ -2534,4 +2554,4 @@ int OGRDXFLayer::TestCapability( const char * pszCap )

{
return EQUAL(pszCap, OLCStringsAsUTF8);
}
}