openpilot v0.9.6 release
date: 2024-02-21T23:02:42 master commit: 0b4d08fab8e35a264bc7383e878538f8083c33e5
This commit is contained in:
241
third_party/maplibre-native-qt/include/conversion_p.hpp
vendored
Normal file
241
third_party/maplibre-native-qt/include/conversion_p.hpp
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2018 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "geojson_p.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
#include <mbgl/style/conversion/geojson.hpp>
|
||||
#include <mbgl/style/conversion_impl.hpp>
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace mbgl::style::conversion {
|
||||
|
||||
std::string convertColor(const QColor &color);
|
||||
|
||||
template <>
|
||||
class ConversionTraits<QVariant> {
|
||||
public:
|
||||
static bool isUndefined(const QVariant &value) { return value.isNull() || !value.isValid(); }
|
||||
|
||||
static bool isArray(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
return QMetaType::canConvert(value.metaType(), QMetaType(QMetaType::QVariantList));
|
||||
#else
|
||||
return value.canConvert(QVariant::List);
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::size_t arrayLength(const QVariant &value) { return value.toList().size(); }
|
||||
|
||||
static QVariant arrayMember(const QVariant &value, std::size_t i) { return value.toList()[static_cast<int>(i)]; }
|
||||
|
||||
static bool isObject(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
return QMetaType::canConvert(value.metaType(), QMetaType(QMetaType::QVariantMap)) ||
|
||||
value.typeId() == QMetaType::QByteArray
|
||||
#else
|
||||
return value.canConvert(QVariant::Map) || value.type() == QVariant::ByteArray
|
||||
#endif
|
||||
|| QString(value.typeName()) == QStringLiteral("QMapLibre::Feature") ||
|
||||
value.userType() == qMetaTypeId<QVector<QMapLibre::Feature>>() ||
|
||||
value.userType() == qMetaTypeId<QList<QMapLibre::Feature>>() ||
|
||||
value.userType() == qMetaTypeId<std::list<QMapLibre::Feature>>();
|
||||
}
|
||||
|
||||
static std::optional<QVariant> objectMember(const QVariant &value, const char *key) {
|
||||
auto map = value.toMap();
|
||||
auto iter = map.constFind(key);
|
||||
|
||||
if (iter != map.constEnd()) {
|
||||
return iter.value();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template <class Fn>
|
||||
static std::optional<Error> eachMember(const QVariant &value, Fn &&fn) {
|
||||
auto map = value.toMap();
|
||||
auto iter = map.constBegin();
|
||||
|
||||
while (iter != map.constEnd()) {
|
||||
std::optional<Error> result = fn(iter.key().toStdString(), QVariant(iter.value()));
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<bool> toBool(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() == QMetaType::Bool) {
|
||||
#else
|
||||
if (value.type() == QVariant::Bool) {
|
||||
#endif
|
||||
return value.toBool();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<float> toNumber(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() == QMetaType::Int || value.typeId() == QMetaType::Double ||
|
||||
value.typeId() == QMetaType::Long || value.typeId() == QMetaType::LongLong ||
|
||||
value.typeId() == QMetaType::ULong || value.typeId() == QMetaType::ULongLong) {
|
||||
#else
|
||||
if (value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong ||
|
||||
value.type() == QVariant::ULongLong) {
|
||||
#endif
|
||||
return value.toFloat();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<double> toDouble(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() == QMetaType::Int || value.typeId() == QMetaType::Double ||
|
||||
value.typeId() == QMetaType::Long || value.typeId() == QMetaType::LongLong ||
|
||||
value.typeId() == QMetaType::ULong || value.typeId() == QMetaType::ULongLong) {
|
||||
#else
|
||||
if (value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong ||
|
||||
value.type() == QVariant::ULongLong) {
|
||||
#endif
|
||||
return value.toDouble();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<std::string> toString(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() == QMetaType::QString) {
|
||||
return value.toString().toStdString();
|
||||
}
|
||||
|
||||
if (value.typeId() == QMetaType::QColor) {
|
||||
return convertColor(value.value<QColor>());
|
||||
}
|
||||
#else
|
||||
if (value.type() == QVariant::String) {
|
||||
return value.toString().toStdString();
|
||||
}
|
||||
|
||||
if (value.type() == QVariant::Color) {
|
||||
return convertColor(value.value<QColor>());
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<Value> toValue(const QVariant &value) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() == QMetaType::Bool) {
|
||||
return {value.toBool()};
|
||||
}
|
||||
|
||||
if (value.typeId() == QMetaType::QString) {
|
||||
return {value.toString().toStdString()};
|
||||
}
|
||||
|
||||
if (value.typeId() == QMetaType::QColor) {
|
||||
return {convertColor(value.value<QColor>())};
|
||||
}
|
||||
|
||||
if (value.typeId() == QMetaType::Int) {
|
||||
return {static_cast<int64_t>(value.toInt())};
|
||||
}
|
||||
|
||||
if (QMetaType::canConvert(value.metaType(), QMetaType(QMetaType::Double))) {
|
||||
return {value.toDouble()};
|
||||
}
|
||||
#else
|
||||
if (value.type() == QVariant::Bool) {
|
||||
return {value.toBool()};
|
||||
}
|
||||
|
||||
if (value.type() == QVariant::String) {
|
||||
return {value.toString().toStdString()};
|
||||
}
|
||||
|
||||
if (value.type() == QVariant::Color) {
|
||||
return {convertColor(value.value<QColor>())};
|
||||
}
|
||||
|
||||
if (value.type() == QVariant::Int) {
|
||||
return {static_cast<int64_t>(value.toInt())};
|
||||
}
|
||||
|
||||
if (value.canConvert(QVariant::Double)) {
|
||||
return {value.toDouble()};
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
static std::optional<GeoJSON> toGeoJSON(const QVariant &value, Error &error) {
|
||||
if (value.typeName() == QStringLiteral("QMapLibre::Feature")) {
|
||||
return GeoJSON{QMapLibre::GeoJSON::asFeature(value.value<QMapLibre::Feature>())};
|
||||
}
|
||||
|
||||
if (value.userType() == qMetaTypeId<QVector<QMapLibre::Feature>>()) {
|
||||
return featureCollectionToGeoJSON(value.value<QVector<QMapLibre::Feature>>());
|
||||
}
|
||||
|
||||
if (value.userType() == qMetaTypeId<QList<QMapLibre::Feature>>()) {
|
||||
return featureCollectionToGeoJSON(value.value<QList<QMapLibre::Feature>>());
|
||||
}
|
||||
|
||||
if (value.userType() == qMetaTypeId<std::list<QMapLibre::Feature>>()) {
|
||||
return featureCollectionToGeoJSON(value.value<std::list<QMapLibre::Feature>>());
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (value.typeId() != QMetaType::QByteArray) {
|
||||
#else
|
||||
if (value.type() != QVariant::ByteArray) {
|
||||
#endif
|
||||
error = {"JSON data must be in QByteArray"};
|
||||
return {};
|
||||
}
|
||||
|
||||
const QByteArray data = value.toByteArray();
|
||||
return parseGeoJSON(std::string(data.constData(), data.size()), error);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
static GeoJSON featureCollectionToGeoJSON(const T &features) {
|
||||
mapbox::feature::feature_collection<double> collection;
|
||||
collection.reserve(static_cast<std::size_t>(features.size()));
|
||||
for (const auto &feature : features) {
|
||||
collection.push_back(QMapLibre::GeoJSON::asFeature(feature));
|
||||
}
|
||||
return GeoJSON{std::move(collection)};
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class... Args>
|
||||
std::optional<T> convert(const QVariant &value, Error &error, Args &&...args) {
|
||||
return convert<T>(Convertible(value), error, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
inline std::string convertColor(const QColor &color) {
|
||||
return QString::asprintf("rgba(%d,%d,%d,%lf)", color.red(), color.green(), color.blue(), color.alphaF())
|
||||
.toStdString();
|
||||
}
|
||||
|
||||
} // namespace mbgl::style::conversion
|
||||
20
third_party/maplibre-native-qt/include/export_core.hpp
vendored
Normal file
20
third_party/maplibre-native-qt/include/export_core.hpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_CORE_EXPORT_H
|
||||
#define QMAPLIBRE_CORE_EXPORT_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(QT_MAPLIBRE_STATIC)
|
||||
#if defined(QT_BUILD_MAPLIBRE_CORE_LIB)
|
||||
#define Q_MAPLIBRE_CORE_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define Q_MAPLIBRE_CORE_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define Q_MAPLIBRE_CORE_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // QMAPLIBRE_CORE_EXPORT_H
|
||||
20
third_party/maplibre-native-qt/include/export_location.hpp
vendored
Normal file
20
third_party/maplibre-native-qt/include/export_location.hpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_LOCATION_EXPORT_H
|
||||
#define QMAPLIBRE_LOCATION_EXPORT_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(QT_MAPLIBRE_STATIC)
|
||||
#if defined(QT_BUILD_MAPLIBRE_LOCATION_LIB)
|
||||
#define Q_MAPLIBRE_LOCATION_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define Q_MAPLIBRE_LOCATION_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define Q_MAPLIBRE_LOCATION_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // QMAPLIBRE_LOCATION_EXPORT_H
|
||||
20
third_party/maplibre-native-qt/include/export_widgets.hpp
vendored
Normal file
20
third_party/maplibre-native-qt/include/export_widgets.hpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_WIDGETS_EXPORT_H
|
||||
#define QMAPLIBRE_WIDGETS_EXPORT_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#if !defined(QT_MAPLIBRE_STATIC)
|
||||
#if defined(QT_BUILD_MAPLIBRE_WIDGETS_LIB)
|
||||
#define Q_MAPLIBRE_WIDGETS_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define Q_MAPLIBRE_WIDGETS_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define Q_MAPLIBRE_WIDGETS_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // QMAPLIBRE_WIDGETS_EXPORT_H
|
||||
30
third_party/maplibre-native-qt/include/geojson_p.hpp
vendored
Normal file
30
third_party/maplibre-native-qt/include/geojson_p.hpp
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
#include <mapbox/geojson.hpp>
|
||||
#include <mbgl/util/feature.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace QMapLibre::GeoJSON {
|
||||
|
||||
mbgl::Point<double> asPoint(const Coordinate &coordinate);
|
||||
mbgl::MultiPoint<double> asMultiPoint(const Coordinates &multiPoint);
|
||||
mbgl::LineString<double> asLineString(const Coordinates &lineString);
|
||||
mbgl::MultiLineString<double> asMultiLineString(const CoordinatesCollection &multiLineString);
|
||||
mbgl::Polygon<double> asPolygon(const CoordinatesCollection &polygon);
|
||||
mbgl::MultiPolygon<double> asMultiPolygon(const CoordinatesCollections &multiPolygon);
|
||||
mbgl::Value asPropertyValue(const QVariant &value);
|
||||
mbgl::FeatureIdentifier asFeatureIdentifier(const QVariant &id);
|
||||
mbgl::GeoJSONFeature asFeature(const Feature &feature);
|
||||
|
||||
} // namespace QMapLibre::GeoJSON
|
||||
56
third_party/maplibre-native-qt/include/gl_widget.hpp
vendored
Normal file
56
third_party/maplibre-native-qt/include/gl_widget.hpp
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_GL_WIDGET_H
|
||||
#define QMAPLIBRE_GL_WIDGET_H
|
||||
|
||||
#include <QMapLibreWidgets/Export>
|
||||
|
||||
#include <QMapLibre/Map>
|
||||
#include <QMapLibre/Settings>
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QKeyEvent;
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class GLWidgetPrivate;
|
||||
|
||||
class Q_MAPLIBRE_WIDGETS_EXPORT GLWidget : public QOpenGLWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GLWidget(const Settings &);
|
||||
~GLWidget() override;
|
||||
|
||||
Map *map();
|
||||
|
||||
protected:
|
||||
// QWidget implementation.
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
// Q{,Open}GLWidget implementation.
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(GLWidget)
|
||||
|
||||
std::unique_ptr<GLWidgetPrivate> d_ptr;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
|
||||
#endif // QMAPLIBRE_GL_WIDGET_H
|
||||
42
third_party/maplibre-native-qt/include/gl_widget_p.hpp
vendored
Normal file
42
third_party/maplibre-native-qt/include/gl_widget_p.hpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMapLibre/Map>
|
||||
#include <QMapLibre/Settings>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QKeyEvent;
|
||||
class QMouseEvent;
|
||||
class QWheelEvent;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class GLWidgetPrivate : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GLWidgetPrivate(QObject *parent, Settings settings);
|
||||
~GLWidgetPrivate() override;
|
||||
|
||||
void handleMousePressEvent(QMouseEvent *event);
|
||||
void handleMouseMoveEvent(QMouseEvent *event);
|
||||
void handleWheelEvent(QWheelEvent *event) const;
|
||||
|
||||
std::unique_ptr<Map> m_map{};
|
||||
Settings m_settings;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(GLWidgetPrivate);
|
||||
|
||||
QPointF m_lastPos;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
205
third_party/maplibre-native-qt/include/map.hpp
vendored
Normal file
205
third_party/maplibre-native-qt/include/map.hpp
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_MAP_H
|
||||
#define QMAPLIBRE_MAP_H
|
||||
|
||||
#include <QMapLibre/Export>
|
||||
#include <QMapLibre/Settings>
|
||||
#include <QMapLibre/Types>
|
||||
|
||||
#include <QtCore/QMargins>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QImage>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class MapPrivate;
|
||||
|
||||
class Q_MAPLIBRE_CORE_EXPORT Map : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
|
||||
Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
|
||||
Q_PROPERTY(double zoom READ zoom WRITE setZoom)
|
||||
Q_PROPERTY(double bearing READ bearing WRITE setBearing)
|
||||
Q_PROPERTY(double pitch READ pitch WRITE setPitch)
|
||||
Q_PROPERTY(QString styleJson READ styleJson WRITE setStyleJson)
|
||||
Q_PROPERTY(QString styleUrl READ styleUrl WRITE setStyleUrl)
|
||||
Q_PROPERTY(double scale READ scale WRITE setScale)
|
||||
Q_PROPERTY(QMapLibre::Coordinate coordinate READ coordinate WRITE setCoordinate)
|
||||
Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
|
||||
|
||||
public:
|
||||
enum MapChange {
|
||||
MapChangeRegionWillChange = 0,
|
||||
MapChangeRegionWillChangeAnimated,
|
||||
MapChangeRegionIsChanging,
|
||||
MapChangeRegionDidChange,
|
||||
MapChangeRegionDidChangeAnimated,
|
||||
MapChangeWillStartLoadingMap,
|
||||
MapChangeDidFinishLoadingMap,
|
||||
MapChangeDidFailLoadingMap,
|
||||
MapChangeWillStartRenderingFrame,
|
||||
MapChangeDidFinishRenderingFrame,
|
||||
MapChangeDidFinishRenderingFrameFullyRendered,
|
||||
MapChangeWillStartRenderingMap,
|
||||
MapChangeDidFinishRenderingMap,
|
||||
MapChangeDidFinishRenderingMapFullyRendered,
|
||||
MapChangeDidFinishLoadingStyle,
|
||||
MapChangeSourceDidChange
|
||||
};
|
||||
|
||||
enum MapLoadingFailure {
|
||||
StyleParseFailure,
|
||||
StyleLoadFailure,
|
||||
NotFoundFailure,
|
||||
UnknownFailure
|
||||
};
|
||||
|
||||
// Determines the orientation of the map.
|
||||
enum NorthOrientation {
|
||||
NorthUpwards, // Default
|
||||
NorthRightwards,
|
||||
NorthDownwards,
|
||||
NorthLeftwards,
|
||||
};
|
||||
|
||||
explicit Map(QObject *parent = nullptr,
|
||||
const Settings &settings = Settings(),
|
||||
const QSize &size = QSize(),
|
||||
qreal pixelRatio = 1);
|
||||
~Map() override;
|
||||
|
||||
[[nodiscard]] QString styleJson() const;
|
||||
[[nodiscard]] QString styleUrl() const;
|
||||
|
||||
void setStyleJson(const QString &);
|
||||
void setStyleUrl(const QString &);
|
||||
|
||||
[[nodiscard]] double latitude() const;
|
||||
void setLatitude(double latitude);
|
||||
|
||||
[[nodiscard]] double longitude() const;
|
||||
void setLongitude(double longitude);
|
||||
|
||||
[[nodiscard]] double scale() const;
|
||||
void setScale(double scale, const QPointF ¢er = QPointF());
|
||||
|
||||
[[nodiscard]] double zoom() const;
|
||||
void setZoom(double zoom);
|
||||
|
||||
[[nodiscard]] double minimumZoom() const;
|
||||
[[nodiscard]] double maximumZoom() const;
|
||||
|
||||
[[nodiscard]] double bearing() const;
|
||||
void setBearing(double degrees);
|
||||
void setBearing(double degrees, const QPointF ¢er);
|
||||
|
||||
[[nodiscard]] double pitch() const;
|
||||
void setPitch(double pitch);
|
||||
void pitchBy(double pitch);
|
||||
|
||||
[[nodiscard]] NorthOrientation northOrientation() const;
|
||||
void setNorthOrientation(NorthOrientation);
|
||||
|
||||
[[nodiscard]] Coordinate coordinate() const;
|
||||
void setCoordinate(const Coordinate &coordinate);
|
||||
void setCoordinateZoom(const Coordinate &coordinate, double zoom);
|
||||
|
||||
void jumpTo(const CameraOptions &);
|
||||
|
||||
void setGestureInProgress(bool inProgress);
|
||||
|
||||
void setTransitionOptions(qint64 duration, qint64 delay = 0);
|
||||
|
||||
void addAnnotationIcon(const QString &name, const QImage &sprite);
|
||||
|
||||
AnnotationID addAnnotation(const Annotation &annotation);
|
||||
void updateAnnotation(AnnotationID id, const Annotation &annotation);
|
||||
void removeAnnotation(AnnotationID id);
|
||||
|
||||
bool setLayoutProperty(const QString &layerId, const QString &propertyName, const QVariant &value);
|
||||
bool setPaintProperty(const QString &layerId, const QString &propertyName, const QVariant &value);
|
||||
|
||||
[[nodiscard]] bool isFullyLoaded() const;
|
||||
|
||||
void moveBy(const QPointF &offset);
|
||||
void scaleBy(double scale, const QPointF ¢er = QPointF());
|
||||
void rotateBy(const QPointF &first, const QPointF &second);
|
||||
|
||||
void resize(const QSize &size);
|
||||
|
||||
[[nodiscard]] QPointF pixelForCoordinate(const Coordinate &coordinate) const;
|
||||
[[nodiscard]] Coordinate coordinateForPixel(const QPointF &pixel) const;
|
||||
|
||||
[[nodiscard]] CoordinateZoom coordinateZoomForBounds(const Coordinate &sw, const Coordinate &ne) const;
|
||||
[[nodiscard]] CoordinateZoom coordinateZoomForBounds(const Coordinate &sw,
|
||||
const Coordinate &ne,
|
||||
double bearing,
|
||||
double pitch);
|
||||
|
||||
void setMargins(const QMargins &margins);
|
||||
[[nodiscard]] QMargins margins() const;
|
||||
|
||||
void addSource(const QString &id, const QVariantMap ¶ms);
|
||||
bool sourceExists(const QString &id);
|
||||
void updateSource(const QString &id, const QVariantMap ¶ms);
|
||||
void removeSource(const QString &id);
|
||||
|
||||
void addImage(const QString &id, const QImage &sprite);
|
||||
void removeImage(const QString &id);
|
||||
|
||||
void addCustomLayer(const QString &id,
|
||||
std::unique_ptr<CustomLayerHostInterface> host,
|
||||
const QString &before = QString());
|
||||
void addLayer(const QString &id, const QVariantMap ¶ms, const QString &before = QString());
|
||||
bool layerExists(const QString &id);
|
||||
void removeLayer(const QString &id);
|
||||
|
||||
[[nodiscard]] QVector<QString> layerIds() const;
|
||||
|
||||
void setFilter(const QString &layerId, const QVariant &filter);
|
||||
[[nodiscard]] QVariant getFilter(const QString &layerId) const;
|
||||
// When rendering on a different thread,
|
||||
// should be called on the render thread.
|
||||
void createRenderer();
|
||||
void destroyRenderer();
|
||||
void setFramebufferObject(quint32 fbo, const QSize &size);
|
||||
|
||||
public slots:
|
||||
void render();
|
||||
void setConnectionEstablished();
|
||||
|
||||
// Commit changes, load all the resources
|
||||
// and renders the map when completed.
|
||||
void startStaticRender();
|
||||
|
||||
signals:
|
||||
void needsRendering();
|
||||
void mapChanged(Map::MapChange);
|
||||
void mapLoadingFailed(Map::MapLoadingFailure, const QString &reason);
|
||||
void copyrightsChanged(const QString ©rightsHtml);
|
||||
|
||||
void staticRenderFinished(const QString &error);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(Map)
|
||||
|
||||
std::unique_ptr<MapPrivate> d_ptr;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
|
||||
Q_DECLARE_METATYPE(QMapLibre::Map::MapChange);
|
||||
Q_DECLARE_METATYPE(QMapLibre::Map::MapLoadingFailure);
|
||||
|
||||
#endif // QMAPLIBRE_MAP_H
|
||||
54
third_party/maplibre-native-qt/include/map_observer_p.hpp
vendored
Normal file
54
third_party/maplibre-native-qt/include/map_observer_p.hpp
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "map.hpp"
|
||||
|
||||
#include <mbgl/map/map_observer.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class MapPrivate;
|
||||
|
||||
class MapObserver : public QObject, public mbgl::MapObserver {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MapObserver(MapPrivate *ptr);
|
||||
~MapObserver() override;
|
||||
|
||||
// mbgl::MapObserver implementation.
|
||||
void onCameraWillChange(mbgl::MapObserver::CameraChangeMode mode) final;
|
||||
void onCameraIsChanging() final;
|
||||
void onCameraDidChange(mbgl::MapObserver::CameraChangeMode mode) final;
|
||||
void onWillStartLoadingMap() final;
|
||||
void onDidFinishLoadingMap() final;
|
||||
void onDidFailLoadingMap(mbgl::MapLoadError error, const std::string &what) final;
|
||||
void onWillStartRenderingFrame() final;
|
||||
void onDidFinishRenderingFrame(mbgl::MapObserver::RenderFrameStatus status) final;
|
||||
void onWillStartRenderingMap() final;
|
||||
void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode mode) final;
|
||||
void onDidFinishLoadingStyle() final;
|
||||
void onSourceChanged(mbgl::style::Source &source) final;
|
||||
|
||||
signals:
|
||||
void mapChanged(Map::MapChange);
|
||||
void mapLoadingFailed(Map::MapLoadingFailure, const QString &reason);
|
||||
void copyrightsChanged(const QString ©rightsHtml);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(MapObserver)
|
||||
|
||||
MapPrivate *d_ptrRef;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
79
third_party/maplibre-native-qt/include/map_p.hpp
vendored
Normal file
79
third_party/maplibre-native-qt/include/map_p.hpp
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "map.hpp"
|
||||
#include "map_observer_p.hpp"
|
||||
#include "map_renderer_p.hpp"
|
||||
|
||||
#include <mbgl/actor/actor.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/renderer/renderer_frontend.hpp>
|
||||
#include <mbgl/storage/resource_transform.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSize>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class MapPrivate : public QObject, public mbgl::RendererFrontend {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MapPrivate(Map *map, const Settings &settings, const QSize &size, qreal pixelRatio);
|
||||
~MapPrivate() override;
|
||||
|
||||
// mbgl::RendererFrontend implementation.
|
||||
void reset() final {}
|
||||
void setObserver(mbgl::RendererObserver &observer) final;
|
||||
void update(std::shared_ptr<mbgl::UpdateParameters> parameters) final;
|
||||
|
||||
// These need to be called on the same thread.
|
||||
void createRenderer();
|
||||
void destroyRenderer();
|
||||
void render();
|
||||
void setFramebufferObject(quint32 fbo, const QSize &size);
|
||||
|
||||
using PropertySetter = std::optional<mbgl::style::conversion::Error> (mbgl::style::Layer::*)(
|
||||
const std::string &, const mbgl::style::conversion::Convertible &);
|
||||
[[nodiscard]] bool setProperty(const PropertySetter &setter,
|
||||
const QString &layerId,
|
||||
const QString &name,
|
||||
const QVariant &value) const;
|
||||
|
||||
mbgl::EdgeInsets margins;
|
||||
std::unique_ptr<mbgl::Map> mapObj{};
|
||||
|
||||
public slots:
|
||||
void requestRendering();
|
||||
|
||||
signals:
|
||||
void needsRendering();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(MapPrivate)
|
||||
|
||||
std::recursive_mutex m_mapRendererMutex;
|
||||
std::shared_ptr<mbgl::RendererObserver> m_rendererObserver{};
|
||||
std::shared_ptr<mbgl::UpdateParameters> m_updateParameters{};
|
||||
|
||||
std::unique_ptr<MapObserver> m_mapObserver{};
|
||||
std::unique_ptr<MapRenderer> m_mapRenderer{};
|
||||
std::unique_ptr<mbgl::Actor<mbgl::ResourceTransform::TransformCallback>> m_resourceTransform{};
|
||||
|
||||
Settings::GLContextMode m_mode;
|
||||
qreal m_pixelRatio;
|
||||
|
||||
QString m_localFontFamily;
|
||||
|
||||
std::atomic_flag m_renderQueued = ATOMIC_FLAG_INIT;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
63
third_party/maplibre-native-qt/include/map_renderer_p.hpp
vendored
Normal file
63
third_party/maplibre-native-qt/include/map_renderer_p.hpp
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "utils/renderer_backend.hpp"
|
||||
|
||||
#include <mbgl/renderer/renderer.hpp>
|
||||
#include <mbgl/renderer/renderer_observer.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace mbgl {
|
||||
class Renderer;
|
||||
class UpdateParameters;
|
||||
} // namespace mbgl
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class RendererBackend;
|
||||
|
||||
class MapRenderer : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapRenderer(qreal pixelRatio, Settings::GLContextMode, const QString &localFontFamily);
|
||||
~MapRenderer() override;
|
||||
|
||||
void render();
|
||||
void updateFramebuffer(quint32 fbo, const mbgl::Size &size);
|
||||
void setObserver(mbgl::RendererObserver *observer);
|
||||
|
||||
// Thread-safe, called by the Frontend
|
||||
void updateParameters(std::shared_ptr<mbgl::UpdateParameters> parameters);
|
||||
|
||||
signals:
|
||||
void needsRendering();
|
||||
|
||||
private:
|
||||
MBGL_STORE_THREAD(tid)
|
||||
|
||||
Q_DISABLE_COPY(MapRenderer)
|
||||
|
||||
std::mutex m_updateMutex;
|
||||
std::shared_ptr<mbgl::UpdateParameters> m_updateParameters;
|
||||
|
||||
RendererBackend m_backend;
|
||||
std::unique_ptr<mbgl::Renderer> m_renderer{};
|
||||
|
||||
bool m_forceScheduler{};
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
54
third_party/maplibre-native-qt/include/qgeomap.hpp
vendored
Normal file
54
third_party/maplibre-native-qt/include/qgeomap.hpp
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// Copyright (C) 2017 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "export_location.hpp"
|
||||
|
||||
#include <QMapLibre/Map>
|
||||
#include <QMapLibre/StyleParameter>
|
||||
|
||||
#include <QtLocation/private/qgeomap_p.h>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class QGeoMapMapLibrePrivate;
|
||||
|
||||
class Q_MAPLIBRE_LOCATION_EXPORT QGeoMapMapLibre : public QGeoMap {
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QGeoMapMapLibre)
|
||||
|
||||
public:
|
||||
explicit QGeoMapMapLibre(QGeoMappingManagerEngine *engine, QObject *parent = nullptr);
|
||||
~QGeoMapMapLibre() override;
|
||||
|
||||
[[nodiscard]] Capabilities capabilities() const override;
|
||||
|
||||
void setSettings(const Settings &settings);
|
||||
void setMapItemsBefore(const QString &mapItemsBefore);
|
||||
|
||||
void addStyleParameter(StyleParameter *parameter);
|
||||
void removeStyleParameter(StyleParameter *parameter);
|
||||
void clearStyleParameters();
|
||||
|
||||
private Q_SLOTS:
|
||||
// QMapLibre
|
||||
void onMapChanged(Map::MapChange);
|
||||
|
||||
// QDeclarativeGeoMapItemBase
|
||||
void onMapItemPropertyChanged();
|
||||
void onMapItemSubPropertyChanged();
|
||||
void onMapItemUnsupportedPropertyChanged();
|
||||
void onMapItemGeometryChanged();
|
||||
|
||||
// StyleParameter
|
||||
void onStyleParameterUpdated(StyleParameter *parameter);
|
||||
|
||||
private:
|
||||
QSGNode *updateSceneGraph(QSGNode *oldNode, QQuickWindow *window) override;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
93
third_party/maplibre-native-qt/include/qgeomap_p.hpp
vendored
Normal file
93
third_party/maplibre-native-qt/include/qgeomap_p.hpp
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// Copyright (C) 2017 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qgeomap.hpp"
|
||||
|
||||
#include <QMapLibre/Settings>
|
||||
#include <QMapLibre/StyleParameter>
|
||||
|
||||
#include <QtLocation/private/qgeomap_p_p.h>
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class Map;
|
||||
class StyleChange;
|
||||
|
||||
class QGeoMapMapLibrePrivate : public QGeoMapPrivate {
|
||||
Q_DECLARE_PUBLIC(QGeoMapMapLibre)
|
||||
|
||||
public:
|
||||
explicit QGeoMapMapLibrePrivate(QGeoMappingManagerEngine *engine);
|
||||
~QGeoMapMapLibrePrivate() override;
|
||||
|
||||
QSGNode *updateSceneGraph(QSGNode *oldNode, QQuickWindow *window);
|
||||
|
||||
QGeoMap::ItemTypes supportedMapItemTypes() const override;
|
||||
void addMapItem(QDeclarativeGeoMapItemBase *item) override;
|
||||
void removeMapItem(QDeclarativeGeoMapItemBase *item) override;
|
||||
|
||||
void addStyleParameter(StyleParameter *parameter);
|
||||
void removeStyleParameter(StyleParameter *parameter);
|
||||
void clearStyleParameters();
|
||||
|
||||
/* Data members */
|
||||
enum SyncState : int {
|
||||
NoSync = 0,
|
||||
ViewportSync = 1 << 0,
|
||||
CameraDataSync = 1 << 1,
|
||||
MapTypeSync = 1 << 2,
|
||||
VisibleAreaSync = 1 << 3
|
||||
};
|
||||
Q_DECLARE_FLAGS(SyncStates, SyncState);
|
||||
|
||||
Settings m_settings;
|
||||
QString m_mapItemsBefore;
|
||||
|
||||
QList<StyleParameter *> m_mapParameters;
|
||||
|
||||
QTimer m_refresh;
|
||||
bool m_shouldRefresh = true;
|
||||
bool m_warned = false;
|
||||
bool m_threadedRendering = false;
|
||||
bool m_styleLoaded = false;
|
||||
|
||||
SyncStates m_syncState = NoSync;
|
||||
|
||||
std::vector<std::unique_ptr<StyleChange>> m_styleChanges;
|
||||
|
||||
protected:
|
||||
void changeViewportSize(const QSize &size) override;
|
||||
void changeCameraData(const QGeoCameraData &data) override;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
void changeActiveMapType(const QGeoMapType &mapType) override;
|
||||
#else
|
||||
void changeActiveMapType(const QGeoMapType mapType) override;
|
||||
#endif
|
||||
|
||||
void setVisibleArea(const QRectF &visibleArea) override;
|
||||
QRectF visibleArea() const override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QGeoMapMapLibrePrivate);
|
||||
|
||||
void syncStyleChanges(Map *map);
|
||||
void threadedRenderingHack(QQuickWindow *window, Map *map);
|
||||
|
||||
QRectF m_visibleArea;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoMapMapLibrePrivate::SyncStates)
|
||||
|
||||
} // namespace QMapLibre
|
||||
9
third_party/maplibre-native-qt/include/qmaplibre.hpp
vendored
Normal file
9
third_party/maplibre-native-qt/include/qmaplibre.hpp
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#include "export_core.hpp"
|
||||
#include "map.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
6
third_party/maplibre-native-qt/include/qmaplibrewidgets.hpp
vendored
Normal file
6
third_party/maplibre-native-qt/include/qmaplibrewidgets.hpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#include "export_widgets.hpp"
|
||||
#include "gl_widget.hpp"
|
||||
31
third_party/maplibre-native-qt/include/qt_mapping_engine.hpp
vendored
Normal file
31
third_party/maplibre-native-qt/include/qt_mapping_engine.hpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// Copyright (C) 2017 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "export_location.hpp"
|
||||
|
||||
#include <QMapLibre/Settings>
|
||||
|
||||
#include <QtLocation/private/qgeomappingmanagerengine_p.h>
|
||||
#include <QtLocation/QGeoServiceProvider>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class Q_MAPLIBRE_LOCATION_EXPORT QtMappingEngine : public QGeoMappingManagerEngine {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtMappingEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString);
|
||||
|
||||
QGeoMap *createMap() override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
QString m_mapItemsBefore;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
125
third_party/maplibre-native-qt/include/settings.hpp
vendored
Normal file
125
third_party/maplibre-native-qt/include/settings.hpp
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_SETTINGS_H
|
||||
#define QMAPLIBRE_SETTINGS_H
|
||||
|
||||
#include <QMapLibre/Export>
|
||||
#include <QMapLibre/Types>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QImage>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
// TODO: this will be wrapped at some point
|
||||
namespace mbgl {
|
||||
class TileServerOptions;
|
||||
} // namespace mbgl
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class SettingsPrivate;
|
||||
|
||||
class Q_MAPLIBRE_CORE_EXPORT Settings {
|
||||
public:
|
||||
enum GLContextMode : bool {
|
||||
UniqueGLContext,
|
||||
SharedGLContext
|
||||
};
|
||||
|
||||
enum MapMode {
|
||||
Continuous = 0,
|
||||
Static
|
||||
};
|
||||
|
||||
enum ConstrainMode {
|
||||
NoConstrain = 0,
|
||||
ConstrainHeightOnly,
|
||||
ConstrainWidthAndHeight
|
||||
};
|
||||
|
||||
enum ViewportMode {
|
||||
DefaultViewport = 0,
|
||||
FlippedYViewport
|
||||
};
|
||||
|
||||
enum ProviderTemplate {
|
||||
NoProvider = 0,
|
||||
MapLibreProvider,
|
||||
MapTilerProvider,
|
||||
MapboxProvider
|
||||
};
|
||||
|
||||
using ResourceTransformFunction = std::function<std::string(const std::string &)>;
|
||||
|
||||
explicit Settings(ProviderTemplate provider = NoProvider);
|
||||
~Settings();
|
||||
Settings(const Settings &s);
|
||||
Settings(Settings &&s) noexcept;
|
||||
Settings &operator=(const Settings &s);
|
||||
Settings &operator=(Settings &&s) noexcept;
|
||||
|
||||
[[nodiscard]] GLContextMode contextMode() const;
|
||||
void setContextMode(GLContextMode);
|
||||
|
||||
[[nodiscard]] MapMode mapMode() const;
|
||||
void setMapMode(MapMode);
|
||||
|
||||
[[nodiscard]] ConstrainMode constrainMode() const;
|
||||
void setConstrainMode(ConstrainMode);
|
||||
|
||||
[[nodiscard]] ViewportMode viewportMode() const;
|
||||
void setViewportMode(ViewportMode);
|
||||
|
||||
[[nodiscard]] unsigned cacheDatabaseMaximumSize() const;
|
||||
void setCacheDatabaseMaximumSize(unsigned);
|
||||
|
||||
[[nodiscard]] QString cacheDatabasePath() const;
|
||||
void setCacheDatabasePath(const QString &path);
|
||||
|
||||
[[nodiscard]] QString assetPath() const;
|
||||
void setAssetPath(const QString &path);
|
||||
|
||||
[[nodiscard]] QString apiKey() const;
|
||||
void setApiKey(const QString &key);
|
||||
|
||||
[[nodiscard]] QString apiBaseUrl() const;
|
||||
void setApiBaseUrl(const QString &url);
|
||||
|
||||
[[nodiscard]] QString localFontFamily() const;
|
||||
void setLocalFontFamily(const QString &family);
|
||||
|
||||
[[nodiscard]] QString clientName() const;
|
||||
void setClientName(const QString &name);
|
||||
|
||||
[[nodiscard]] QString clientVersion() const;
|
||||
void setClientVersion(const QString &version);
|
||||
|
||||
[[nodiscard]] ResourceTransformFunction resourceTransform() const;
|
||||
void setResourceTransform(const ResourceTransformFunction &transform);
|
||||
|
||||
void setProviderTemplate(ProviderTemplate providerTemplate);
|
||||
void setStyles(const Styles &styles);
|
||||
|
||||
[[nodiscard]] const Styles &styles() const;
|
||||
[[nodiscard]] Styles providerStyles() const;
|
||||
|
||||
[[nodiscard]] Coordinate defaultCoordinate() const;
|
||||
void setDefaultCoordinate(const Coordinate &coordinate);
|
||||
[[nodiscard]] double defaultZoom() const;
|
||||
void setDefaultZoom(double zoom);
|
||||
|
||||
[[nodiscard]] bool customTileServerOptions() const;
|
||||
[[nodiscard]] const mbgl::TileServerOptions &tileServerOptions() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<SettingsPrivate> d_ptr;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
|
||||
#endif // QMAPLIBRE_SETTINGS_H
|
||||
57
third_party/maplibre-native-qt/include/settings_p.hpp
vendored
Normal file
57
third_party/maplibre-native-qt/include/settings_p.hpp
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "settings.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
#include <mbgl/util/tile_server_options.hpp>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
class TileServerOptions;
|
||||
} // namespace mbgl
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class SettingsPrivate {
|
||||
public:
|
||||
SettingsPrivate();
|
||||
|
||||
void setProviderTemplate(Settings::ProviderTemplate providerTemplate);
|
||||
void setProviderApiBaseUrl(const QString &url);
|
||||
|
||||
Settings::GLContextMode m_contextMode{Settings::SharedGLContext};
|
||||
Settings::MapMode m_mapMode{Settings::Continuous};
|
||||
Settings::ConstrainMode m_constrainMode{Settings::ConstrainHeightOnly};
|
||||
Settings::ViewportMode m_viewportMode{Settings::DefaultViewport};
|
||||
Settings::ProviderTemplate m_providerTemplate{Settings::NoProvider};
|
||||
|
||||
unsigned m_cacheMaximumSize;
|
||||
QString m_cacheDatabasePath;
|
||||
QString m_assetPath;
|
||||
QString m_apiKey;
|
||||
QString m_localFontFamily;
|
||||
QString m_clientName;
|
||||
QString m_clientVersion;
|
||||
|
||||
Coordinate m_defaultCoordinate{};
|
||||
double m_defaultZoom{};
|
||||
|
||||
Styles m_styles;
|
||||
|
||||
std::function<std::string(const std::string &)> m_resourceTransform;
|
||||
|
||||
bool m_customTileServerOptions{};
|
||||
mbgl::TileServerOptions m_tileServerOptions{};
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
34
third_party/maplibre-native-qt/include/style_change_utils_p.hpp
vendored
Normal file
34
third_party/maplibre-native-qt/include/style_change_utils_p.hpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2017 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMapLibre/Types>
|
||||
|
||||
#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
|
||||
#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
|
||||
#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
|
||||
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
|
||||
#include <QtLocation/private/qdeclarativerectanglemapitem_p.h>
|
||||
|
||||
namespace QMapLibre::StyleChangeUtils {
|
||||
|
||||
Feature featureFromMapRectangle(QDeclarativeRectangleMapItem *item);
|
||||
Feature featureFromMapCircle(QDeclarativeCircleMapItem *item);
|
||||
Feature featureFromMapPolygon(QDeclarativePolygonMapItem *item);
|
||||
Feature featureFromMapPolyline(QDeclarativePolylineMapItem *item);
|
||||
Feature featureFromMapItem(QDeclarativeGeoMapItemBase *item);
|
||||
|
||||
QString featureId(QDeclarativeGeoMapItemBase *item);
|
||||
std::vector<FeatureProperty> featureLayoutPropertiesFromMapPolyline(QDeclarativePolylineMapItem *item);
|
||||
std::vector<FeatureProperty> featureLayoutPropertiesFromMapItem(QDeclarativeGeoMapItemBase *item);
|
||||
std::vector<FeatureProperty> featurePaintPropertiesFromMapRectangle(QDeclarativeRectangleMapItem *item);
|
||||
std::vector<FeatureProperty> featurePaingPropertiesFromMapCircle(QDeclarativeCircleMapItem *item);
|
||||
std::vector<FeatureProperty> featurePaintPropertiesFromMapPolygon(QDeclarativePolygonMapItem *item);
|
||||
std::vector<FeatureProperty> featurePaintPropertiesFromMapPolyline(QDeclarativePolylineMapItem *item);
|
||||
std::vector<FeatureProperty> featurePaintPropertiesFromMapItem(QDeclarativeGeoMapItemBase *item);
|
||||
std::vector<FeatureProperty> featurePropertiesFromMapItem(QDeclarativeGeoMapItemBase *item);
|
||||
|
||||
} // namespace QMapLibre::StyleChangeUtils
|
||||
42
third_party/maplibre-native-qt/include/texture_node.hpp
vendored
Normal file
42
third_party/maplibre-native-qt/include/texture_node.hpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// Copyright (C) 2017 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#include <QtQuick/QSGRenderNode>
|
||||
#include <QtQuick/QSGSimpleTextureNode>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QtOpenGL/QOpenGLFramebufferObject>
|
||||
#else
|
||||
#include <QtGui/QOpenGLFramebufferObject>
|
||||
#endif
|
||||
|
||||
#include <QMapLibre/Map>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
class QGeoMapMapLibre;
|
||||
|
||||
class TextureNode : public QSGSimpleTextureNode {
|
||||
public:
|
||||
TextureNode(const Settings &setting, const QSize &size, qreal pixelRatio, QGeoMapMapLibre *geoMap);
|
||||
|
||||
[[nodiscard]] Map *map() const;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void resize(const QSize &size, qreal pixelRatio, QQuickWindow *window);
|
||||
#else
|
||||
void resize(const QSize &size, qreal pixelRatio);
|
||||
#endif
|
||||
void render(QQuickWindow *);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Map> m_map{};
|
||||
std::unique_ptr<QOpenGLFramebufferObject> m_fbo{};
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
206
third_party/maplibre-native-qt/include/types.hpp
vendored
Normal file
206
third_party/maplibre-native-qt/include/types.hpp
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_TYPES_H
|
||||
#define QMAPLIBRE_TYPES_H
|
||||
|
||||
#include <QMapLibre/Export>
|
||||
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtGui/QColor>
|
||||
#include <utility>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
using Coordinate = QPair<double, double>;
|
||||
using CoordinateZoom = QPair<Coordinate, double>;
|
||||
using ProjectedMeters = QPair<double, double>;
|
||||
|
||||
using Coordinates = QVector<Coordinate>;
|
||||
using CoordinatesCollection = QVector<Coordinates>;
|
||||
|
||||
using CoordinatesCollections = QVector<CoordinatesCollection>;
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT Style {
|
||||
enum Type { // Taken from Qt to be in sync with QtLocation
|
||||
NoMap = 0,
|
||||
StreetMap,
|
||||
SatelliteMapDay,
|
||||
SatelliteMapNight,
|
||||
TerrainMap,
|
||||
HybridMap,
|
||||
TransitMap,
|
||||
GrayStreetMap,
|
||||
PedestrianMap,
|
||||
CarNavigationMap,
|
||||
CycleMap,
|
||||
CustomMap = 100
|
||||
};
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
explicit Style(QString url_, QString name_ = QString())
|
||||
: url(std::move(url_)),
|
||||
name(std::move(name_)) {}
|
||||
#else
|
||||
explicit Style(QString url_ = QString(), QString name_ = QString())
|
||||
: url(std::move(url_)),
|
||||
name(std::move(name_)) {}
|
||||
#endif
|
||||
|
||||
QString url;
|
||||
QString name;
|
||||
QString description;
|
||||
bool night{};
|
||||
Type type{CustomMap};
|
||||
};
|
||||
|
||||
using Styles = QVector<Style>;
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT Feature {
|
||||
enum Type {
|
||||
PointType = 1,
|
||||
LineStringType,
|
||||
PolygonType
|
||||
};
|
||||
|
||||
/*! Class constructor. */
|
||||
explicit Feature(Type type_ = PointType,
|
||||
CoordinatesCollections geometry_ = CoordinatesCollections(),
|
||||
QVariantMap properties_ = QVariantMap(),
|
||||
QVariant id_ = QVariant())
|
||||
: type(type_),
|
||||
geometry(std::move(geometry_)),
|
||||
properties(std::move(properties_)),
|
||||
id(std::move(id_)) {}
|
||||
|
||||
Type type;
|
||||
CoordinatesCollections geometry;
|
||||
QVariantMap properties;
|
||||
QVariant id;
|
||||
};
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT FeatureProperty {
|
||||
enum Type {
|
||||
LayoutProperty = 1,
|
||||
PaintProperty,
|
||||
};
|
||||
|
||||
/*! Class constructor. */
|
||||
explicit FeatureProperty(Type type_, QString name_, QVariant value_)
|
||||
: type(type_),
|
||||
name(std::move(name_)),
|
||||
value(std::move(value_)) {}
|
||||
|
||||
Type type;
|
||||
QString name;
|
||||
QVariant value;
|
||||
};
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT ShapeAnnotationGeometry {
|
||||
enum Type {
|
||||
LineStringType = 1,
|
||||
PolygonType,
|
||||
MultiLineStringType,
|
||||
MultiPolygonType
|
||||
};
|
||||
|
||||
/*! Class constructor. */
|
||||
explicit ShapeAnnotationGeometry(Type type_ = LineStringType,
|
||||
CoordinatesCollections geometry_ = CoordinatesCollections())
|
||||
: type(type_),
|
||||
geometry(std::move(geometry_)) {}
|
||||
|
||||
Type type;
|
||||
CoordinatesCollections geometry;
|
||||
};
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT SymbolAnnotation {
|
||||
Coordinate geometry;
|
||||
QString icon;
|
||||
};
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT LineAnnotation {
|
||||
/*! Class constructor. */
|
||||
explicit LineAnnotation(ShapeAnnotationGeometry geometry_ = ShapeAnnotationGeometry(),
|
||||
float opacity_ = 1.0f,
|
||||
float width_ = 1.0f,
|
||||
const QColor &color_ = Qt::black)
|
||||
: geometry(std::move(geometry_)),
|
||||
opacity(opacity_),
|
||||
width(width_),
|
||||
color(color_) {}
|
||||
|
||||
ShapeAnnotationGeometry geometry;
|
||||
float opacity;
|
||||
float width;
|
||||
QColor color;
|
||||
};
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT FillAnnotation {
|
||||
/*! Class constructor. */
|
||||
explicit FillAnnotation(ShapeAnnotationGeometry geometry_ = ShapeAnnotationGeometry(),
|
||||
float opacity_ = 1.0f,
|
||||
const QColor &color_ = Qt::black,
|
||||
QVariant outlineColor_ = QVariant())
|
||||
: geometry(std::move(geometry_)),
|
||||
opacity(opacity_),
|
||||
color(color_),
|
||||
outlineColor(std::move(outlineColor_)) {}
|
||||
|
||||
ShapeAnnotationGeometry geometry;
|
||||
float opacity;
|
||||
QColor color;
|
||||
QVariant outlineColor;
|
||||
};
|
||||
|
||||
using Annotation = QVariant;
|
||||
using AnnotationID = quint32;
|
||||
using AnnotationIDs = QVector<AnnotationID>;
|
||||
|
||||
struct Q_MAPLIBRE_CORE_EXPORT CameraOptions {
|
||||
QVariant center; // Coordinate
|
||||
QVariant anchor; // QPointF
|
||||
QVariant zoom; // double
|
||||
QVariant bearing; // double
|
||||
QVariant pitch; // double
|
||||
};
|
||||
|
||||
// This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters.
|
||||
struct Q_MAPLIBRE_CORE_EXPORT CustomLayerRenderParameters {
|
||||
double width;
|
||||
double height;
|
||||
double latitude;
|
||||
double longitude;
|
||||
double zoom;
|
||||
double bearing;
|
||||
double pitch;
|
||||
double fieldOfView;
|
||||
};
|
||||
|
||||
class Q_MAPLIBRE_CORE_EXPORT CustomLayerHostInterface {
|
||||
public:
|
||||
virtual ~CustomLayerHostInterface() = default;
|
||||
virtual void initialize() = 0;
|
||||
virtual void render(const CustomLayerRenderParameters &) = 0;
|
||||
virtual void deinitialize() = 0;
|
||||
};
|
||||
|
||||
} // namespace QMapLibre
|
||||
|
||||
Q_DECLARE_METATYPE(QMapLibre::Coordinate);
|
||||
Q_DECLARE_METATYPE(QMapLibre::Coordinates);
|
||||
Q_DECLARE_METATYPE(QMapLibre::CoordinatesCollection);
|
||||
Q_DECLARE_METATYPE(QMapLibre::CoordinatesCollections);
|
||||
Q_DECLARE_METATYPE(QMapLibre::Feature);
|
||||
|
||||
Q_DECLARE_METATYPE(QMapLibre::SymbolAnnotation);
|
||||
Q_DECLARE_METATYPE(QMapLibre::ShapeAnnotationGeometry);
|
||||
Q_DECLARE_METATYPE(QMapLibre::LineAnnotation);
|
||||
Q_DECLARE_METATYPE(QMapLibre::FillAnnotation);
|
||||
|
||||
#endif // QMAPLIBRE_TYPES_H
|
||||
28
third_party/maplibre-native-qt/include/utils.hpp
vendored
Normal file
28
third_party/maplibre-native-qt/include/utils.hpp
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2023 MapLibre contributors
|
||||
// Copyright (C) 2019 Mapbox, Inc.
|
||||
|
||||
// SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
#ifndef QMAPLIBRE_UTILS_H
|
||||
#define QMAPLIBRE_UTILS_H
|
||||
|
||||
#include <QMapLibre/Export>
|
||||
#include <QMapLibre/Types>
|
||||
|
||||
namespace QMapLibre {
|
||||
|
||||
enum NetworkMode {
|
||||
Online, // Default
|
||||
Offline,
|
||||
};
|
||||
|
||||
Q_MAPLIBRE_CORE_EXPORT NetworkMode networkMode();
|
||||
Q_MAPLIBRE_CORE_EXPORT void setNetworkMode(NetworkMode mode);
|
||||
|
||||
Q_MAPLIBRE_CORE_EXPORT double metersPerPixelAtLatitude(double latitude, double zoom);
|
||||
Q_MAPLIBRE_CORE_EXPORT ProjectedMeters projectedMetersForCoordinate(const Coordinate &coordinate);
|
||||
Q_MAPLIBRE_CORE_EXPORT Coordinate coordinateForProjectedMeters(const ProjectedMeters &projectedMeters);
|
||||
|
||||
} // namespace QMapLibre
|
||||
|
||||
#endif // QMAPLIBRE_UTILS_H
|
||||
Reference in New Issue
Block a user