qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.68k stars 3.02k forks source link

Wrong text orientation when importing DWG #29815

Open qgib opened 5 years ago

qgib commented 5 years ago

Author Name: Etienne MORO (Etienne MORO) Original Redmine Issue: 22000 Affected QGIS version: 3.4.7 Redmine category:dwg/dxf_import Assignee: Jürgen Fischer


When you import a DWG file using the command 'Import Layers from DWG/DXF', the texts (labels) get a wrong orientation. It's just because the expression associated to the orientation of the labels is not the correct. The right expression to use is: 360-(angle*180/pi()) whereas the expression used after import is: 360-angle The mistake is due to the fact that the field "angle" returns angles in radians, so they have to be converted in degrees. I've attached a DWG example to use for your tests.


jdugge commented 5 years ago

@jef-n: In 92e7faab665d1853191227c8aeb6c13a04c43537, you introduced a conversion of the angle to radians when reading the DWG/DXF file by dividing the angle by ARAD, which is 57.295. In the same commit, you changed the expression for the text rotation from 360-angle*180.0/pi() to 360-angle, which would require the angle to be in degrees.

I think that the expression should be 360-angle*180.0/pi() (conversion of angle from radians to degrees), but your commit implies that there were cases where this caused problems. Do you remember why the changes were introduced?

lbartoletti commented 3 years ago

@jdugge Etienne ( @sigmoe ? ), @jef-n

I don't think there is a radians to degrees conversion problem. The angles are in radians and close to those of autocad.

I tried with the Rue Honoré de Balzac, and as far as i know, there is a problem only for one label which is angle is between 180 and 270 degrees (arithmetic). If i'm not wrong, label don't use arithmetic degrees.

I tested several expressions, here the screenshots:

angle

angle

360-angle

360-angle

360-angle*180.0/pi()

360-angle_radi

conversion from arithmetic to geographic : CASE WHEN angle > 180 and angle < 270 THEN angle ELSE 360 - angle END

case_when

lbartoletti commented 3 years ago

For reference, the DWG opeend in autocad:

image

jef-n commented 3 years ago

IIRC the interpretation of angles is different between versions of DWG and/or DXF vs DWG.