Commit f8b54574 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5131 from DonLakeFlyer/LineSort

Plan: More fixes for line sorting
parents 3f0806ac 78c37693
...@@ -467,7 +467,6 @@ void SurveyMissionItem::_optimizeReflySegments(void) ...@@ -467,7 +467,6 @@ void SurveyMissionItem::_optimizeReflySegments(void)
} }
if (shortestIndex > 1) { if (shortestIndex > 1) {
qDebug() << "Reverse segments";
// We need to reverse the order of segments // We need to reverse the order of segments
QList<QList<QGeoCoordinate>> rgReversedTransects; QList<QList<QGeoCoordinate>> rgReversedTransects;
for (int i=_reflyTransectSegments.count() - 1; i>=0; i--) { for (int i=_reflyTransectSegments.count() - 1; i>=0; i--) {
...@@ -476,7 +475,6 @@ void SurveyMissionItem::_optimizeReflySegments(void) ...@@ -476,7 +475,6 @@ void SurveyMissionItem::_optimizeReflySegments(void)
_reflyTransectSegments = rgReversedTransects; _reflyTransectSegments = rgReversedTransects;
} }
if (shortestIndex & 1) { if (shortestIndex & 1) {
qDebug() << "Reverse points";
// We need to reverse the points within each segment // We need to reverse the points within each segment
for (int i=0; i<_reflyTransectSegments.count(); i++) { for (int i=0; i<_reflyTransectSegments.count(); i++) {
QList<QGeoCoordinate> rgReversedCoords; QList<QGeoCoordinate> rgReversedCoords;
...@@ -770,11 +768,16 @@ void SurveyMissionItem::_intersectLinesWithPolygon(const QList<QLineF>& lineList ...@@ -770,11 +768,16 @@ void SurveyMissionItem::_intersectLinesWithPolygon(const QList<QLineF>& lineList
/// Adjust the line segments such that they are all going the same direction with respect to going from P1->P2 /// Adjust the line segments such that they are all going the same direction with respect to going from P1->P2
void SurveyMissionItem::_adjustLineDirection(const QList<QLineF>& lineList, QList<QLineF>& resultLines) void SurveyMissionItem::_adjustLineDirection(const QList<QLineF>& lineList, QList<QLineF>& resultLines)
{ {
qreal firstAngle = 0;
for (int i=0; i<lineList.count(); i++) { for (int i=0; i<lineList.count(); i++) {
const QLineF& line = lineList[i]; const QLineF& line = lineList[i];
QLineF adjustedLine; QLineF adjustedLine;
if (line.angle() > 180.0) { if (i == 0) {
firstAngle = line.angle();
}
if (qAbs(line.angle() - firstAngle) > 1.0) {
adjustedLine.setP1(line.p2()); adjustedLine.setP1(line.p2());
adjustedLine.setP2(line.p1()); adjustedLine.setP2(line.p1());
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment