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

error with returned angle by orientedMinimumBoundingBox() #31371

Closed
300000kms opened this issue Aug 23, 2019 · 1 comment
Closed

error with returned angle by orientedMinimumBoundingBox() #31371

300000kms opened this issue Aug 23, 2019 · 1 comment
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers

Comments

@300000kms
Copy link

in qgis3.4 and ubuntu16
with geometries projected in 25831
the angle obtained by the function orientedMinimumBoundingBox is not the same as the obtained using the function angleBetweenThreePoints
And this second is the correct

oriented minimum bounding box

geom, area, angle, width, height = z.geometry().orientedMinimumBoundingBox()

angle manually calculated

a = math.degrees(QgsGeometryUtils.angleBetweenThreePoints(
geom.vertexAt(0).x(),geom.vertexAt(0).y(),
geom.vertexAt(1).x(),geom.vertexAt(1).y(),
geom.vertexAt(1).x(),geom.vertexAt(1).y()+1000000,
))

a != angle
a != angle-180

@300000kms 300000kms added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Aug 23, 2019
@lbartoletti lbartoletti self-assigned this Sep 11, 2019
@lbartoletti
Copy link
Member

@300000kms QgsGeometryUtils.angleBetweenThreePoints return an angle in radians. You converted it in degrees, but orientedMinimumBoundingBox() returns an angle in degrees converted from angle in radians clockwise from the north direction.

You can take a look at our test files:
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tests/testdata/custom/oriented_bbox.gml
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tests/testdata/expected/oriented_bounds.gml

@gioman gioman added the Feedback Waiting on the submitter for answers label Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers
Projects
None yet
Development

No branches or pull requests

3 participants