Skip to content

Conversation

@lbartoletti
Copy link
Member

Description

@nicogodet Follow up our discussion on #61545

@DelazJ after this pr, we can rewrite the documentation 😉

I'm not sure about the wording here.

@lbartoletti lbartoletti self-assigned this Dec 19, 2025
@lbartoletti lbartoletti added Processing Relating to QGIS Processing framework or individual Processing algorithms Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. labels Dec 19, 2025
@github-actions github-actions bot added this to the 4.0.0 milestone Dec 19, 2025
@qgis-bot
Copy link
Collaborator

@lbartoletti
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit f186cbc)

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This installer is not signed, control+click > open the app to avoid the warning
(Built from commit f186cbc)

@nicogodet
Copy link
Member

Thank you @lbartoletti!
I would have seen a combobox with 2 options Right to Left and Left to Right for better clarity.
Checkbox "Swap direction" is quite obscure as you don't necessary know the default direction so you need in every cases to check the documentation.

@lbartoletti
Copy link
Member Author

Thank you @lbartoletti! I would have seen a combobox with 2 options Right to Left and Left to Right for better clarity. Checkbox "Swap direction" is quite obscure as you don't necessary know the default direction so you need in every cases to check the documentation.

Yes, it makes sense.

@lbartoletti lbartoletti force-pushed the transect_swap_orientation branch from 29dcb8b to d3acfe7 Compare December 19, 2025 13:02

addParameter( new QgsProcessingParameterEnum( QStringLiteral( "SIDE" ), QObject::tr( "Side to create the transects" ), QStringList() << QObject::tr( "Left" ) << QObject::tr( "Right" ) << QObject::tr( "Both" ), false, 2 ) );

auto direction = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "DIRECTION" ), QObject::tr( "Direction" ), QStringList() << QObject::tr( "Left to Right" ) << QObject::tr( "Right to Left" ), false, 0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think this should be marked 'optional' to maintain compatibility with older scripts?

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, good idea.

@lbartoletti lbartoletti force-pushed the transect_swap_orientation branch from d3acfe7 to f186cbc Compare December 22, 2025 16:54
Comment on lines +229 to +241
// Direction determines the line orientation:
// - LeftToRight: line goes from pLeft to pRight (default)
// - RightToLeft: line goes from pRight to pLeft (hydraulic convention - perpendicular from stream bank looking downstream)
if ( direction == QgsTransectAlgorithmBase::RightToLeft )
{
line.append( pRight );
line.append( pLeft );
}
else
{
line.append( pLeft );
line.append( pRight );
}
Copy link
Member

@nicogodet nicogodet Dec 23, 2025

Choose a reason for hiding this comment

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

This is wrong.
pLeft and pRight are inverted.

Image

Current behavior is Right to Left.
So currently, pLeft stores the right point and pRight stores the left point.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, it should be:

  if ( direction == QgsTransectAlgorithmBase::RightToLeft )
  {
    line.append( pLeft );
    line.append( pRight );
  }
  else
  {
    line.append( pRight );
    line.append( pLeft );
  }

Copy link
Member

Choose a reason for hiding this comment

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

I believe so
and rename pLeft and pRight ?

Copy link
Member

Choose a reason for hiding this comment

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

Can't write a suggestion but here is what I would do:

QgsGeometry QgsTransectAlgorithmBase::calcTransect( const QgsPoint &point, const double angleAtVertex, const double length, const QgsTransectAlgorithmBase::Side orientation, const double angle, const QgsTransectAlgorithmBase::Direction direction )
{
  // Transect is built from right to left relative to the reference line direction.
  QgsPoint pStart;  // start point of the transect
  QgsPoint pEnd;  // end point of the transect

  QgsPolyline transect;

  switch ( orientation )
  {
    case QgsTransectAlgorithmBase::Right:
      pStart = point.project( length, angle + 180.0 / M_PI * angleAtVertex );
      pEnd = point;
      break;

    case QgsTransectAlgorithmBase::Left:
      pEnd = point.project( -length, angle + 180.0 / M_PI * angleAtVertex );
      pStart = point;
      break;

    case QgsTransectAlgorithmBase::Both:
      pStart = point.project( length, angle + 180.0 / M_PI * angleAtVertex );
      pEnd = point.project( -length, angle + 180.0 / M_PI * angleAtVertex );
      break;
  }

  // Direction determines the transect orientation relative to the reference line direction:
  // - RightToLeft: transect goes from pStart to pEnd (default)
  // - LeftToRight: transect goes from pEnd to pStart (hydraulic convention - from left bank to right bank  looking downstream)
  if ( direction == QgsTransectAlgorithmBase::RightToLeft )
  {
    transect.append( pStart );
    transect.append( pEnd );
  }
  else
  {
    transect.append( pEnd );
    transect.append( pStart );
  }

  return QgsGeometry::fromPolyline( transect );
}
  • Do not mention line to avoid confusion with the line from which we are creating transects, mention transect instead
  • Use pStart and pEnd during transect construction (mention at beginning that transect is built from right to left relative to the reference line direction.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 7, 2026
@lbartoletti lbartoletti removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Processing Relating to QGIS Processing framework or individual Processing algorithms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants