#include "qmapbox.hpp" #include #include #include #include #include #include #if QT_VERSION >= 0x050000 #include #else #include #endif // mbgl::NetworkStatus::Status static_assert(mbgl::underlying_type(QMapbox::Online) == mbgl::underlying_type(mbgl::NetworkStatus::Status::Online), "error"); static_assert(mbgl::underlying_type(QMapbox::Offline) == mbgl::underlying_type(mbgl::NetworkStatus::Status::Offline), "error"); // mbgl::FeatureType static_assert(mbgl::underlying_type(QMapbox::Feature::PointType) == mbgl::underlying_type(mbgl::FeatureType::Point), "error"); static_assert(mbgl::underlying_type(QMapbox::Feature::LineStringType) == mbgl::underlying_type(mbgl::FeatureType::LineString), "error"); static_assert(mbgl::underlying_type(QMapbox::Feature::PolygonType) == mbgl::underlying_type(mbgl::FeatureType::Polygon), "error"); namespace QMapbox { Q_DECL_EXPORT NetworkMode networkMode() { return static_cast(mbgl::NetworkStatus::Get()); } Q_DECL_EXPORT void setNetworkMode(NetworkMode mode) { mbgl::NetworkStatus::Set(static_cast(mode)); } Q_DECL_EXPORT QList>& defaultStyles() { static QList> styles; if (styles.isEmpty()) { for (auto style : mbgl::util::default_styles::orderedStyles) { styles.append(QPair( QString::fromStdString(style.url), QString::fromStdString(style.name))); } } return styles; } Q_DECL_EXPORT void initializeGLExtensions() { mbgl::gl::InitializeExtensions([](const char* name) { #if QT_VERSION >= 0x050000 QOpenGLContext* thisContext = QOpenGLContext::currentContext(); return thisContext->getProcAddress(name); #else const QGLContext* thisContext = QGLContext::currentContext(); return reinterpret_cast(thisContext->getProcAddress(name)); #endif }); } }