Skip to content

qgsvectorlayerprofilegenerator: Fix intersection for collinear polygons#66432

Open
ptitjano wants to merge 1 commit into
qgis:masterfrom
ptitjano:profiletool-tolerance-tooltip
Open

qgsvectorlayerprofilegenerator: Fix intersection for collinear polygons#66432
ptitjano wants to merge 1 commit into
qgis:masterfrom
ptitjano:profiletool-tolerance-tooltip

Conversation

@ptitjano

Copy link
Copy Markdown
Collaborator

Description

With tolerance at 0, when a triangle from the tessellated polygon is collinear In the XY plane, the processTriangleLineIntersect worflow does not work and a special case is requirede.

In that case, the intersection between the profile line and the profile line is computed. For every intersection, the Z value is extracted. For each intersection, a Z value is calculated along the edge. The lowest and highest Z values are then used to build the vertical profile segment represented by the triangle.

This changes fixes 2 issues when iterating over the triangle edges:

  1. Use the triangle, instead of the input polygon is used to compute intersection
  2. Preserve the first valid intersection point when processing collinear triangles. Otherwise, a subsequent failed edge intersection test may overwrite a previously valid intersection point, causing profile segments to be skipped.

AI tool usage

No AI Tool used

Example

Capture d’écran du 2026-06-10 19-36-12

Bug

Capture d’écran du 2026-06-10 19-36-34

Fixed

Capture d’écran du 2026-06-10 19-37-56

@ptitjano ptitjano self-assigned this Jun 10, 2026
@ptitjano ptitjano added Bug Either a bug report, or a bug fix. Let's hope for the latter! Profile tool backport release-3_44 labels Jun 10, 2026
@github-actions github-actions Bot added this to the 4.2.0 milestone Jun 10, 2026
vl = QgsVectorLayer("PolygonZ?crs=EPSG:3857", "polygon", "memory")
self.assertTrue(vl.isValid())

polygon_wkt = "Polygon Z ((547405.88 6150237.19 0, 547405.88 6150237.19 5, 547413.39 6150203.24 5, 547413.39 6150203.24 0, 547405.88 6150237.19 0))"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

those "random" looking coordinates are difficult to reason with. If there was a way of coming with simple looking coordinates, that might help (no strong requirement, just asking in case it is not too difficult)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No strong opinion. I just tried to stay in line with other unit test which use similar "random" coordinates.

@nyalldawson nyalldawson reopened this Jun 11, 2026
Comment thread tests/src/python/test_qgsvectorlayerprofilegenerator.py Outdated
With tolerance at 0, when a triangle from the tessellated polygon is
collinear In the XY plane, the `processTriangleLineIntersect` worflow
does not work and a special case is requirede.

In that case, the intersection between the profile line and the
profile line is computed. For every intersection, the Z value is
extracted. For each intersection, a Z value is calculated along the
edge. The lowest and highest Z values are then used to build the
vertical profile segment represented by the triangle.

This changes fixes 2 issues when iterating over the triangle edges:
1. Use the triangle, instead of the input polygon is used to compute
intersection
2. Preserve the first valid intersection point when processing
collinear triangles. Otherwise, a subsequent failed edge intersection
test may overwrite a previously valid intersection point, causing
profile segments to be skipped.
@ptitjano ptitjano force-pushed the profiletool-tolerance-tooltip branch from 225ccec to 8226eca Compare June 11, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release-3_44 Bug Either a bug report, or a bug fix. Let's hope for the latter! Profile tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants