|
|
|
@ -444,16 +444,56 @@ void SurveyMissionItem::_convertTransectToGeo(const QList<QList<QPointF>>& trans
@@ -444,16 +444,56 @@ void SurveyMissionItem::_convertTransectToGeo(const QList<QList<QPointF>>& trans
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SurveyMissionItem::_convertPointsToGeo(const QList<QPointF>& pointsNED, const QGeoCoordinate& tangentOrigin, QVariantList& pointsGeo) |
|
|
|
|
void SurveyMissionItem::_optimizeReflySegments(void) |
|
|
|
|
{ |
|
|
|
|
pointsGeo.clear(); |
|
|
|
|
// The last flight point of the initial pass
|
|
|
|
|
QGeoCoordinate initialPassLastCoord = _transectSegments.last().last(); |
|
|
|
|
|
|
|
|
|
// Now determine where we should start the refly pass
|
|
|
|
|
|
|
|
|
|
double rgTransectDistance[4]; |
|
|
|
|
rgTransectDistance[0] = _reflyTransectSegments.first().first().distanceTo(initialPassLastCoord); |
|
|
|
|
rgTransectDistance[1] = _reflyTransectSegments.first().last().distanceTo(initialPassLastCoord); |
|
|
|
|
rgTransectDistance[2] = _reflyTransectSegments.last().first().distanceTo(initialPassLastCoord); |
|
|
|
|
rgTransectDistance[3] = _reflyTransectSegments.last().last().distanceTo(initialPassLastCoord); |
|
|
|
|
|
|
|
|
|
int shortestIndex = 0; |
|
|
|
|
double shortestDistance = rgTransectDistance[0]; |
|
|
|
|
for (int i=1; i<3; i++) { |
|
|
|
|
if (rgTransectDistance[i] < shortestDistance) { |
|
|
|
|
shortestIndex = i; |
|
|
|
|
shortestDistance = rgTransectDistance[i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i=0; i<pointsNED.count(); i++) { |
|
|
|
|
QGeoCoordinate geoCoord; |
|
|
|
|
const QPointF& point = pointsNED[i]; |
|
|
|
|
if (shortestIndex > 1) { |
|
|
|
|
qDebug() << "Reverse segments"; |
|
|
|
|
// We need to reverse the order of segments
|
|
|
|
|
QList<QList<QGeoCoordinate>> rgReversedTransects; |
|
|
|
|
for (int i=_reflyTransectSegments.count() - 1; i>=0; i--) { |
|
|
|
|
rgReversedTransects.append(_reflyTransectSegments[i]); |
|
|
|
|
} |
|
|
|
|
_reflyTransectSegments = rgReversedTransects; |
|
|
|
|
} |
|
|
|
|
if (shortestIndex & 1) { |
|
|
|
|
qDebug() << "Reverse points"; |
|
|
|
|
// We need to reverse the points within each segment
|
|
|
|
|
for (int i=0; i<_reflyTransectSegments.count(); i++) { |
|
|
|
|
QList<QGeoCoordinate> rgReversedCoords; |
|
|
|
|
QList<QGeoCoordinate>& rgOriginalCoords = _reflyTransectSegments[i]; |
|
|
|
|
for (int j=rgOriginalCoords.count()-1; j>=0; j++) { |
|
|
|
|
rgReversedCoords.append(rgOriginalCoords[j]); |
|
|
|
|
} |
|
|
|
|
_reflyTransectSegments[i] = rgReversedCoords; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
convertNedToGeo(-point.y(), point.x(), 0, tangentOrigin, &geoCoord); |
|
|
|
|
pointsGeo.append(QVariant::fromValue(geoCoord)); |
|
|
|
|
void SurveyMissionItem::_appendGridPointsFromTransects(QList<QList<QGeoCoordinate>>& rgTransectSegments) |
|
|
|
|
{ |
|
|
|
|
for (int i=0; i<rgTransectSegments.count(); i++) { |
|
|
|
|
_simpleGridPoints.append(QVariant::fromValue(rgTransectSegments[i].first())); |
|
|
|
|
_simpleGridPoints.append(QVariant::fromValue(rgTransectSegments[i].last())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -473,7 +513,6 @@ void SurveyMissionItem::_generateGrid(void)
@@ -473,7 +513,6 @@ void SurveyMissionItem::_generateGrid(void)
|
|
|
|
|
_reflyTransectSegments.clear(); |
|
|
|
|
|
|
|
|
|
QList<QPointF> polygonPoints; |
|
|
|
|
QList<QPointF> gridPoints; |
|
|
|
|
QList<QList<QPointF>> transectSegments; |
|
|
|
|
|
|
|
|
|
// Convert polygon to Qt coordinate system (y positive is down)
|
|
|
|
@ -499,18 +538,17 @@ void SurveyMissionItem::_generateGrid(void)
@@ -499,18 +538,17 @@ void SurveyMissionItem::_generateGrid(void)
|
|
|
|
|
|
|
|
|
|
// Generate grid
|
|
|
|
|
int cameraShots = 0; |
|
|
|
|
cameraShots += _gridGenerator(polygonPoints, gridPoints, transectSegments, false /* refly */); |
|
|
|
|
_convertPointsToGeo(gridPoints, tangentOrigin, _simpleGridPoints); |
|
|
|
|
cameraShots += _gridGenerator(polygonPoints, transectSegments, false /* refly */); |
|
|
|
|
_convertTransectToGeo(transectSegments, tangentOrigin, _transectSegments); |
|
|
|
|
_appendGridPointsFromTransects(_transectSegments); |
|
|
|
|
if (_refly90Degrees) { |
|
|
|
|
QVariantList reflyPointsGeo; |
|
|
|
|
|
|
|
|
|
gridPoints.clear(); |
|
|
|
|
transectSegments.clear(); |
|
|
|
|
cameraShots += _gridGenerator(polygonPoints, gridPoints, transectSegments, true /* refly */); |
|
|
|
|
_convertPointsToGeo(gridPoints, tangentOrigin, reflyPointsGeo); |
|
|
|
|
cameraShots += _gridGenerator(polygonPoints, transectSegments, true /* refly */); |
|
|
|
|
_convertTransectToGeo(transectSegments, tangentOrigin, _reflyTransectSegments); |
|
|
|
|
_simpleGridPoints.append(reflyPointsGeo); |
|
|
|
|
_optimizeReflySegments(); |
|
|
|
|
_appendGridPointsFromTransects(_reflyTransectSegments); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Calc survey distance
|
|
|
|
@ -681,7 +719,7 @@ void SurveyMissionItem::_adjustLineDirection(const QList<QLineF>& lineList, QLis
@@ -681,7 +719,7 @@ void SurveyMissionItem::_adjustLineDirection(const QList<QLineF>& lineList, QLis
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QList<QPointF>& simpleGridPoints, QList<QList<QPointF>>& transectSegments, bool refly) |
|
|
|
|
int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QList<QList<QPointF>>& transectSegments, bool refly) |
|
|
|
|
{ |
|
|
|
|
int cameraShots = 0; |
|
|
|
|
|
|
|
|
@ -690,7 +728,6 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
@@ -690,7 +728,6 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
|
|
|
|
|
|
|
|
|
|
qCDebug(SurveyMissionItemLog) << "SurveyMissionItem::_gridGenerator gridSpacing:gridAngle" << gridSpacing << gridAngle; |
|
|
|
|
|
|
|
|
|
simpleGridPoints.clear(); |
|
|
|
|
transectSegments.clear(); |
|
|
|
|
|
|
|
|
|
// Convert polygon to bounding rect
|
|
|
|
@ -793,9 +830,6 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
@@ -793,9 +830,6 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
|
|
|
|
|
transectPoints.append(transectLine.pointAt(1 + turnaroundPosition)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
simpleGridPoints.append(transectPoints[0]); |
|
|
|
|
simpleGridPoints.append(transectPoints[transectPoints.count() - 1]); |
|
|
|
|
|
|
|
|
|
transectSegments.append(transectPoints); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|