CircularSurveyComplexItem.cc 23.8 KB
Newer Older
1
#include "CircularSurveyComplexItem.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
2 3
#include "JsonHelper.h"
#include "QGCApplication.h"
4

Valentin Platzgummer's avatar
Valentin Platzgummer committed
5
const char* CircularSurveyComplexItem::settingsGroup =              "CircularSurvey";
6 7
const char* CircularSurveyComplexItem::deltaRName =                 "DeltaR";
const char* CircularSurveyComplexItem::deltaAlphaName =             "DeltaAlpha";
8

Valentin Platzgummer's avatar
Valentin Platzgummer committed
9 10 11 12 13 14 15
const char* CircularSurveyComplexItem::jsonComplexItemTypeValue     =   "circularSurvey";
const char* CircularSurveyComplexItem::jsonDeltaRKey                =   "deltaR";
const char* CircularSurveyComplexItem::jsonDeltaAlphaKey            =   "deltaAlpha";
const char* CircularSurveyComplexItem::jsonReferencePointLatKey     =   "referencePointLat";
const char* CircularSurveyComplexItem::jsonReferencePointLongKey    =   "referencePointLong";
const char* CircularSurveyComplexItem::jsonReferencePointAltKey     =   "referencePointAlt";

16
CircularSurveyComplexItem::CircularSurveyComplexItem(Vehicle *vehicle, bool flyView, const QString &kmlOrShpFile, QObject *parent)
17
    :   TransectStyleComplexItem    (vehicle, flyView, settingsGroup, parent)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
18
    ,   _referencePoint             (QGeoCoordinate(0, 0,0))
