1
0
Fork 0

Maintenance: groundnetwork

parameter 'seg' changed to const*.
++prefix for complex types.
SPDX tags.
This commit is contained in:
scttgs0 2023-05-23 19:39:50 -05:00
parent 6b40b1474e
commit f69d069175
2 changed files with 118 additions and 141 deletions

View file

@ -1,56 +1,40 @@
// groundnet.cxx - Implimentation of the FlightGear airport ground handling code
//
// Written by Durk Talsma, started June 2005.
//
// Copyright (C) 2004 Durk Talsma.
//
// 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 the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
/*
* SPDX-FileName: groundnet.cxx
* SPDX-FileComment: Implementation of the FlightGear airport ground handling code
* SPDX-FileCopyrightText: Copyright (C) 2004 Durk Talsma
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config.h>
#include "groundnetwork.hxx"
#include <cmath>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <map>
#include <iterator>
#include <map>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/timing/timestamp.hxx>
#include <simgear/math/SGLineSegment.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/SGGeometryFwd.hxx>
#include <simgear/math/SGIntersect.hxx>
#include <simgear/math/SGLineSegment.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/timing/timestamp.hxx>
#include <Airports/airport.hxx>
#include <Airports/runways.hxx>
#include <Scenery/scenery.hxx>
#include "groundnetwork.hxx"
using std::string;
/***************************************************************************
* FGTaxiSegment
**************************************************************************/
FGTaxiSegment::FGTaxiSegment(FGTaxiNode* aStart, FGTaxiNode* aEnd) :
startNode(aStart),
FGTaxiSegment::FGTaxiSegment(FGTaxiNode* aStart, FGTaxiNode* aEnd) : startNode(aStart),
endNode(aEnd),
isActive(0),
index(0),
@ -89,7 +73,6 @@ double FGTaxiSegment::getHeading() const
return SGGeodesy::courseDeg(getStart()->geod(), getEnd()->geod());
}
void FGTaxiSegment::block(int id, time_t blockTime, time_t now)
{
BlockListIterator i = blockTimes.begin();
@ -160,12 +143,12 @@ bool FGTaxiRoute::next(FGTaxiNodeRef& node, int* rte)
}
*rte = *(currRoute);
currRoute++;
++currRoute;
} else {
// Handle special case for the first node.
*rte = -1 * *(currRoute);
}
currNode++;
++currNode;
return true;
};
@ -173,8 +156,7 @@ bool FGTaxiRoute::next(FGTaxiNodeRef& node, int* rte)
* FGGroundNetwork()
**************************************************************************/
FGGroundNetwork::FGGroundNetwork(FGAirport* airport) :
parent(airport)
FGGroundNetwork::FGGroundNetwork(FGAirport* airport) : parent(airport)
{
hasNetwork = false;
version = 0;
@ -183,7 +165,6 @@ FGGroundNetwork::FGGroundNetwork(FGAirport* airport) :
FGGroundNetwork::~FGGroundNetwork()
{
for (auto seg : segments) {
delete seg;
}
@ -247,8 +228,7 @@ FGTaxiNodeRef FGGroundNetwork::findNearestNodeOffRunway(const SGGeod& aGeod, FGR
const SGVec3d cartPos = SGVec3d::fromGeod(aGeod);
std::copy_if(m_nodes.begin(), m_nodes.end(), std::back_inserter(nodes),
[runwayLine, cartPos, marginMSqr] (const FGTaxiNodeRef& a)
{
[runwayLine, cartPos, marginMSqr](const FGTaxiNodeRef& a) {
if (a->getIsOnRunway()) return false;
// exclude parking positions from consideration. This helps to
@ -261,11 +241,9 @@ FGTaxiNodeRef FGGroundNetwork::findNearestNodeOffRunway(const SGGeod& aGeod, FGR
});
// find closest of matching nodes
auto node = std::min_element(nodes.begin(), nodes.end(),
[cartPos](const FGTaxiNodeRef& a, const FGTaxiNodeRef& b)
{ return distSqr(cartPos, a->cart()) < distSqr(cartPos, b->cart()); });
[cartPos](const FGTaxiNodeRef& a, const FGTaxiNodeRef& b) { return distSqr(cartPos, a->cart()) < distSqr(cartPos, b->cart()); });
if (node == nodes.end()) {
return FGTaxiNodeRef();
@ -440,9 +418,9 @@ static int edgePenalty(FGTaxiNode* tn)
class ShortestPathData
{
public:
ShortestPathData() :
score(HUGE_VAL)
{}
ShortestPathData() : score(HUGE_VAL)
{
}
double score;
FGTaxiNodeRef previousNode;
@ -510,7 +488,6 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(FGTaxiNode* start, FGTaxiNode* en
int idx = segment->getIndex();
routes.push_back(idx);
bt = searchData[bt].previousNode;
}
nodes.push_back(start);
reverse(nodes.begin(), nodes.end());
@ -525,7 +502,7 @@ void FGGroundNetwork::unblockAllSegments(time_t now)
}
}
void FGGroundNetwork::blockSegmentsEndingAt(FGTaxiSegment *seg, int blockId, time_t blockTime, time_t now)
void FGGroundNetwork::blockSegmentsEndingAt(const FGTaxiSegment* seg, int blockId, time_t blockTime, time_t now)
{
if (!seg)
throw sg_exception("Passed invalid segment");
@ -614,7 +591,8 @@ FGTaxiNodeVector FGGroundNetwork::findSegmentsFrom(const FGTaxiNodeRef &from) co
return result;
}
FGTaxiSegment* FGGroundNetwork::findSegmentByHeading(const FGTaxiNode* from, const double heading) const {
FGTaxiSegment* FGGroundNetwork::findSegmentByHeading(const FGTaxiNode* from, const double heading) const
{
if (from == 0) {
return NULL;
}

View file

@ -295,8 +295,7 @@ public:
FGTaxiRoute findShortestRoute(FGTaxiNode* start, FGTaxiNode* end, bool fullSearch = true);
void blockSegmentsEndingAt(FGTaxiSegment* seg, int blockId,
time_t blockTime, time_t now);
void blockSegmentsEndingAt(const FGTaxiSegment* seg, int blockId, time_t blockTime, time_t now);
void addVersion(int v) { version = v; };
void unblockAllSegments(time_t now);