File indexing completed on 2024-05-12 03:50:13

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Torsten Rahn <tackat@kde.org>
0004 //
0005 
0006 
0007 #ifndef MARBLE_GEODATALINEARRING_H
0008 #define MARBLE_GEODATALINEARRING_H
0009 
0010 
0011 #include "geodata_export.h"
0012 #include "GeoDataLineString.h"
0013 
0014 
0015 namespace Marble
0016 {
0017 
0018 class GeoDataLinearRingPrivate;
0019 
0020 /*!
0021     \class GeoDataLinearRing
0022     \brief A LinearRing that allows to store a closed, contiguous set of line segments.
0023 
0024     GeoDataLinearRing is a tool class that implements the LinearRing tag/class
0025     of the Open Geospatial Consortium standard KML 2.2.
0026 
0027     Unlike suggested in the KML spec GeoDataLinearRing extends GeoDataLineString
0028     to store a closed LineString (the KML specification suggests to inherit from
0029     the Geometry class directly).
0030 
0031     In the QPainter API LinearRings are also referred to as "polygons".
0032     As such they are similar to QPolygons.
0033 
0034     Whenever a LinearRing is painted GeoDataLineStyle should be used to assign a
0035     color and line width.
0036 
0037     A GeoDataLinearRing consists of several (geodetic) nodes which are each
0038     connected through line segments. The nodes are stored as GeoDataCoordinates
0039     objects.
0040 
0041     The API which provides access to the nodes is similar to the API of
0042     QVector.
0043 
0044     GeoDataLinearRing allows LinearRings to be tessellated in order to make them
0045     follow the terrain and the curvature of the earth. The tessellation options
0046     allow for different ways of visualization:
0047 
0048     \li Not tessellated: A LinearRing that connects each two nodes directly and
0049         straight in screen coordinate space.
0050     \li A tessellated line: Each line segment is bent so that the LinearRing
0051         follows the curvature of the earth and its terrain. A tessellated
0052         line segment connects two nodes at the shortest possible distance
0053         ("along great circles").
0054     \li A tessellated line that follows latitude circles whenever possible:
0055         In this case Latitude circles are followed as soon as two subsequent
0056         nodes have exactly the same amount of latitude. In all other places the
0057         line segments follow great circles.
0058 
0059     Some convenience methods have been added that allow to calculate the
0060     geodesic bounding box or the length of a LinearRing.
0061 */
0062 class GEODATA_EXPORT GeoDataLinearRing : public GeoDataLineString
0063 {
0064 
0065  public:
0066 /*!
0067     \brief Creates a new LinearRing.
0068 */
0069     explicit GeoDataLinearRing( TessellationFlags f = NoTessellation);
0070 
0071 
0072 /*!
0073     \brief Creates a LinearRing from an existing geometry object.
0074 */
0075     explicit GeoDataLinearRing(const GeoDataGeometry &other);
0076 
0077     
0078 /*!
0079     \brief Destroys a LinearRing.
0080 */
0081     ~GeoDataLinearRing() override;
0082 
0083     const char *nodeType() const override;
0084 
0085     EnumGeometryId geometryId() const override;
0086 
0087     GeoDataGeometry *copy() const override;
0088 
0089 
0090 /*!
0091     \brief Returns true/false depending on whether this and other are/are not equal.
0092 */
0093 
0094     bool operator==( const GeoDataLinearRing &other ) const;
0095     bool operator!=( const GeoDataLinearRing &other ) const;
0096 
0097 
0098 /*!
0099     \brief Returns whether a LinearRing is a closed polygon.
0100 
0101     \return <code>true</code> for a LinearRing.
0102 */
0103     bool isClosed() const override;
0104 
0105     
0106 /*!
0107     \brief Returns the length of the LinearRing across a sphere.
0108 
0109     As a parameter the \a planetRadius needs to be passed.
0110 
0111     \return The return value is the length of the LinearRing.
0112     The unit used for the resulting length matches the unit of the planet
0113     radius.
0114 
0115     This method can be used as an approximation for the circumference of a
0116     LinearRing.
0117 */
0118     qreal length( qreal planetRadius, int offset = 0 ) const override;
0119 
0120 /*!
0121     \brief Returns whether the given coordinates lie within the polygon.
0122 
0123     \return <code>true</code> if the coordinates lie within the polygon, false otherwise.
0124 */
0125     virtual bool contains( const GeoDataCoordinates &coordinates ) const;
0126 
0127 /*!
0128  * \brief Returns whether the orientaion of ring is coloskwise or not
0129  * \return Return value is true if ring is clockwise orientated
0130  */
0131     virtual bool isClockwise() const;
0132 };
0133 
0134 }
0135 
0136 #endif