19 20 21
    ,   _metaDataMap                (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CircularSurvey.SettingsGroup.json"), this))
    ,   _deltaR                     (settingsGroup, _metaDataMap[deltaRName])
    ,   _deltaAlpha                 (settingsGroup, _metaDataMap[deltaAlphaName])
Valentin Platzgummer's avatar
Valentin Platzgummer committed
22
    ,   _autoGenerated              (false)
23
{
24 25
    _editorQml = "qrc:/qml/CircularSurveyItemEditor.qml";

Valentin Platzgummer's avatar
Valentin Platzgummer committed
26 27 28
    connect(&_deltaR,       &Fact::valueChanged, this, &CircularSurveyComplexItem::_setDirty);
    connect(&_deltaAlpha,   &Fact::valueChanged, this, &CircularSurveyComplexItem::_setDirty);
    connect(this,           &CircularSurveyComplexItem::refPointChanged, this, &CircularSurveyComplexItem::_setDirty);
29

Valentin Platzgummer's avatar
Valentin Platzgummer committed
30 31 32 33
    _deltaR.setRawValue(_deltaR.rawDefaultValue());
    _deltaAlpha.setRawValue(_deltaAlpha.rawDefaultValue());
    qDebug() << _deltaAlpha.rawDefaultValue().toDouble();
    qDebug() << _deltaAlpha.rawValue().toDouble();
34

35 36
    connect(&_updateTimer, &QTimer::timeout, this, &CircularSurveyComplexItem::_updateItem);
    _updateTimer.start(100);
37 38 39
}

void CircularSurveyComplexItem::setRefPoint(const QGeoCoordinate &refPt)
40
{
41 42
    if (refPt != _referencePoint){
        _referencePoint = refPt;
43

44
        emit refPointChanged();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
45
        //qDebug() << _referencePoint.toString();
46 47 48
    }
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
49 50 51 52 53 54 55 56 57
void CircularSurveyComplexItem::setAutoGenerated(bool autoGen)
{
    if (autoGen != _autoGenerated) {
        _autoGenerated = autoGen;

        emit autoGeneratedChanged();
    }
}

58 59 60
QGeoCoordinate CircularSurveyComplexItem::refPoint() const
{
    return _referencePoint;
61 62
}

63 64 65 66 67 68 69 70 71 72
Fact *CircularSurveyComplexItem::deltaR()
{
    return &_deltaR;
}

Fact *CircularSurveyComplexItem::deltaAlpha()
{
    return &_deltaAlpha;
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
73 74 75 76 77
bool CircularSurveyComplexItem::autoGenerated()
{
    return _autoGenerated;
}

78 79
bool CircularSurveyComplexItem::load(const QJsonObject &complexObject, int sequenceNumber, QString &errorString)
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
    // We need to pull version first to determine what validation/conversion needs to be performed
    QList<JsonHelper::KeyValidateInfo> versionKeyInfoList = {
        { JsonHelper::jsonVersionKey, QJsonValue::Double, true },
    };
    if (!JsonHelper::validateKeys(complexObject, versionKeyInfoList, errorString)) {
        return false;
    }

    int version = complexObject[JsonHelper::jsonVersionKey].toInt();
    if (version != 1) {
        errorString = tr("Survey items do not support version %1").arg(version);
        return false;
    }

    QList<JsonHelper::KeyValidateInfo> keyInfoList = {
        { VisualMissionItem::jsonTypeKey,               QJsonValue::String, true },
        { ComplexMissionItem::jsonComplexItemTypeKey,   QJsonValue::String, true },
        { jsonDeltaRKey,                                QJsonValue::Double, true },
        { jsonDeltaAlphaKey,                            QJsonValue::Double, true },
        { jsonReferencePointLatKey,                     QJsonValue::Double, true },
        { jsonReferencePointLongKey,                     QJsonValue::Double, true },
        { jsonReferencePointAltKey,                     QJsonValue::Double, true },
    };


    if (!JsonHelper::validateKeys(complexObject, keyInfoList, errorString)) {
        return false;
    }

    QString itemType = complexObject[VisualMissionItem::jsonTypeKey].toString();
    QString complexType = complexObject[ComplexMissionItem::jsonComplexItemTypeKey].toString();
    if (itemType != VisualMissionItem::jsonTypeComplexItemValue || complexType != jsonComplexItemTypeValue) {
        errorString = tr("%1 does not support loading this complex mission item type: %2:%3").arg(qgcApp()->applicationName()).arg(itemType).arg(complexType);
        return false;
    }

    _ignoreRecalc = true;

    setSequenceNumber(sequenceNumber);

    if (!_surveyAreaPolygon.loadFromJson(complexObject, true /* required */, errorString)) {
        _surveyAreaPolygon.clear();
        return false;
    }

    if (!_load(complexObject, errorString)) {
        _ignoreRecalc = false;
        return false;
    }

    _deltaR.setRawValue             (complexObject[jsonDeltaRKey].toDouble());
    _deltaAlpha.setRawValue         (complexObject[jsonDeltaAlphaKey].toDouble());
    _referencePoint.setLongitude    (complexObject[jsonReferencePointLongKey].toDouble());
    _referencePoint.setLatitude     (complexObject[jsonReferencePointLatKey].toDouble());
    _referencePoint.setAltitude     (complexObject[jsonReferencePointAltKey].toDouble());
    _autoGenerated = true;

    _ignoreRecalc = false;

    _recalcComplexDistance();
    if (_cameraShots == 0) {
        // Shot count was possibly not available from plan file
        _recalcCameraShots();
    }

    return true;
146 147 148 149
}

void CircularSurveyComplexItem::save(QJsonArray &planItems)
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
150 151 152 153 154 155 156
    QJsonObject saveObject;

    _save(saveObject);

    saveObject[JsonHelper::jsonVersionKey] =                    1;
    saveObject[VisualMissionItem::jsonTypeKey] =                VisualMissionItem::jsonTypeComplexItemValue;
    saveObject[ComplexMissionItem::jsonComplexItemTypeKey] =    jsonComplexItemTypeValue;
157

Valentin Platzgummer's avatar
Valentin Platzgummer committed
158 159 160 161 162 163 164 165 166 167
    saveObject[jsonDeltaRKey]               = _deltaR.rawValue().toDouble();
    saveObject[jsonDeltaAlphaKey]           = _deltaAlpha.rawValue().toDouble();
    saveObject[jsonReferencePointLongKey]   = _referencePoint.longitude();
    saveObject[jsonReferencePointLatKey]    = _referencePoint.latitude();
    saveObject[jsonReferencePointAltKey]    = _referencePoint.altitude();

    // Polygon shape
    _surveyAreaPolygon.saveToJson(saveObject);

    planItems.append(saveObject);
168 169 170 171
}

void CircularSurveyComplexItem::appendMissionItems(QList<MissionItem *> &items, QObject *missionItemParent)
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
172 173 174 175 176 177 178 179 180 181 182 183
    if (_loadedMissionItems.count()) {
        // We have mission items from the loaded plan, use those
        _appendLoadedMissionItems(items, missionItemParent);
    } else {
        // Build the mission items on the fly
        _buildAndAppendMissionItems(items, missionItemParent);
    }
}

