Commit c38c26ed authored by DoinLakeFlyer's avatar DoinLakeFlyer

parent 0bd92099
...@@ -538,6 +538,18 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void) ...@@ -538,6 +538,18 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void)
} }
emit lastSequenceNumberChanged(lastSequenceNumber()); emit lastSequenceNumberChanged(lastSequenceNumber());
// Update entry/exit coordinates
if (_transects.count()) {
if (_transects.first().count()) {
_coordinate.setAltitude(_transects.first().first().coord.altitude());
emit coordinateChanged(coordinate());
}
if (_transects.last().count()) {
_exitCoordinate.setAltitude(_transects.last().last().coord.altitude());
emit exitCoordinateChanged(exitCoordinate());
}
}
} }
} }
...@@ -653,32 +665,25 @@ void TransectStyleComplexItem::_adjustForTolerance(QList<CoordInfo_t>& transect) ...@@ -653,32 +665,25 @@ void TransectStyleComplexItem::_adjustForTolerance(QList<CoordInfo_t>& transect)
{ {
QList<CoordInfo_t> adjustedPoints; QList<CoordInfo_t> adjustedPoints;
double tolerance = _terrainAdjustToleranceFact.rawValue().toDouble(); if (transect.count()) {
double tolerance = _terrainAdjustToleranceFact.rawValue().toDouble();
int coordIndex = 0; CoordInfo_t& lastCoordInfo = transect.first();
while (coordIndex < transect.count()) {
const CoordInfo_t& fromCoordInfo = transect[coordIndex];
adjustedPoints.append(fromCoordInfo); adjustedPoints.append(lastCoordInfo);
// Walk forward until we fall out of tolerence or find a fixed point int coordIndex = 1;
while (++coordIndex < transect.count()) { while (coordIndex < transect.count()) {
const CoordInfo_t& toCoordInfo = transect[coordIndex]; // Walk forward until we fall out of tolerence. When we fall out of tolerance add that point.
if (toCoordInfo.coordType != CoordTypeInteriorTerrainAdded || qAbs(fromCoordInfo.coord.altitude() - toCoordInfo.coord.altitude()) > tolerance) { // We always add non-interstitial points no matter what.
adjustedPoints.append(toCoordInfo); const CoordInfo_t& nextCoordInfo = transect[coordIndex];
coordIndex++; if (nextCoordInfo.coordType != CoordTypeInteriorTerrainAdded || qAbs(lastCoordInfo.coord.altitude() - nextCoordInfo.coord.altitude()) > tolerance) {
break; adjustedPoints.append(nextCoordInfo);
lastCoordInfo = nextCoordInfo;
} }
coordIndex++;
} }
} }
#if 0
qDebug() << "_adjustForTolerance";
for (const TransectStyleComplexItem::CoordInfo_t& coordInfo: adjustedPoints) {
qDebug() << coordInfo.coordType;
}
#endif
transect = adjustedPoints; transect = adjustedPoints;
} }
...@@ -686,7 +691,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -686,7 +691,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
{ {
QList<CoordInfo_t> adjustedTransect; QList<CoordInfo_t> adjustedTransect;
double requestedAltitude = _cameraCalc.distanceToSurface()->rawValue().toDouble(); double distanceToSurface = _cameraCalc.distanceToSurface()->rawValue().toDouble();
for (int i=0; i<transect.count() - 1; i++) { for (int i=0; i<transect.count() - 1; i++) {
CoordInfo_t fromCoordInfo = transect[i]; CoordInfo_t fromCoordInfo = transect[i];
...@@ -697,8 +702,8 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -697,8 +702,8 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo[i]; const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo[i];
fromCoordInfo.coord.setAltitude(pathHeightInfo.heights.first() + requestedAltitude); fromCoordInfo.coord.setAltitude(pathHeightInfo.heights.first() + distanceToSurface);
toCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + requestedAltitude); toCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + distanceToSurface);
if (i == 0) { if (i == 0) {
adjustedTransect.append(fromCoordInfo); adjustedTransect.append(fromCoordInfo);
...@@ -712,7 +717,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -712,7 +717,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
CoordInfo_t interstitialCoordInfo; CoordInfo_t interstitialCoordInfo;
interstitialCoordInfo.coordType = CoordTypeInteriorTerrainAdded; interstitialCoordInfo.coordType = CoordTypeInteriorTerrainAdded;
interstitialCoordInfo.coord = fromCoordInfo.coord.atDistanceAndAzimuth(distance * percentTowardsTo, azimuth); interstitialCoordInfo.coord = fromCoordInfo.coord.atDistanceAndAzimuth(distance * percentTowardsTo, azimuth);
interstitialCoordInfo.coord.setAltitude(interstitialTerrainHeight + requestedAltitude); interstitialCoordInfo.coord.setAltitude(interstitialTerrainHeight + distanceToSurface);
adjustedTransect.append(interstitialCoordInfo); adjustedTransect.append(interstitialCoordInfo);
} }
...@@ -722,7 +727,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>& ...@@ -722,7 +727,7 @@ void TransectStyleComplexItem::_addInterstitialTerrainPoints(QList<CoordInfo_t>&
CoordInfo_t lastCoordInfo = transect.last(); CoordInfo_t lastCoordInfo = transect.last();
const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo.last(); const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo = transectPathHeightInfo.last();
lastCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + requestedAltitude); lastCoordInfo.coord.setAltitude(pathHeightInfo.heights.last() + distanceToSurface);
adjustedTransect.append(lastCoordInfo); adjustedTransect.append(lastCoordInfo);
#if 0 #if 0
......
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