diff --git a/src/fs/bgl/ap/airport.cpp b/src/fs/bgl/ap/airport.cpp index 84153aca..c57084e5 100644 --- a/src/fs/bgl/ap/airport.cpp +++ b/src/fs/bgl/ap/airport.cpp @@ -773,14 +773,9 @@ void Airport::updateHelipads() void Airport::removeVehicleParking() { - QList::iterator it = std::remove_if(parkings.begin(), parkings.end(), - [](const Parking& p) -> bool - { + parkings.erase(std::remove_if(parkings.begin(), parkings.end(), [](const Parking& p) -> bool { return p.getType() == atools::fs::bgl::ap::VEHICLES; - }); - - if(it != parkings.end()) - parkings.erase(it, parkings.end()); + }), parkings.end()); } void Airport::updateTaxiPaths(const QList& taxipoints, const QStringList& taxinames) diff --git a/src/fs/db/airwayresolver.cpp b/src/fs/db/airwayresolver.cpp index a2ad5d01..6a37e85c 100644 --- a/src/fs/db/airwayresolver.cpp +++ b/src/fs/db/airwayresolver.cpp @@ -388,12 +388,9 @@ void AirwayResolver::buildAirway(const QString& airwayName, QSet& void AirwayResolver::cleanFragments(QVector& fragments) { // Erase empty segments - auto it = std::remove_if(fragments.begin(), fragments.end(), [](const Fragment& f) -> bool - { + fragments.erase(std::remove_if(fragments.begin(), fragments.end(), [](const Fragment& f) -> bool { return f.waypoints.size() < 2; - }); - if(it != fragments.end()) - fragments.erase(it, fragments.end()); + }), fragments.end()); // Erase all segments that are contained by another for(int i = 0; i < fragments.size(); i++) @@ -412,12 +409,9 @@ void AirwayResolver::cleanFragments(QVector& fragments) } // Remove the marked segments - auto it2 = std::remove_if(fragments.begin(), fragments.end(), [](const Fragment& f) -> bool - { + fragments.erase(std::remove_if(fragments.begin(), fragments.end(), [](const Fragment& f) -> bool { return f.waypoints.isEmpty(); - }); - if(it2 != fragments.end()) - fragments.erase(it2, fragments.end()); + }), fragments.end()); } } // namespace writer diff --git a/src/fs/db/nav/airwaysegmentwriter.cpp b/src/fs/db/nav/airwaysegmentwriter.cpp index 93afe789..8d4d067f 100644 --- a/src/fs/db/nav/airwaysegmentwriter.cpp +++ b/src/fs/db/nav/airwaysegmentwriter.cpp @@ -1,5 +1,5 @@ /***************************************************************************** -* Copyright 2015-2020 Alexander Barthel alex@littlenavmap.org +* Copyright 2015-2024 Alexander Barthel alex@littlenavmap.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,13 +16,12 @@ *****************************************************************************/ #include "fs/db/nav/airwaysegmentwriter.h" -#include "fs/db/meta/bglfilewriter.h" -#include "fs/db/datawriter.h" + +#include "atools.h" #include "fs/bgl/nav/airwaywaypoint.h" #include "fs/bgl/util.h" -#include "fs/db/nav/waypointwriter.h" +#include "fs/db/datawriter.h" #include "geo/calculations.h" -#include "atools.h" namespace atools { namespace fs { @@ -39,22 +38,18 @@ void AirwaySegmentWriter::writeObject(const AirwaySegment *type) bind(":mid_ident", type->getMidWaypoint().getIdent()); bind(":mid_region", type->getMidWaypoint().getRegion()); - bind(":mid_type", bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, - type->getMidWaypoint().getType())); + bind(":mid_type", bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, type->getMidWaypoint().getType())); if(type->hasNextWaypoint()) { using namespace atools::geo; using namespace atools; - bind(":next_type", - bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, - type->getNextWaypoint().getType())); + bind(":next_type", bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, type->getNextWaypoint().getType())); bind(":next_ident", type->getNextWaypoint().getIdent()); bind(":next_region", type->getNextWaypoint().getRegion()); bind(":next_airport_ident", type->getNextWaypoint().getAirportIdent()); - bind(":next_minimum_altitude", - roundToPrecision(meterToFeet(type->getNextWaypoint().getMinimumAltitude()), 1)); + bind(":next_minimum_altitude", roundToPrecision(meterToFeet(type->getNextWaypoint().getMinimumAltitude()), 1)); } else { @@ -70,13 +65,11 @@ void AirwaySegmentWriter::writeObject(const AirwaySegment *type) using namespace atools::geo; bind(":previous_type", - bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, - type->getPreviousWaypoint().getType())); + bgl::util::enumToStr(bgl::AirwayWaypoint::airwayWaypointTypeToStr, type->getPreviousWaypoint().getType())); bind(":previous_ident", type->getPreviousWaypoint().getIdent()); bind(":previous_region", type->getPreviousWaypoint().getRegion()); bind(":previous_airport_ident", type->getPreviousWaypoint().getAirportIdent()); - bind(":previous_minimum_altitude", - roundToPrecision(meterToFeet(type->getPreviousWaypoint().getMinimumAltitude()), 1)); + bind(":previous_minimum_altitude", roundToPrecision(meterToFeet(type->getPreviousWaypoint().getMinimumAltitude()), 1)); } else { diff --git a/src/fs/sc/datareaderthread.cpp b/src/fs/sc/datareaderthread.cpp index e971142d..a06f9ac6 100644 --- a/src/fs/sc/datareaderthread.cpp +++ b/src/fs/sc/datareaderthread.cpp @@ -135,7 +135,7 @@ void DataReaderThread::debugWriteWhazzup(const atools::fs::sc::SimConnectData& d // ac.setCoordinates(pos); } - // // Move N8 + //// Move N8 // if(reg.startsWith("N8")) // { // atools::geo::Pos pos = ac.getPosition(); @@ -349,26 +349,14 @@ void DataReaderThread::run() // Remove boat and ship traffic depending on settings for testing purposes QVector& aiAircraft = data.getAiAircraft(); if(!(opts & atools::fs::sc::FETCH_AI_AIRCRAFT)) - { - QVector::iterator it = - std::remove_if(aiAircraft.begin(), aiAircraft.end(), [] (const SimConnectAircraft &aircraft)->bool - { - return !aircraft.isUser() && !aircraft.isAnyBoat(); - }); - if(it != aiAircraft.end()) - aiAircraft.erase(it, aiAircraft.end()); - } + aiAircraft.erase(std::remove_if(aiAircraft.begin(), aiAircraft.end(), [] (const SimConnectAircraft& aircraft)->bool { + return !aircraft.isUser() && !aircraft.isAnyBoat(); + }), aiAircraft.end()); if(!(opts & atools::fs::sc::FETCH_AI_BOAT)) - { - QVector::iterator it = - std::remove_if(aiAircraft.begin(), aiAircraft.end(), [] (const SimConnectAircraft &aircraft)->bool - { - return !aircraft.isUser() && aircraft.isAnyBoat(); - }); - if(it != aiAircraft.end()) - aiAircraft.erase(it, aiAircraft.end()); - } + aiAircraft.erase(std::remove_if(aiAircraft.begin(), aiAircraft.end(), [] (const SimConnectAircraft& aircraft)->bool { + return !aircraft.isUser() && aircraft.isAnyBoat(); + }), aiAircraft.end()); if(!replayWhazzupFile.isEmpty()) debugWriteWhazzup(data); @@ -376,9 +364,9 @@ void DataReaderThread::run() #ifdef DEBUG_CREATE_WHAZZUP_TEST_FILTER data.getAiAircraft().erase(std::remove_if(data.getAiAircraft().begin(), data.getAiAircraft().end(), - [] (const SimConnectAircraft &type)->bool { - return type.getAirplaneRegistration() != "N2092Z"; - }), data.getAiAircraft().end()); + [] (const SimConnectAircraft& type)->bool { + return type.getAirplaneRegistration() != "N2092Z"; + }), data.getAiAircraft().end()); #endif emit postSimConnectData(data); @@ -472,9 +460,9 @@ void DataReaderThread::run() closeReplay(); if(failedTerminally) - terminate = true; // Drop dead + terminate = true; // Drop dead else - terminate = false; // Allow restart + terminate = false; // Allow restart connected = false; reconnecting = false; diff --git a/src/fs/userdata/airspacereaderopenair.cpp b/src/fs/userdata/airspacereaderopenair.cpp index 3b0e75ab..0dfda55f 100644 --- a/src/fs/userdata/airspacereaderopenair.cpp +++ b/src/fs/userdata/airspacereaderopenair.cpp @@ -135,8 +135,7 @@ void AirspaceReaderOpenAir::writeBoundary() insertAirspaceQuery->bindValue(":file_id", fileId); // Remove all remaining invalid points - auto it = std::remove_if(curLine.begin(), curLine.end(), [](const Pos& p) -> bool - { + auto it = std::remove_if(curLine.begin(), curLine.end(), [](const Pos& p) -> bool { return !p.isValidRange(); }); diff --git a/src/geo/linestring.cpp b/src/geo/linestring.cpp index 13878a93..cbe4b28b 100644 --- a/src/geo/linestring.cpp +++ b/src/geo/linestring.cpp @@ -123,14 +123,9 @@ void LineString::setAltitude(float alt) void LineString::removeInvalid() { - auto it = std::remove_if(begin(), end(), - [](const Pos& pos) -> bool - { + erase(std::remove_if(begin(), end(), [](const Pos& pos) -> bool { return !pos.isValid(); - }); - - if(it != end()) - erase(it, end()); + }), end()); } void LineString::removeDuplicates(float epsilon) diff --git a/src/gui/dockwidgethandler.cpp b/src/gui/dockwidgethandler.cpp index 0b6deb0b..33ac2ab8 100644 --- a/src/gui/dockwidgethandler.cpp +++ b/src/gui/dockwidgethandler.cpp @@ -426,11 +426,9 @@ void DockWidgetHandler::updateDockTabStatus(QDockWidget *dockWidget) if(it == dockStackList.end()) { - auto rmIt = std::remove_if(tabified.begin(), tabified.end(), [](QDockWidget *dock) -> bool { + tabified.erase(std::remove_if(tabified.begin(), tabified.end(), [](QDockWidget *dock) -> bool { return dock->isFloating(); - }); - if(rmIt != tabified.end()) - tabified.erase(rmIt, tabified.end()); + }), tabified.end()); if(!tabified.isEmpty()) { diff --git a/src/track/trackreader.cpp b/src/track/trackreader.cpp index 0e07dbb7..23ab72dc 100644 --- a/src/track/trackreader.cpp +++ b/src/track/trackreader.cpp @@ -103,8 +103,7 @@ int TrackReader::removeInvalid() int TrackReader::removeInvalid(TrackVectorType& trackVector) { - auto it = std::remove_if(trackVector.begin(), trackVector.end(), [](const Track& track) -> bool - { + auto it = std::remove_if(trackVector.begin(), trackVector.end(), [](const Track& track) -> bool { bool valid = track.isFullyValid(); if(!valid) qWarning() << "TrackReader: Invalid track " << track; @@ -325,15 +324,9 @@ void TrackReader::extractTracks(const QStringList& lines, const QRegularExpressi // Remove elements without waypoints ======================================= if(removeEmpty) - { - atools::track::TrackVectorType::iterator it = std::remove_if(temp.begin(), temp.end(), [](const Track& t) -> bool - { + temp.erase(std::remove_if(temp.begin(), temp.end(), [](const Track& t) -> bool { return t.route.isEmpty(); - }); - - if(it != temp.end()) - temp.erase(it, temp.end()); - } + }), temp.end()); tracks.append(temp); }