void CircularSurveyComplexItem::_appendLoadedMissionItems(QList<MissionItem*>& items, QObject* missionItemParent)
{
    //qCDebug(SurveyComplexItemLog) << "_appendLoadedMissionItems";
184

Valentin Platzgummer's avatar
Valentin Platzgummer committed
185 186 187 188 189 190 191
    int seqNum = _sequenceNumber;

    for (const MissionItem* loadedMissionItem: _loadedMissionItems) {
        MissionItem* item = new MissionItem(*loadedMissionItem, missionItemParent);
        item->setSequenceNumber(seqNum++);
        items.append(item);
    }
192 193
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
194
void CircularSurveyComplexItem::_buildAndAppendMissionItems(QList<MissionItem*>& items, QObject* missionItemParent)
195
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
    // original code: SurveyComplexItem::_buildAndAppendMissionItems()
    //qCDebug(SurveyComplexItemLog) << "_buildAndAppendMissionItems";

    // Now build the mission items from the transect points

    MissionItem* item;
    int seqNum =                    _sequenceNumber;
    // bool imagesEverywhere =         _cameraTriggerInTurnAroundFact.rawValue().toBool();
    // bool addTriggerAtBeginning =    !hoverAndCaptureEnabled() && imagesEverywhere;
    bool firstOverallPoint =        true;

    MAV_FRAME mavFrame = followTerrain() || !_cameraCalc.distanceToSurfaceRelative() ? MAV_FRAME_GLOBAL : MAV_FRAME_GLOBAL_RELATIVE_ALT;

    for (const QList<TransectStyleComplexItem::CoordInfo_t>& transect: _transects) {
        //bool transectEntry = true;

        for (const CoordInfo_t& transectCoordInfo: transect) {
            item = new MissionItem(seqNum++,
                                   MAV_CMD_NAV_WAYPOINT,
                                   mavFrame,
                                   0,                                           // Hold time (delay for hover and capture to settle vehicle before image is taken)
                                   0.0,                                         // No acceptance radius specified
                                   0.0,                                         // Pass through waypoint
                                   std::numeric_limits<double>::quiet_NaN(),    // Yaw unchanged
                                   transectCoordInfo.coord.latitude(),
                                   transectCoordInfo.coord.longitude(),
                                   transectCoordInfo.coord.altitude(),
                                   true,                                        // autoContinue
                                   false,                                       // isCurrentItem
                                   missionItemParent);
            items.append(item);
            // implement capture if desired
//            if (hoverAndCaptureEnabled()) {
//                item = new MissionItem(seqNum++,
//                                       MAV_CMD_IMAGE_START_CAPTURE,
//                                       MAV_FRAME_MISSION,
//                                       0,                                   // Reserved (Set to 0)
//                                       0,                                   // Interval (none)
//                                       1,                                   // Take 1 photo
//                                       qQNaN(), qQNaN(), qQNaN(), qQNaN(),  // param 4-7 reserved
//                                       true,                                // autoContinue
//                                       false,                               // isCurrentItem
//                                       missionItemParent);
//                items.append(item);
//            }

//            if (firstOverallPoint && addTriggerAtBeginning) {
//                // Start triggering
//                addTriggerAtBeginning = false;
//                item = new MissionItem(seqNum++,
//                                       MAV_CMD_DO_SET_CAM_TRIGG_DIST,
//                                       MAV_FRAME_MISSION,
//                                       triggerDistance(),   // trigger distance
//                                       0,                   // shutter integration (ignore)
//                                       1,                   // trigger immediately when starting
//                                       0, 0, 0, 0,          // param 4-7 unused
//                                       true,                // autoContinue
//                                       false,               // isCurrentItem
//                                       missionItemParent);
//                items.append(item);
//            }
            firstOverallPoint = false;

//            // Possibly add trigger start/stop to survey area entrance/exit
//            if (triggerCamera() && !hoverAndCaptureEnabled() && transectCoordInfo.coordType == TransectStyleComplexItem::CoordTypeSurveyEdge) {
//                if (transectEntry) {
//                    // Start of transect, always start triggering. We do this even if we are taking images everywhere.
//                    // This allows a restart of the mission in mid-air without losing images from the entire mission.
//                    // At most you may lose part of a transect.
//                    item = new MissionItem(seqNum++,
//                                           MAV_CMD_DO_SET_CAM_TRIGG_DIST,
//                                           MAV_FRAME_MISSION,
//                                           triggerDistance(),   // trigger distance
//                                           0,                   // shutter integration (ignore)
//                                           1,                   // trigger immediately when starting
//                                           0, 0, 0, 0,          // param 4-7 unused
//                                           true,                // autoContinue
//                                           false,               // isCurrentItem
//                                           missionItemParent);
//                    items.append(item);
//                    transectEntry = false;
//                } else if (!imagesEverywhere && !transectEntry){
//                    // End of transect, stop triggering
//                    item = new MissionItem(seqNum++,
//                                           MAV_CMD_DO_SET_CAM_TRIGG_DIST,
//                                           MAV_FRAME_MISSION,
//                                           0,           // stop triggering
//                                           0,           // shutter integration (ignore)
//                                           0,           // trigger immediately when starting
//                                           0, 0, 0, 0,  // param 4-7 unused
//                                           true,        // autoContinue
//                                           false,       // isCurrentItem
//                                           missionItemParent);
//                    items.append(item);
//                }
//            }
        }
    }

    // implemetn photo capture if desired
//    if (triggerCamera() && !hoverAndCaptureEnabled() && imagesEverywhere) {
//        // Stop triggering
//        MissionItem* item = new MissionItem(seqNum++,
//                                            MAV_CMD_DO_SET_CAM_TRIGG_DIST,
//                                            MAV_FRAME_MISSION,
//                                            0,           // stop triggering
//                                            0,           // shutter integration (ignore)
//                                            0,           // trigger immediately when starting
//                                            0, 0, 0, 0,  // param 4-7 unused
//                                            true,        // autoContinue
//                                            false,       // isCurrentItem
//                                            missionItemParent);
//        items.append(item);
//    }
}
311

