File indexing completed on 2024-05-05 03:49:51

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 // Copyright 2014      Gábor Péterffy <peterffy95@gmail.com>
0003 //
0004 
0005 #ifndef MARBLE_AZIMUTHALPROJECTIONPRIVATE_H
0006 #define MARBLE_AZIMUTHALPROJECTIONPRIVATE_H
0007 
0008 #include "AbstractProjection_p.h"
0009 
0010 
0011 namespace Marble
0012 {
0013 
0014 // Maximum amount of nodes that are created automatically between actual nodes.
0015 static const int maxTessellationNodes = 200;
0016 
0017 
0018 class AzimuthalProjection;
0019 
0020 class AzimuthalProjectionPrivate : public AbstractProjectionPrivate
0021 {
0022 public:
0023     explicit AzimuthalProjectionPrivate( AzimuthalProjection * parent )
0024         : AbstractProjectionPrivate( parent ),
0025           q_ptr( parent )
0026     {
0027 
0028     }
0029 
0030     ~AzimuthalProjectionPrivate() override {};
0031 
0032     // This method tessellates a line segment in a way that the line segment
0033     // follows great circles. The count parameter specifies the
0034     // number of nodes generated for the polygon. If the
0035     // clampToGround flag is added the polygon contains count + 2
0036     // nodes as the clamped down start and end node get added.
0037 
0038     // In order to ensure proper performance the current algorithm
0039     // determines whether the linestring disappears
0040     // behind the horizon by evaluating the actual node coordinates of the
0041     // linestring.
0042     // However in some cases only a tessellated portion of the linestring
0043     // disappears behind the globe. In this case non-closed linestrings
0044     // can still be cut into separate polygons without problems.
0045     // But for linearrings the horizon detection at this stage happens too
0046     // late already to be taken into account for rendering.
0047     // The allowLatePolygonCut parameter allows to split at least
0048     // non-closed linestrings properly at this point.
0049 
0050     void tessellateLineSegment(  const GeoDataCoordinates &aCoords,
0051                                 qreal ax, qreal ay,
0052                                 const GeoDataCoordinates &bCoords,
0053                                 qreal bx, qreal by,
0054                                 QVector<QPolygonF*> &polygons,
0055                                 const ViewportParams *viewport,
0056                                 TessellationFlags f = TessellationFlags(),
0057                                 bool allowLatePolygonCut = false ) const;
0058 
0059     void processTessellation(   const GeoDataCoordinates &previousCoords,
0060                                const GeoDataCoordinates &currentCoords,
0061                                int count,
0062                                QVector<QPolygonF*> &polygons,
0063                                const ViewportParams *viewport,
0064                                TessellationFlags f = TessellationFlags(),
0065                                bool allowLatePolygonCut = false ) const;
0066 
0067     void crossHorizon( const GeoDataCoordinates & bCoord,
0068                        QVector<QPolygonF*> &polygons,
0069                        const ViewportParams *viewport,
0070                        bool allowLatePolygonCut = false
0071                      ) const;
0072 
0073     virtual bool lineStringToPolygon( const GeoDataLineString &lineString,
0074                               const ViewportParams *viewport,
0075                               QVector<QPolygonF*> &polygons ) const;
0076 
0077     void horizonToPolygon( const ViewportParams *viewport,
0078                            const GeoDataCoordinates & disappearCoords,
0079                            const GeoDataCoordinates & reappearCoords,
0080                            QPolygonF* ) const;
0081 
0082     GeoDataCoordinates findHorizon( const GeoDataCoordinates & previousCoords,
0083                                     const GeoDataCoordinates & currentCoords,
0084                                     const ViewportParams *viewport,
0085                                     TessellationFlags f = TessellationFlags()) const;
0086 
0087     GeoDataCoordinates doFindHorizon(const GeoDataCoordinates & previousCoords,
0088                                      const GeoDataCoordinates & currentCoords,
0089                                      const ViewportParams *viewport,
0090                                      TessellationFlags f,
0091                                      bool currentHide,
0092                                      int recursionCounter) const;
0093 
0094     bool globeHidesPoint( const GeoDataCoordinates &coordinates,
0095                           const ViewportParams *viewport ) const;
0096 
0097     AzimuthalProjection * const q_ptr;
0098 
0099     Q_DECLARE_PUBLIC( AzimuthalProjection )
0100 };
0101 
0102 } // namespace Marble
0103 
0104 #endif