15#ifndef WSFROUTENETWORK_HPP
16#define WSFROUTENETWORK_HPP
18#include "wsf_export.h"
26#include "UtLineSegment.hpp"
29#include "UtSpatialTree.hpp"
30#include "UtSphericalEarth.hpp"
74 static std::unique_ptr<UtScriptClass>
CreateScriptClass(
const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
83 bool Add(std::unique_ptr<WsfRoute> aRoutePtr);
100 bool aLeaveRouteNetwork =
true);
106 unsigned int GetRouteCount()
const {
return static_cast<unsigned int>(mRoutes.size()); }
109 WsfRoute& operator[](
unsigned int aIndex);
112 std::vector<const WsfRoute*> GetRoutes()
const;
114 void Append(
const RoutePoint& aPoint,
WsfRoute& aRoute);
115 void AppendSubroute(
const RoutePoint& aPoint1,
const RoutePoint& aPoint2,
WsfRoute& aRoute);
116 int GetAdjacentNodeIndices(
const RoutePoint& aPoint,
int* aIndices);
125 return aLhs.first < aRhs.first;
182 using RouteGraph = UtGraphT<RouteNode, RouteEdge, false, double>;
215 const WsfWaypoint& n1 = (*mNetworkPtr)[wa1.first][wa1.second];
216 const WsfWaypoint& n2 = (*mNetworkPtr)[wa2.first][wa2.second];
222 UtSphericalEarth::GreatCircleHeadingAndDistance(n1.
GetLat(), n1.
GetLon(), n2.
GetLat(), n2.
GetLon(), heading, distance);
237 class SegmentDatum :
public UtQuadDatum
240 SegmentDatum(
const UtLineSegment& aSegment);
241 ~SegmentDatum()
override;
243 bool IsPoint()
const override {
return false; }
245 bool IsWhollyContainedIn(
const UtBoundingBox& aBox)
const override;
247 bool IsPartiallyContainedIn(
const UtBoundingBox& aBox)
const override;
249 const UtBoundingBoxI<2> GetBoundingBox()
const {
return mBoundingBox; }
251 unsigned int mRouteIndex;
253 UtLineSegment mSegment;
254 UtBoundingBoxI<2> mBoundingBox;
257 using Path = std::vector<RouteNode>;
262 bool BuildRoute(
const Path& aShortestPath,
int aStartIndex,
int aStopIndex, WsfRoute& aPath);
264 void AppendSubroute(
const WsfRouteNetwork::RouteNode& aStartingWaypoint,
265 const WsfRouteNetwork::RouteNode& aEndingWaypoint,
267 void AppendSubroute(
const WsfRoute& aSourceRoute,
int aStartWptIndex,
int aStopWptIndex, WsfRoute& aAppendRoute);
269 void InitializeShortestPath();
273 std::vector<ut::CloneablePtr<WsfRoute>> mRoutes;
274 std::vector<WsfWaypoint> mNwaypoint;
278 RouteCostFunc mCostFunc;
281 bool mShortestPathInitialized;
285 UtQuadTree* mTreePtr;
290 double mCenterLLA[3];
293 double mTransECEF[3][3];
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
virtual WsfObject * Clone() const =0
virtual bool ProcessInput(UtInput &aInput)
Definition WsfObject.cpp:140
Definition WsfRouteNetworkTypes.hpp:22
A cost function used by the shortest_path algorithm provided by the RouteGraph class.
Definition WsfRouteNetwork.hpp:188
double operator()(const RouteEdge &aEdge, const RouteNode &, const RouteNode &) const override
Returns the precomputed cost along the edge.
Definition WsfRouteNetwork.hpp:200
double operator()(const RouteNode &aNode1, const RouteNode &aNode2) const override
Computes a lower-bound cost to move from aNode1 to aNode2 (a straight (curved) line).
Definition WsfRouteNetwork.hpp:206
RouteCostFunc(WsfRouteNetwork *aNetworkPtr)
Definition WsfRouteNetwork.hpp:194
WsfRouteNetwork * mNetworkPtr
Definition WsfRouteNetwork.hpp:228
RouteCostFunc()
Definition WsfRouteNetwork.hpp:190
Specifies a location along a route.
Definition WsfRouteNetwork.hpp:51
WaypointAddr mWaypointAddr
Waypoint and route index.
Definition WsfRouteNetwork.hpp:64
RoutePoint(const WaypointAddr &aAddr, double aDistanceAlongSegment=0)
Definition WsfRouteNetwork.hpp:54
int RouteIndex() const
Definition WsfRouteNetwork.hpp:60
double mDistanceAlongSegment
Distance from the waypoint addressed toward the next waypoint.
Definition WsfRouteNetwork.hpp:67
int WaypointIndex() const
Definition WsfRouteNetwork.hpp:61
UtGraphT< RouteNode, RouteEdge, false, double > RouteGraph
Definition WsfRouteNetwork.hpp:182
std::pair< int, int > WaypointAddr
A waypoint address. Minimal information required to look up a waypoint.
Definition WsfRouteNetwork.hpp:46
bool Initialize()
Definition WsfRouteNetwork.cpp:138
bool GeneratePathOffRouteToRoute(double aStartLat, double aStartLon, double aEndLat, double aEndLon, WsfRoute &aPath)
Definition WsfRouteNetwork.cpp:436
WsfRouteNetwork & operator=(const WsfRouteNetwork &)=delete
unsigned int GetRouteCount() const
Definition WsfRouteNetwork.hpp:106
std::vector< WaypointAddr > WaypointAddrList
Definition WsfRouteNetwork.hpp:47
bool FindClosestWaypoint(double aLat, double aLon, WsfWaypoint &aWpt, double &aDistance)
Returns the closest waypoint relative to the provided latitude and longitude.
Definition WsfRouteNetwork.cpp:651
WsfRouteNetwork()
Definition WsfRouteNetwork.cpp:47
bool GeneratePathBetweenClosestSegments(double aStartLat, double aStartLon, double aEndLat, double aEndLon, WsfRoute &aPath, bool aLeaveRouteNetwork=true)
Definition WsfRouteNetwork.cpp:539
const RouteGraph & GetGraph() const
Definition WsfRouteNetwork.hpp:184
bool FindClosestSegment(double aLat, double aLon, RoutePoint &aProjectedPoint, double &aDistanceToSegment)
Definition WsfRouteNetwork.cpp:582
bool AppendShortestPathOnNetwork(RoutePoint aPoint1, RoutePoint aPoint2, WsfRoute &aPath)
Definition WsfRouteNetwork.cpp:294
WsfStringId cSTOP_NODE_ID
Definition WsfRouteNetwork.hpp:43
bool GeneratePathBetweenClosestWaypoints(double aStartLat, double aStartLon, double aEndLat, double aEndLon, WsfRoute &aPath)
Definition WsfRouteNetwork.cpp:507
static bool CompareWaypointAddrRoute(const WaypointAddr &aLhs, const WaypointAddr &aRhs)
Definition WsfRouteNetwork.hpp:123
bool GenerateShortestPathBetweenWaypoints(const WsfWaypoint &aFromWaypoint, const WsfWaypoint &aToWaypoint, WsfRoute &aPath)
Definition WsfRouteNetwork.cpp:414
static std::unique_ptr< UtScriptClass > CreateScriptClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfRouteNetwork.cpp:1285
WsfStringId cSTART_NODE_ID
Definition WsfRouteNetwork.hpp:42
void BuildQuadtree()
Definition WsfRouteNetwork.cpp:981
WSF_DEPRECATED bool Add(WsfRoute *aRoute)
Definition WsfRouteNetwork.cpp:205
A collection of WsfWaypoint objects that represent a path to be followed.
Definition WsfRoute.hpp:40
Definition WsfWaypoint.hpp:57
double GetLat() const
Definition WsfWaypoint.hpp:129
double GetLon() const
Definition WsfWaypoint.hpp:132
Represents an edge key for use with the RouteGraph class.
Definition WsfRouteNetwork.hpp:157
bool operator==(const RouteEdge &aRhs) const
Definition WsfRouteNetwork.hpp:172
RouteEdge()
Definition WsfRouteNetwork.hpp:158
double mDistance
Definition WsfRouteNetwork.hpp:179
RouteNode mSrcNode
Definition WsfRouteNetwork.hpp:177
RouteNode mDstNode
Definition WsfRouteNetwork.hpp:178
RouteEdge(const RouteNode &aSrcNode, const RouteNode &aDstNode)
Definition WsfRouteNetwork.hpp:165
Represents a node key for use with the RouteGraph class.
Definition WsfRouteNetwork.hpp:130
bool operator!=(const RouteNode &aRhs) const
Definition WsfRouteNetwork.hpp:147
bool operator==(const RouteNode &aRhs) const
Definition WsfRouteNetwork.hpp:145
RouteNode(WsfStringId aId, WaypointAddrList *aWptListPtr=nullptr)
Definition WsfRouteNetwork.hpp:138
bool operator<(const RouteNode &aRhs) const
Definition WsfRouteNetwork.hpp:149
WaypointAddrList * mWaypoints
Definition WsfRouteNetwork.hpp:152
RouteNode()
Definition WsfRouteNetwork.hpp:131
bool mSegmentNode
Definition WsfRouteNetwork.hpp:150
WsfStringId mId
Definition WsfRouteNetwork.hpp:151