Valentin Platzgummer's avatar
Valentin Platzgummer committed
312 313 314 315 316
void CircularSurveyComplexItem::applyNewAltitude(double newAltitude)
{
    _cameraCalc.valueSetIsDistance()->setRawValue(true);
    _cameraCalc.distanceToSurface()->setRawValue(newAltitude);
    _cameraCalc.setDistanceToSurfaceRelative(true);
317 318 319 320 321 322 323 324 325
}

double CircularSurveyComplexItem::timeBetweenShots()
{
    return 1;
}

bool CircularSurveyComplexItem::readyForSave() const
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
326
    return TransectStyleComplexItem::readyForSave();
327 328 329 330 331 332 333 334 335
}

double CircularSurveyComplexItem::additionalTimeDelay() const
{
    return 0;
}

void CircularSurveyComplexItem::_rebuildTransectsPhase1()
{
336 337 338 339
    using namespace GeoUtilities;
    using namespace PolygonCalculus;
    using namespace PlanimetryCalculus;

340 341 342
    if ( _surveyAreaPolygon.count() < 3)
        return;

343
    _transects.clear();
344 345 346
    QPolygonF surveyPolygon = toQPolygonF(toCartesian2D(_surveyAreaPolygon.coordinateList(), _referencePoint));

    QVector<double> distances;
347 348
    for (const QPointF &p : surveyPolygon) distances.append(norm(p));

349 350 351 352 353 354 355 356 357
    // check if input is valid
    if (   _deltaAlpha.rawValue() > _deltaAlpha.rawMax()
           && _deltaAlpha.rawValue() < _deltaAlpha.rawMin())
        return;
    if (   _deltaR.rawValue() > _deltaR.rawMax()
           && _deltaR.rawValue() < _deltaR.rawMin())
        return;


Valentin Platzgummer's avatar
Valentin Platzgummer committed
358
    double dalpha = _deltaAlpha.rawValue().toDouble()/180.0*M_PI; // radiants
359
    double dr = _deltaR.rawValue().toDouble(); // meter
Valentin Platzgummer's avatar
Valentin Platzgummer committed
360 361
//    double dalpha = 1.0/180.0*M_PI; // radiants
//    double dr = 10.0; // meter
362 363 364 365 366
    double r_min = dr; // meter
    double r_max = (*std::max_element(distances.begin(), distances.end())); // meter

    QPointF origin(0, 0);
    IntersectType type;
367
    bool originInside = true;
368 369 370 371 372
    if (!contains(surveyPolygon, origin, type)) {
        QVector<double> angles;
        for (const QPointF &p : surveyPolygon) angles.append(truncateAngle(angle(p)));

        // determine r_min by successive approximation
373 374
        double r = r_min;
        while ( r < r_max) {
375 376
            Circle circle(r, origin);

377
            if (intersects(circle, surveyPolygon)) {
378 379 380 381
                r_min = r;
                break;
            }

382
            r += dr;
383
        }
384
        originInside = false;
385 386
    }

387 388 389
//    qWarning("r_min, r_max:");
//    qWarning() << r_min;
//    qWarning() << r_max;
390 391 392 393

    QList<QPolygonF> convexPolygons;
    decomposeToConvex(surveyPolygon, convexPolygons);

394
    QList<QList<QPointF>> fullPath;
395
    for (int i = 0; i < convexPolygons.size(); i++) {
396
        const QPolygonF &polygon = convexPolygons[i];
397
        double r = r_min;
398

399 400
        QList<QList<QPointF>> currPolyPath;
        while (r < r_max) {
401
            Circle circle(r, origin);
402 403
            QList<QPointFList> intersectPoints;
            QList<IntersectType> typeList;
404 405
            QList<QPair<int, int>> neighbourList;
            if (intersects(circle, polygon, intersectPoints, neighbourList, typeList)) {
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431

                // intersection Points between circle and polygon, entering polygon
                // when walking in counterclockwise direction along circle
                QPointFList entryPoints;
                // intersection Points between circle and polygon, leaving polygon
                // when walking in counterclockwise direction along circle
                QPointFList exitPoints;
                // determine entryPoints and exit Points
                for (int j = 0; j < intersectPoints.size(); j++) {
                    QList<QPointF> intersects = intersectPoints[j];

                    QPointF p1 = polygon[neighbourList[j].first];
                    QPointF p2 = polygon[neighbourList[j].second];
                    QLineF intersetLine(p1, p2);
                    double lineAngle = truncateAngle(angle(intersetLine));

                    for (QPointF ipt : intersects) {
                        double circleTangentAngle = truncateAngle(angle(ipt)+M_PI_2);
                        // compare line angle and circle tangent at intersection point
                        // to determine between exit and entry point
                        if (   !qFuzzyCompare(lineAngle, circleTangentAngle)
                            && !qFuzzyCompare(lineAngle, truncateAngle(circleTangentAngle + M_PI))) {
                            if (truncateAngle(lineAngle - circleTangentAngle)  < M_PI) {
                                entryPoints.append(ipt);
                            } else {
                                exitPoints.append(ipt);
432 433
                            }
                        }
434 435
                    }
                }
436

437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
                // sort
                std::sort(entryPoints.begin(), entryPoints.end(), [](QPointF p1, QPointF p2) {
                   return angle(p1) < angle(p2);
                });
                std::sort(exitPoints.begin(), exitPoints.end(), [](QPointF p1, QPointF p2) {
                   return angle(p1) < angle(p2);
                });

                // match entry and exit points
                int offset = 0;
                double minAngle = std::numeric_limits<double>::infinity();
                for (int k = 0; k < exitPoints.size(); k++) {
                    QPointF pt = exitPoints[k];
                    double alpha = truncateAngle(angle(pt) - angle(entryPoints[0]));
                    if (minAngle > alpha) {
                        minAngle = alpha;
                        offset = k;
                    }
                }
456

457 458 459
                for (int k = 0; k < entryPoints.size(); k++) {
                    double alpha1 = angle(entryPoints[k]);
                    double alpha2 = angle(exitPoints[(k+offset) % entryPoints.size()]);
460

461
                    QList<QPointF> sectorPath = circle.approximateSektor(double(dalpha), alpha1, alpha2);
462 463
                    // use shortestPath() here if necessary, could be a problem if dr >>
                    if (sectorPath.size() > 0)
464 465
                        currPolyPath.append(sectorPath);
                }
466 467
            } else if (originInside) {
                // circle fully inside polygon
468
                QList<QPointF> sectorPath = circle.approximateSektor(double(dalpha), 0, 2*M_PI);
469 470
                // use shortestPath() here if necessary, could be a problem if dr >>
                currPolyPath.append(sectorPath);
471 472
            }
            r += dr;
473 474 475
         }
        if (currPolyPath.size() > 0) {
            fullPath.append(currPolyPath);
476
        }
477
    }
478

Valentin Platzgummer's avatar
Valentin Platzgummer committed
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
    // optimize path to lawn pattern
    if (fullPath.size() == 0)
        return;
    QList<QPointF> currentSection = fullPath.takeFirst();
    if ( currentSection.isEmpty() )
        return;
    QList<QList<QPointF>> optiPath; // optimized path
    while( !fullPath.empty() ) {
        optiPath.append(currentSection);
        QPointF endVertex = currentSection.last();
        double minDist = std::numeric_limits<double>::infinity();
        int index = 0;
        bool reversePath = false;

        // iterate over all paths in fullPath and assign the one with the shortest distance to endVertex to currentSection
        for (int i = 0; i < fullPath.size(); i++) {
            auto iteratorPath = fullPath[i];
            double dist = PlanimetryCalculus::distance(endVertex, iteratorPath.first());
            if ( dist < minDist ) {
                minDist = dist;
                index = i;
            }
            dist = PlanimetryCalculus::distance(endVertex, iteratorPath.last());
            if (dist < minDist) {
                minDist = dist;
                index = i;
                reversePath = true;
            }
        }
        currentSection = fullPath.takeAt(index);
        if (reversePath) {
            PolygonCalculus::reversePath(currentSection);
        }
    }

    optiPath.append(currentSection); // append last section
515

516 517

    // convert to CoordInfo_t
Valentin Platzgummer's avatar
Valentin Platzgummer committed
518 519
    for ( const QList<QPointF> &transect : optiPath) {
//    for ( const QList<QPointF> &transect : fullPath) {
520 521 522 523 524 525 526 527
        QList<QGeoCoordinate> geoPath = toGeo(transect, _referencePoint);
        QList<CoordInfo_t> transectList;
        for ( const QGeoCoordinate &coordinate : geoPath) {
            CoordInfo_t coordinfo = {coordinate, CoordTypeInterior};
            transectList.append(coordinfo);
        }
        _transects.append(transectList);
    }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
528

529 530 531 532
}

