File indexing completed on 2024-04-28 03:49:28
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_ROUTESEGMENT_H 0007 #define MARBLE_ROUTESEGMENT_H 0008 0009 #include "Maneuver.h" 0010 #include "GeoDataLineString.h" 0011 #include "GeoDataLatLonBox.h" 0012 0013 #include <QtGlobal> 0014 0015 namespace Marble 0016 { 0017 0018 class MARBLE_EXPORT RouteSegment 0019 { 0020 public: 0021 RouteSegment(); 0022 0023 bool isValid() const; 0024 0025 qreal distance() const; 0026 0027 const Maneuver & maneuver() const; 0028 0029 void setManeuver( const Maneuver &maneuver ); 0030 0031 const GeoDataLineString & path() const; 0032 0033 void setPath( const GeoDataLineString &path ); 0034 0035 int travelTime() const; 0036 0037 void setTravelTime( int seconds ); 0038 0039 GeoDataLatLonBox bounds() const; 0040 0041 const RouteSegment & nextRouteSegment() const; 0042 0043 void setNextRouteSegment( const RouteSegment* segment ); 0044 0045 qreal distanceTo( const GeoDataCoordinates &point, GeoDataCoordinates &closest, GeoDataCoordinates &interpolated ) const; 0046 0047 qreal minimalDistanceTo( const GeoDataCoordinates &point ) const; 0048 0049 qreal projectedDirection(const GeoDataCoordinates &point) const; 0050 0051 bool operator==( const RouteSegment &other ) const; 0052 0053 bool operator!=( const RouteSegment &other ) const; 0054 0055 private: 0056 static qreal distancePointToLine(const GeoDataCoordinates &p, const GeoDataCoordinates &a, const GeoDataCoordinates &b); 0057 0058 static GeoDataCoordinates projected(const GeoDataCoordinates &p, const GeoDataCoordinates &a, const GeoDataCoordinates &b); 0059 0060 bool m_valid; 0061 0062 qreal m_distance; 0063 0064 Maneuver m_maneuver; 0065 0066 GeoDataLineString m_path; 0067 0068 int m_travelTime; 0069 0070 GeoDataLatLonBox m_bounds; 0071 0072 const RouteSegment *m_nextRouteSegment; 0073 }; 0074 0075 0076 } 0077 0078 #endif