6#include <QtCore/QDebug>
7#include <QtCore/QMetaProperty>
8#include <QtCore/QRegularExpression>
9#include <QtCore/QStringList>
10#include <QtPositioning/QGeoPath>
11#include <QtPositioning/QGeoPolygon>
12#include <QtQml/QJSValue>
13#include <QtLocation/private/qdeclarativecirclemapitem_p_p.h>
39 return rect.topLeft().longitude() >
rect.bottomRight().longitude();
45 QMapbox::Coordinate bottomLeft {
rect->bottomLeft().latitude(),
rect->bottomLeft().longitude() };
46 QMapbox::Coordinate topLeft {
rect->topLeft().latitude(),
rect->topLeft().longitude() };
47 QMapbox::Coordinate bottomRight {
rect->bottomRight().latitude(),
rect->bottomRight().longitude() };
48 QMapbox::Coordinate topRight {
rect->topRight().latitude(),
rect->topRight().longitude() };
49 if (geoRectangleCrossesDateLine(*
rect)) {
50 bottomRight.second += 360.0;
51 topRight.second += 360.0;
53 QMapbox::CoordinatesCollections geometry { { { bottomLeft, bottomRight, topRight, topLeft, bottomLeft } } };
55 return QMapbox::Feature(QMapbox::Feature::PolygonType, geometry, {}, getId(mapItem));
60 static const int circleSamples = 128;
64 QDeclarativeCircleMapItemPrivate::calculatePeripheralPoints(
path, mapItem->
center(), mapItem->
radius(), circleSamples, leftBound);
67 pathProjected <<
p.geoToMapProjection(
c);
69 QDeclarativeCircleMapItemPrivateCPU::preserveCircleGeometry(pathProjected, mapItem->
center(), mapItem->
radius(),
p);
72 path <<
p.mapProjectionToGeo(
c);
75 QMapbox::Coordinates coordinates;
77 coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() };
79 coordinates.append(coordinates.first());
80 QMapbox::CoordinatesCollections geometry { { coordinates } };
81 return QMapbox::Feature(QMapbox::Feature::PolygonType, geometry, {}, getId(mapItem));
84static QMapbox::Coordinates qgeocoordinate2mapboxcoordinate(
const QList<QGeoCoordinate> &crds,
const bool crossesDateline,
bool closed =
false)
86 QMapbox::Coordinates coordinates;
88 if (!coordinates.empty() && crossesDateline &&
qAbs(coordinate.longitude() - coordinates.last().second) > 180.0) {
89 coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() + (coordinate.longitude() >= 0 ? -360.0 : 360.0) };
91 coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() };
94 if (closed && !coordinates.empty() && coordinates.last() != coordinates.first())
95 coordinates.append(coordinates.first());
102 const bool crossesDateline = geoRectangleCrossesDateLine(
polygon->boundingGeoRectangle());
103 QMapbox::CoordinatesCollections geometry;
104 QMapbox::CoordinatesCollection poly;
105 QMapbox::Coordinates coordinates = qgeocoordinate2mapboxcoordinate(
polygon->perimeter(), crossesDateline,
true);
106 poly.push_back(coordinates);
107 for (
int i = 0;
i <
polygon->holesCount(); ++
i) {
108 coordinates = qgeocoordinate2mapboxcoordinate(
polygon->holePath(
i), crossesDateline,
true);
109 poly.push_back(coordinates);
112 geometry.push_back(poly);
113 return QMapbox::Feature(QMapbox::Feature::PolygonType, geometry, {}, getId(mapItem));
119 QMapbox::Coordinates coordinates;
120 const bool crossesDateline = geoRectangleCrossesDateLine(
path->boundingGeoRectangle());
122 if (!coordinates.empty() && crossesDateline &&
qAbs(coordinate.longitude() - coordinates.last().second) > 180.0) {
123 coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() + (coordinate.longitude() >= 0 ? -360.0 : 360.0) };
125 coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() };
128 QMapbox::CoordinatesCollections geometry { { coordinates } };
130 return QMapbox::Feature(QMapbox::Feature::LineStringType, geometry, {}, getId(mapItem));
135 switch (
item->itemType()) {
145 qWarning() <<
"Unsupported QGeoMap item type: " <<
item->itemType();
146 return QMapbox::Feature();
155 propertyNames.append(
metaObject->property(
i).name());
157 return propertyNames;
167 switch (
item->itemType()) {
174 qWarning() <<
"Unsupported QGeoMap item type: " <<
item->itemType();
178 QMapbox::Feature feature = featureFromMapItem(
item);
204 map->setLayoutProperty(m_layer, m_property, m_value);
211 switch (
item->itemType()) {
218 changes << QSharedPointer<QMapboxGLStyleChange>(
232 changes << QSharedPointer<QMapboxGLStyleChange>(
234 changes << QSharedPointer<QMapboxGLStyleChange>(
254 map->setPaintProperty(m_layer, m_property, m_value);
259 switch (
item->itemType()) {
269 qWarning() <<
"Unsupported QGeoMap item type: " <<
item->itemType();
281 changes << QSharedPointer<QMapboxGLStyleChange>(
283 changes << QSharedPointer<QMapboxGLStyleChange>(
285 changes << QSharedPointer<QMapboxGLStyleChange>(
298 changes << QSharedPointer<QMapboxGLStyleChange>(
300 changes << QSharedPointer<QMapboxGLStyleChange>(
302 changes << QSharedPointer<QMapboxGLStyleChange>(
315 changes << QSharedPointer<QMapboxGLStyleChange>(
317 changes << QSharedPointer<QMapboxGLStyleChange>(
319 changes << QSharedPointer<QMapboxGLStyleChange>(
332 changes << QSharedPointer<QMapboxGLStyleChange>(
334 changes << QSharedPointer<QMapboxGLStyleChange>(
336 changes << QSharedPointer<QMapboxGLStyleChange>(
346 map->addLayer(m_params, m_before);
355 switch (feature.type) {
356 case QMapbox::Feature::PointType:
359 case QMapbox::Feature::LineStringType:
362 case QMapbox::Feature::PolygonType:
367 layer->m_before = before;
377 map->removeLayer(m_id);
389 map->updateSource(m_id, m_params);
396 source->m_id = feature.id.toString();
413 map->removeSource(m_id);
425 map->setFilter(m_layer, m_filter);
432 map->addImage(m_name, m_sprite);
static int crossEarthPole(const QGeoCoordinate ¢er, qreal distance)
const QGeoShape & geoShape() const override
const QGeoShape & geoShape() const override
const QGeoShape & geoShape() const override
const QGeoProjection & geoProjection() const
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
void reserve(qsizetype size)
void apply(QMapboxGL *map) override
static QSharedPointer< QMapboxGLStyleChange > fromFeature(const QMapbox::Feature &feature, const QString &before)
void apply(QMapboxGL *map) override
static QSharedPointer< QMapboxGLStyleChange > fromMapItem(QDeclarativeGeoMapItemBase *)
static QSharedPointer< QMapboxGLStyleChange > fromFeature(const QMapbox::Feature &feature)
void apply(QMapboxGL *map) override
static QList< QSharedPointer< QMapboxGLStyleChange > > addMapItem(QDeclarativeGeoMapItemBase *, const QString &before)
static QList< QSharedPointer< QMapboxGLStyleChange > > removeMapItem(QDeclarativeGeoMapItemBase *)
QMapboxGLStyleRemoveLayer(const QString &id)
void apply(QMapboxGL *map) override
QMapboxGLStyleRemoveSource(const QString &id)
void apply(QMapboxGL *map) override
void apply(QMapboxGL *map) override
void apply(QMapboxGL *map) override
static QList< QSharedPointer< QMapboxGLStyleChange > > fromMapItem(QDeclarativeGeoMapItemBase *)
static QList< QSharedPointer< QMapboxGLStyleChange > > fromMapItem(QDeclarativeGeoMapItemBase *)
void apply(QMapboxGL *map) override
QString objectName
the name of this object
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toLower() const &
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QMap< QString, QString > map
[6]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr T qAbs(const T &t)
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
#define QStringLiteral(str)
unsigned long long quint64
obj metaObject() -> className()