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>
21 return nameAsString.replace(camelCaseRegex,
QStringLiteral(
"\\1-\\2")).toLower().toLatin1();
39 return rect.topLeft().longitude() >
rect.bottomRight().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;
62 QList<QGeoCoordinate>
path;
64 QDeclarativeCircleMapItemPrivate::calculatePeripheralPoints(
path, mapItem->center(), mapItem->radius(), circleSamples, leftBound);
65 QList<QDoubleVector2D> pathProjected;
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();
150QList<QByteArray> getAllPropertyNamesList(
QObject *
object)
153 QList<QByteArray> propertyNames(
object->dynamicPropertyNames());
155 propertyNames.append(
metaObject->property(
i).name());
157 return propertyNames;
165 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
167 switch (
item->itemType()) {
174 qWarning() <<
"Unsupported QGeoMap item type: " <<
item->itemType();
178 QMapbox::Feature feature = featureFromMapItem(
item);
190 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
204 map->setLayoutProperty(m_layer, m_property, m_value);
209 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
211 switch (
item->itemType()) {
218 changes << QSharedPointer<QMapboxGLStyleChange>(
227 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
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();
270 return QList<QSharedPointer<QMapboxGLStyleChange>>();
276 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
281 changes << QSharedPointer<QMapboxGLStyleChange>(
283 changes << QSharedPointer<QMapboxGLStyleChange>(
285 changes << QSharedPointer<QMapboxGLStyleChange>(
293 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
298 changes << QSharedPointer<QMapboxGLStyleChange>(
300 changes << QSharedPointer<QMapboxGLStyleChange>(
302 changes << QSharedPointer<QMapboxGLStyleChange>(
310 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
315 changes << QSharedPointer<QMapboxGLStyleChange>(
317 changes << QSharedPointer<QMapboxGLStyleChange>(
319 changes << QSharedPointer<QMapboxGLStyleChange>(
327 QList<QSharedPointer<QMapboxGLStyleChange>> changes;
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;
369 return QSharedPointer<QMapboxGLStyleChange>(
layer);
377 map->removeLayer(m_id);
389 map->updateSource(m_id, m_params);
396 source->m_id = feature.id.toString();
400 return QSharedPointer<QMapboxGLStyleChange>(
source);
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)
double latitude
This property holds the latitude in decimal degrees.
QGeoCoordinate bottomLeft
This property holds the bottom left coorindate of this geo rectangle.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
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
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
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()