FlightGear next
AirportGroundRadar.hxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: AirportGroundRadar.hxx
3 * SPDX-FileComment: Implementation of the FlightGear Ground radar
4 * SPDX-FileCopyrightText: Copyright (C) 2023 Keith Paterson
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9#include <simgear/math/SGGeod.hxx>
10#include <simgear/structure/SGSharedPtr.hxx>
11
12#include "AIModel/AIBase.hxx"
15#include "ATC/QuadTree.hxx"
16
18using FGTrafficRef = SGSharedPtr<FGTrafficRecord>;
19
24class AirportGroundRadar: public SGReferenced {
25public:
26// for index
28 static SGRect<double> getBox(FGTrafficRef aiObject) {
29 /*
30 if ((*aiObject).getCallsign() == "BA780") {
31 SG_LOG(SG_ATC, SG_ALERT, "getBox " << (*aiObject).getCallsign() << "(" << (*aiObject).getId() << ") " << aiObject << " " << (*aiObject).getPos().getLatitudeDeg() << " " << (*aiObject).getPos().getLongitudeDeg());
32 }
33 */
34 return SGRect<double>((*aiObject).getPos().getLatitudeDeg(),
35 (*aiObject).getPos().getLongitudeDeg());
36 };
37
38 static bool equal(FGTrafficRef o, FGTrafficRef o2) {
39// if ((*o).getCallsign() == "BA780") {
40 //SG_LOG(SG_ATC, SG_DEBUG, (*o).getCallsign() << "(" << (*o).getId() << ")" << o << "/" << (*o2).getCallsign() << "(" << (*o2).getId() << ")" << o2);
41// }
42 return (*o).getId() == (*o2).getId();
43 };
44
45private:
46 const double QUERY_BOX_SIZE = 0.1;
47 const int SEPARATION = 4;
48 QuadTree<FGTrafficRecord, decltype(&getBox), decltype(&equal)> index;
49 SGGeod min;
50 FGAirportRef airport;
51 int getSize(FGTrafficRef aiObject);
52 bool blocking(FGTrafficRef aiObject, FGTrafficRef other);
53public:
54 AirportGroundRadar(SGGeod min, SGGeod max);
57 bool add(FGTrafficRef aiObject);
58 bool move(const SGRectd& newPos, FGTrafficRef aiObject);
59 bool remove(FGTrafficRef aiObject);
60 size_t size() const;
62 bool isBlocked(FGTrafficRef aiObject);
66};
SGSharedPtr< FGTrafficRecord > FGTrafficRef
#define min(X, Y)
SGSharedPtr< FGAirport > FGAirportRef
bool remove(FGTrafficRef aiObject)
bool isBlockedForPushback(FGTrafficRef aiObject)
Check if the aircraft could push back.
bool add(FGTrafficRef aiObject)
bool move(const SGRectd &newPos, FGTrafficRef aiObject)
static SGRect< double > getBox(FGTrafficRef aiObject)
Function implementing calculation of dimension for Quadtree.
static bool equal(FGTrafficRef o, FGTrafficRef o2)
Function implementing equals for Quadtree.
const FGTrafficRef getBlockedBy(FGTrafficRef aiObject)
Returns which AI object is blocking this traffic.
bool isBlocked(FGTrafficRef aiObject)
Returns if this AI object is blocked by any other "known" aka visible to the Radar.
AirportGroundRadar(SGGeod min, SGGeod max)