void CircularSurveyComplexItem::_recalcComplexDistance()
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
533 534 535 536 537
    _complexDistance = 0;
    for (int i=0; i<_visualTransectPoints.count() - 1; i++) {
        _complexDistance += _visualTransectPoints[i].value<QGeoCoordinate>().distanceTo(_visualTransectPoints[i+1].value<QGeoCoordinate>());
    }
    emit complexDistanceChanged();
538 539
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
540
// no cameraShots in Circular Survey, add if desired
541 542
void CircularSurveyComplexItem::_recalcCameraShots()
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
543
    _cameraShots = 0;
544 545
}

546 547 548 549
void CircularSurveyComplexItem::_updateItem()
{
    if (_dirty) {
        _rebuildTransects();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
550
        qDebug() << "CircularSurveyComplexItem::_updateItem()";
551 552 553 554 555
        setDirty(false);
    }

}

556 557 558 559 560 561 562 563 564 565 566
/*!
    \class CircularSurveyComplexItem
    \inmodule Wima

    \brief The \c CircularSurveyComplexItem class provides a survey mission item with circular transects around a point of interest.

    CircularSurveyComplexItem class provides a survey mission item with circular transects around a point of interest. Within the
    \c Wima module it's used to scan a defined area with constant angle (circular transects) to the base station (point of interest).

    \sa WimaArea
*/