7#include <QtCore/QScopedValueRollback>
11#include <QtGui/private/qtriangulatingstroker_p.h>
12#include <QtPositioning/private/qlocationutils_p.h>
13#include <QtPositioning/private/qdoublevector2d_p.h>
14#include <QtPositioning/private/qwebmercator_p.h>
15#include <QtPositioning/private/qclipperutils_p.h>
16#include <QtPositioning/private/qgeopath_p.h>
17#include <QtLocation/private/qgeomap_p.h>
36 const double s10_x = p1_x - p0_x;
37 const double s10_y = p1_y - p0_y;
38 const double s32_x = p3_x - p2_x;
39 const double s32_y = p3_y - p2_y;
41 const double denom = s10_x * s32_y - s32_x * s10_y;
44 const bool denomPositive = denom > 0;
46 const double s02_x = p0_x - p2_x;
47 const double s02_y = p0_y - p2_y;
48 const double s_numer = s10_x * s02_y - s10_y * s02_x;
49 if ((s_numer < 0.0) == denomPositive)
52 const double t_numer = s32_x * s02_y - s32_y * s02_x;
53 if ((t_numer < 0.0) == denomPositive)
56 if (((s_numer > denom) == denomPositive) || ((t_numer > denom) == denomPositive))
59 *i_t = t_numer / denom;
60 *i_x = p0_x + (*i_t * s10_x);
61 *i_y = p0_y + (*i_t * s10_y);
73 const QList<QDoubleVector2D> &l,
74 const QList<QDoubleVector2D> &poly)
76 QList<QList<QDoubleVector2D> >
res;
77 if (poly.size() < 2 || l.size() < 2)
81 std::vector<std::array<double, 4> > edges;
83 edges.push_back({ { poly.at(i-1).x(), poly.at(i-1).y(), poly.at(i).x(), poly.at(i).y() } });
84 edges.push_back({ { poly.at(poly.size()-1).x(), poly.at(poly.size()-1).y(), poly.at(0).x(), poly.at(0).y() } });
87 QList<QDoubleVector2D> subLine;
88 std::array<double, 4> intersections = { { 0.0, 0.0, 0.0, 0.0 } };
99 if (firstContained && secondContained) {
101 subLine.push_back(l.at(
i));
102 subLine.push_back(l.at(
i+1));
106 for (
unsigned int j = 0;
j < edges.size(); ++
j) {
119 if (previousT >= 0.0) {
121 intersections[2] = intersections[0];
122 intersections[3] = intersections[1];
123 intersections[0] = i_x;
124 intersections[1] = i_y;
126 intersections[2] = i_x;
127 intersections[3] = i_y;
133 intersections[0] = i_x;
134 intersections[1] = i_y;
142 if (!firstContained && !secondContained) {
144 }
else if (firstContained && secondContained) {
148 res.push_back(subLine);
152 if (firstContained <= 0 && secondContained > 0) {
154 subLine.push_back(
QDoubleVector2D(intersections[0], intersections[1]));
155 subLine.push_back(l.at(
i+1));
156 }
else if (firstContained > 0 && secondContained <= 0) {
158 subLine.push_back(l.at(
i));
159 subLine.push_back(
QDoubleVector2D(intersections[0], intersections[1]));
160 res.push_back(subLine);
164 res.push_back(subLine);
170 subLine.push_back(
QDoubleVector2D(intersections[0], intersections[1]));
171 subLine.push_back(
QDoubleVector2D(intersections[2], intersections[3]));
172 res.push_back(subLine);
178 res.push_back(subLine);
305 const QList<QDoubleVector2D> &basePath)
317 QVarLengthArray<QList<QDoubleVector2D>, 3> wrappedPaths;
318 wrappedPaths << QList<QDoubleVector2D>({basePath[0]});
319 wrappedPaths.last().reserve(basePath.size());
320 for (
int i = 1;
i < basePath.size();
i++) {
321 if (basePath[
i].
x() > wrappedPaths.last().last().x() + 0.5)
323 else if (basePath[
i].
x() < wrappedPaths.last().last().x() - 0.5)
326 wrappedPaths.last() << basePath[
i];
334 for (
const auto &
path : wrappedPaths)
336 for (
double xoffset : {-1.0, 1.0}) {
339 wrappedPaths.append(QList<QDoubleVector2D>());
340 QList<QDoubleVector2D> &wP = wrappedPaths.last();
341 wP.reserve(wrappedPaths.first().size());
345 if (wrappedPaths.isEmpty())
349 QList<QList<QDoubleVector2D>> clippedPaths;
350 const QList<QDoubleVector2D> &visibleRegion =
p.visibleGeometryExpanded();
351 for (
const auto &
path : wrappedPaths) {
352 if (visibleRegion.size()) {
356 clippedPaths.append(
path);
359 if (clippedPaths.isEmpty())
363 for (
const auto &
path: clippedPaths)
369 for (
const auto &
path: clippedPaths) {
380 lastAddedPoint = point;
382 if ((point - lastAddedPoint).manhattanLength() > 3 ||
383 i ==
path.size() - 1) {
385 lastAddedPoint = point;
482 path.
translate(-bb.left() + borderWidth * 0.5, -bb.top() + borderWidth * 0.5);
511 for (
int i = 1;
i <
path.elementCount();
i++) {
515 path.elementAt(
i - 1).x,
path.elementAt(
i - 1).y,
517 if (dsqr < 0.25 * lineWidth * lineWidth)
539 this, [
this]() {
m_d->onGeoGeometryChanged(); });
551 m_d->onLinePropertiesChanged();
596 m_d->onGeoGeometryChanged();
610 m_d->onGeoGeometryChanged();
642 m_d->onGeoGeometryUpdated();
662 m_d->onGeoGeometryChanged();
683 m_d->onGeoGeometryChanged();
733 m_d->onGeoGeometryChanged();
755 m_d->onGeoGeometryChanged();
790 if (!newCenter.isValid() || !oldCenter.isValid())
792 double offsetLongi = newCenter.longitude() - oldCenter.longitude();
793 double offsetLati = newCenter.latitude() - oldCenter.latitude();
794 if (offsetLati == 0.0 && offsetLongi == 0.0)
798 m_d->onGeoGeometryChanged();
810 if (
event.mapSize.isEmpty())
813 m_d->afterViewportChanged();
831 return m_d->updateMapItemPaintNode(oldNode,
data);
836 return m_d->contains(point);
static int pointInPolygon(const QDoubleVector2D &point, const QList< QDoubleVector2D > &polygon)
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset)
QGeoMap::ItemType m_itemType
void setShapeTriangulationScale(QQuickShape *shape, qreal maxCoord) const
float zoomLevelOpacity() const
virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
void referenceSurfaceChanged()
QLocation::ReferenceSurface referenceSurface
QDeclarativeGeoMap * quickMap() const
void setPath(const QPainterPath &path)
void widthChanged(qreal width)
QDeclarativeMapLineProperties(QObject *parent=nullptr)
\qmltype MapPolyline \instantiates QDeclarativePolylineMapItem \inqmlmodule QtLocation
void colorChanged(const QColor &color)
void setWidth(qreal width)
void setColor(const QColor &color)
QList< QDoubleVector2D > m_geopathProjected
QDeclarativePolylineMapItemPrivateCPU(QDeclarativePolylineMapItem &poly)
~QDeclarativePolylineMapItemPrivateCPU() override
void updatePolish() override
QGeoMapPolylineGeometry m_geometry
QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) override
QQuickShapePath * m_shapePath
bool contains(const QPointF &point) const override
QDeclarativeGeoMapPainterPath * m_painterPath
QDeclarativePolylineMapItem & m_poly
virtual ~QDeclarativePolylineMapItemPrivate()
QDeclarativeMapLineProperties * line
\qmlpropertygroup Location::MapPolyline::line \qmlproperty int MapPolyline::line.width \qmlproperty c...
QList< QGeoCoordinate > path
Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate)
\qmlmethod void MapPolyline::replaceCoordinate(index, coordinate)
Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate)
\qmlmethod coordinate MapPolyline::containsCoordinate(coordinate)
Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate)
\qmlmethod void MapPolyline::removeCoordinate(coordinate)
virtual void setPath(const QList< QGeoCoordinate > &value)
QDeclarativeMapLineProperties m_line
QSGNode * updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *) override
bool contains(const QPointF &point) const override
\qmlmethod bool QtQuick::Item::contains(point point)
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
\qmlmethod void MapPolyline::addCoordinate(coordinate)
void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override
Q_INVOKABLE int pathLength() const
\qmlmethod int MapPolyline::pathLength()
Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate)
\qmlmethod void MapPolyline::insertCoordinate(index, coordinate)
void updateAfterLinePropertiesChanged()
const QGeoShape & geoShape() const override
void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map) override
QDeclarativePolylineMapItem(QQuickItem *parent=nullptr)
void setGeoShape(const QGeoShape &shape) override
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void updatePolish() override
~QDeclarativePolylineMapItem()
void setPathFromGeoList(const QList< QGeoCoordinate > &path)
Q_INVOKABLE QGeoCoordinate coordinateAt(int index) const
\qmlmethod coordinate MapPolyline::coordinateAt(index)
std::unique_ptr< QDeclarativePolylineMapItemPrivate > m_d
Q_DECL_CONSTEXPR QPointF toPointF() const
Q_DECL_CONSTEXPR double x() const
Q_DECL_CONSTEXPR double y() const
bool isValid
This property holds the validity of this geo coordinate.
QGeoCoordinate srcOrigin_
QRectF sourceBoundingBox() const
const QGeoCoordinate & origin() const
bool isScreenDirty() const
const QGeoProjection & geoProjection() const
Q_INVOKABLE QGeoCoordinate coordinateAt(qsizetype index) const
Returns the coordinate at index .
Q_INVOKABLE void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
Inserts coordinate at the specified index.
void setPath(const QList< QGeoCoordinate > &path)
Sets all the elements of the path.
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude)
Translates this geo path by degreesLatitude northwards and degreesLongitude eastwards.
Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate)
Removes the last occurrence of coordinate from the path.
Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate) const
Returns true if the path contains coordinate as one of the elements.
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
Appends coordinate to the path.
QVariantList path
This property holds the list of coordinates for the geo path.
Q_INVOKABLE void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
Replaces the path element at the specified index with coordinate.
virtual ProjectionType projectionType() const =0
virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport=true) const =0
bool isValid
This property holds the validity of the geo shape.
qsizetype size() const noexcept
qsizetype length() const noexcept
void reserve(qsizetype size)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
void translate(qreal dx, qreal dy)
Translates all elements in the path by ({dx}, {dy}).
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
\inmodule QtCore\reentrant
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setSize(const QSizeF &size)
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
QQmlListProperty< QQuickPathElement > pathElements
\qmlproperty list<PathElement> QtQuick::Path::pathElements This property holds the objects composing ...
void setStrokeColor(const QColor &color)
void setStrokeWidth(qreal w)
void setFillColor(const QColor &color)
void setContainsMode(ContainsMode containsMode)
FINALQQmlListProperty< QObject > data
\qmlproperty list<Object> QtQuick.Shapes::Shape::data
\inmodule QtCore\reentrant
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
QMap< QString, QString > map
[6]
QList< QGeoCoordinate > greaterCirclePath(const QList< QGeoCoordinate > &cornerPoints, greaterCirclePathForm form, int N)
QRectF boundingRectangleFromList(const QList< QDoubleVector2D > &list)
double distanceSqrPointLine(double p0_x, double p0_y, double p1_x, double p1_y, double p2_x, double p2_y)
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE bool get_line_intersection(const double p0_x, const double p0_y, const double p1_x, const double p1_y, const double p2_x, const double p2_y, const double p3_x, const double p3_y, double *i_x, double *i_y, double *i_t)
static QList< QList< QDoubleVector2D > > clipLine(const QList< QDoubleVector2D > &l, const QList< QDoubleVector2D > &poly)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLchar *const * path
static bool clipLine(QLineF *line, const QRect &rect)
void updateSourcePoints(const QGeoMap &map, const QList< QDoubleVector2D > &basePath)
QPainterPath srcPath() const