24 "This can cause errors
while querying holes from QML";
110 steps =
qMax(steps, 3);
111 qreal centerLon = center.longitude();
114 qreal cosLatRad = std::cos(latRad);
115 qreal sinLatRad = std::sin(latRad);
117 qreal cosRatio = std::cos(ratio);
118 qreal sinRatio = std::sin(ratio);
119 qreal sinLatRad_x_cosRatio = sinLatRad * cosRatio;
120 qreal cosLatRad_x_sinRatio = cosLatRad * sinRatio;
121 for (
int i = 0;
i < steps; ++
i) {
123 qreal resultLatRad = std::asin(sinLatRad_x_cosRatio
124 + cosLatRad_x_sinRatio * std::cos(azimuthRad));
125 qreal resultLonRad = lonRad + std::atan2(std::sin(azimuthRad) * cosLatRad_x_sinRatio,
126 cosRatio - sinLatRad * std::sin(resultLatRad));
151 <<
rect.bottomRight() <<
rect.bottomLeft();
180 return d->setPath(
path);
203 d->translate(degreesLatitude, degreesLongitude);
218 result.translate(degreesLatitude, degreesLongitude);
229 return d->length(indexFrom, indexTo);
252 d->addCoordinate(coordinate);
263 d->insertCoordinate(
index, coordinate);
272 d->replaceCoordinate(
index, coordinate);
281 return d->coordinateAt(
index);
290 return d->containsCoordinate(coordinate);
299 d->removeCoordinate(coordinate);
308 d->removeCoordinate(
index);
339 for (
const QVariant &vertex : qvlHolePath) {
373 return holeCoordinates;
384 return d->holePath(
index);
395 return d->removeHole(
index);
450 double degreesLatitude,
451 double degreesLongitude,
455 if (degreesLatitude > 0.0)
456 degreesLatitude =
qMin(degreesLatitude, 90.0 - m_maxLati);
458 degreesLatitude =
qMax(degreesLatitude, -90.0 - m_minLati);
460 p.setLatitude(
p.latitude() + degreesLatitude);
463 if (!m_holesList.isEmpty()){
466 holeVertex.setLatitude(holeVertex.latitude() + degreesLatitude);
471 m_bbox.
translate(degreesLatitude, degreesLongitude);
478 double m_minX, m_maxX, m_minLati, m_maxLati;
488 if (!QGeoShapePrivate::operator==(
other))
508 if (!holeVertex.isValid())
552 if (holePolygon.
contains(coordinate))
573 crd.
setX(crd.
x() + 1.0);
574 preservedPath << crd;
666#include "moc_qgeopolygon_p.cpp"
667#include "moc_qgeopolygon.cpp"
void setPolygon(const QList< QDoubleVector2D > &polygon)
static int pointInPolygon(const QDoubleVector2D &point, const QList< QDoubleVector2D > &polygon)
Q_DECL_CONSTEXPR double x() const
QGeoCoordinate center
This property holds the center coordinate for the geo circle.
qreal radius
This property holds the circle radius in meters.
bool isValid
This property holds the validity of this geo coordinate.
QList< QGeoCoordinate > m_path
virtual void setPath(const QList< QGeoCoordinate > &path)
virtual void computeBoundingBox()
virtual const QList< QGeoCoordinate > & path() const
double m_leftBoundWrapped
virtual void addCoordinate(const QGeoCoordinate &coordinate) override
~QGeoPolygonPrivateEager()
QList< double > m_deltaXs
QGeoPolygonPrivateEager()
virtual void markDirty() override
virtual void translate(double degreesLatitude, double degreesLongitude) override
virtual QGeoShapePrivate * clone() const override
virtual void computeBoundingBox() override
QClipperUtils m_clipperWrapper
virtual void removeHole(qsizetype index)
qsizetype holesCount() const
virtual bool contains(const QGeoCoordinate &coordinate) const override
QList< QList< QGeoCoordinate > > m_holesList
bool polygonContains(const QGeoCoordinate &coordinate) const
virtual bool isValid() const override
const QList< QGeoCoordinate > holePath(qsizetype index) const
virtual void addHole(const QList< QGeoCoordinate > &holePath)
virtual void updateClipperPath()
virtual void markDirty() override
size_t hash(size_t seed) const override
virtual void translate(double degreesLatitude, double degreesLongitude) override
virtual bool operator==(const QGeoShapePrivate &other) const override
virtual QGeoShapePrivate * clone() const override
Q_INVOKABLE qsizetype holesCount() const
Returns the number of holes.
~QGeoPolygon()
Destroys this polygon.
Q_INVOKABLE void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
Replaces the path element at the specified index with coordinate.
const QList< QGeoCoordinate > holePath(qsizetype index) const
Returns a QList<QGeoCoordinate> which represents the hole at index.
void setPerimeter(const QList< QGeoCoordinate > &path)
Sets the perimeter of the polygon based on a list of coordinates path.
Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate)
Removes the last occurrence of coordinate from the polygon.
QGeoPolygon & operator=(const QGeoPolygon &other)
Assigns other to this geo polygon and returns a reference to this geo polygon.
Q_INVOKABLE void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
Inserts coordinate at the specified index.
Q_INVOKABLE void removeHole(qsizetype index)
Removes element at position index from the list of holes.
Q_INVOKABLE QGeoPolygon translated(double degreesLatitude, double degreesLongitude) const
Returns a copy of this geo polygon translated by degreesLatitude northwards and degreesLongitude east...
Q_INVOKABLE double length(qsizetype indexFrom=0, qsizetype indexTo=-1) const
Returns the length of the polygon's perimeter, in meters, from the element indexFrom to the element i...
Q_INVOKABLE QString toString() const
Returns the geo polygon properties as a string.
Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate) const
Returns true if the polygon's perimeter contains coordinate as one of the elements.
Q_INVOKABLE const QVariantList hole(qsizetype index) const
Returns a QVariant containing a QList<QGeoCoordinate> which represents the hole at index.
Q_INVOKABLE QGeoCoordinate coordinateAt(qsizetype index) const
Returns the coordinate at index .
QGeoPolygon()
Constructs a new, empty geo polygon.
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude)
Translates this geo polygon by degreesLatitude northwards and degreesLongitude eastwards.
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
Appends coordinate to the polygon.
QList< QGeoCoordinate > perimeter
Q_INVOKABLE void addHole(const QVariant &holePath)
Sets the holePath for a hole inside the polygon.
Q_INVOKABLE qsizetype size() const
Returns the number of elements in the polygon.
QGeoCoordinate topLeft
This property holds the top left coordinate of this geo rectangle.
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude)
Translates this geo rectangle by degreesLatitude northwards and degreesLongitude eastwards.
QGeoShape & operator=(const QGeoShape &other)
Assigns other to this geo shape and returns a reference to this geo shape.
QSharedDataPointer< QGeoShapePrivate > d_ptr
ShapeType type
This property holds the type of this geo shape.
Q_INVOKABLE bool contains(const QGeoCoordinate &coordinate) const
Returns whether the coordinate coordinate is contained within this geo shape.
qsizetype size() const noexcept
void removeAt(qsizetype i)
QList< T > toList() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
const_iterator cend() const noexcept
void append(parameter_type t)
const_iterator cbegin() const noexcept
static double radians(double degrees)
static double degrees(double radians)
static double earthMeanRadius()
static double wrapLong(double lng)
const T * constData() const noexcept
Returns a const pointer to the shared data object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord)
while(i.hasNext()) QString s
Combined button and popup list for selecting options.
static void updateBBox(const QList< QGeoCoordinate > &m_path, QList< double > &m_deltaXs, double &m_minX, double &m_maxX, double &m_minLati, double &m_maxLati, QGeoRectangle &m_bbox)
static QT_BEGIN_NAMESPACE void computeBBox(const QList< QGeoCoordinate > &m_path, QList< double > &m_deltaXs, double &m_minX, double &m_maxX, double &m_minLati, double &m_maxLati, QGeoRectangle &m_bbox)
static void calculatePeripheralPoints(QList< QGeoCoordinate > &path, const QGeoCircle &circle, int steps)
static void translatePoly(QList< QGeoCoordinate > &m_path, QList< QList< QGeoCoordinate > > &m_holesList, QGeoRectangle &m_bbox, double degreesLatitude, double degreesLongitude, double m_maxLati, double m_minLati)
constexpr auto kTooManyElements
constexpr auto kTooManyHoles
QT_BEGIN_NAMESPACE constexpr int kMaxInt
size_t qHashRange(InputIterator first, InputIterator last, size_t seed=0) noexcept(noexcept(qHash(*first)))
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLubyte GLsizei GLenum const void * coords
GLenum GLsizei const void * pathString
GLsizei GLsizei GLfloat distance
GLsizei const GLchar *const * path
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define QStringLiteral(str)
static const QTextHtmlElement elements[Html_NumElements]
\inmodule QtCore \reentrant