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

Conversation

nextstopsun
Copy link

Added parsing of property 7 from TEXT and MTEXT DXF objects and printing it out to the "font" f property of style string.

@rouault
Copy link
Member

rouault commented Mar 2, 2017

autotest/ogr/ogr_dxf.py tests need to be updated. See

Running tests from ogr/ogr_dxf.py
  TEST: ogr_dxf_1 ... success
  TEST: ogr_dxf_2 ... success
  TEST: ogr_dxf_3 ... success
  TEST: ogr_dxf_4 ... success
  TEST: ogr_dxf_5 ... success
  TEST: ogr_dxf_6 ... LABEL(f:"normallatin1",t:"Test",a:30,s:5g,p:7,c:#000000)
fail
    line 212: got wrong style string
  TEST: ogr_dxf_7 ... success
  TEST: ogr_dxf_8 ... success
  TEST: ogr_dxf_9 ... fail
    line 304: Got unexpected style string:
LABEL(f:"normallatin1",t:"Text Sample1¿λ
\"abc\"",a:45,s:0.5g,p:5,c:#000000)
instead of:
LABEL(f:"Arial",t:"Text Sample1¿λ
\"abc\"",a:45,s:0.5g,p:5,c:#000000).
  TEST: ogr_dxf_10 ... success
  TEST: ogr_dxf_11 ... success
  TEST: ogr_dxf_12 ... success
  TEST: ogr_dxf_13 ... success
  TEST: ogr_dxf_14 ... success
  TEST: ogr_dxf_15 ... success
  TEST: ogr_dxf_16 ... fail
    line 735: Got unexpected style string:
LABEL(f:"normallatin1",t:"Text Sample1¿λ
\"abc\"",a:45,s:0.5g,p:5,c:#000000)
instead of:
LABEL(f:"Arial",t:"Text Sample1¿λ
\"abc\"",a:45,s:0.5g,p:5,c:#000000).
  TEST: ogr_dxf_17 ... fail
    line 858: Got wrong subclasses for feature 1.
  TEST: ogr_dxf_18 ... fail
    line 958: Got wrong linetype. (1)
  TEST: ogr_dxf_19 ... fail
    line 1035: Got wrong subclasses for feature 1.
  TEST: ogr_dxf_20 ... fail
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_21 ... fail
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_22 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1093, in ogr_dxf_22
    if feat.GetFieldAsString('Text') != 'test_text':
AttributeError: 'NoneType' object has no attribute 'GetFieldAsString'
  TEST: ogr_dxf_23 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1166, in ogr_dxf_23
    style = feat.GetStyleString()
AttributeError: 'NoneType' object has no attribute 'GetStyleString'
  TEST: ogr_dxf_24 ... fail
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_25 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1218, in ogr_dxf_25
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_26 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1240, in ogr_dxf_26
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_27 ... success
  TEST: ogr_dxf_28 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1272, in ogr_dxf_28
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_29 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1295, in ogr_dxf_29
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_30 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1325, in ogr_dxf_30
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_31 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1353, in ogr_dxf_31
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_32 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 1781, in ogr_dxf_32
    feat.DumpReadable()
AttributeError: 'NoneType' object has no attribute 'DumpReadable'
    line 83: expected geometry but got NULL.
  TEST: ogr_dxf_33 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 2329, in ogr_dxf_33
    if feat.Layer != '0':
AttributeError: 'NoneType' object has no attribute 'Layer'
  TEST: ogr_dxf_34 ... fail (blowup)
Traceback (most recent call last):
  File "pymod/gdaltest_python2.py", line 42, in run_func
    result = func()
  File "./ogr_dxf.py", line 2371, in ogr_dxf_34
    geom = feat.GetGeometryRef()
AttributeError: 'NoneType' object has no attribute 'GetGeometryRef'

@@ -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

@@ -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

@@ -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.

@@ -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.

@nextstopsun
Copy link
Author

@rouault Can you please review changes? Seems like only one Travis build is failing and it's unrelated to this PR.

@rouault
Copy link
Member

rouault commented Mar 3, 2017

mingw was complaining about "ogrdxflayer.cpp:2547:2: error: no newline at end of file". I've manually fixed that and committed your patch in trunk r37571. Thanks

@rouault rouault closed this Mar 3, 2017
kwrobot pushed a commit to aashish24/gdal-svn that referenced this pull request Mar 3, 2017
rouault added a commit that referenced this pull request Mar 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants