summaryrefslogtreecommitdiffstats
path: root/examples/demos/osmbuildings/manager.h
blob: 57ced4f117394a8587ed92ac1d7844365cee0b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef OSMMANAGER_H
#define OSMMANAGER_H

#include <QQuick3DTextureData>
#include <QtQmlIntegration>
#include <QVector3D>
#include "request.h"

class OSMManager : public QObject
{
    Q_OBJECT
    QML_ELEMENT

public:
    explicit OSMManager(QObject *parent = nullptr);
    int tileSizeX() const;
    int tileSizeY() const;
    Q_INVOKABLE bool isDemoToken() const;
    Q_INVOKABLE void setToken(const QString &token);
    Q_INVOKABLE QString token() const;

public slots:
    void setCameraProperties(const QVector3D &position , const QVector3D &right,
                            float cameraZoom, float minimunZoom, float maximumZoom,
                            float cameraTilt, float minimumTilt, float maxmumTilt);

signals:
    void buildingsDataReady(const QList<QVariant> &geoVariantsList, int tileX, int tileY, int zoomLevel);
    void mapsDataReady(class QByteArray mapData, int tileX, int tileY, int zoomLevel);

private:
    void addBuildingRequestToQueue(QQueue<OSMTileData> &queue, int tileX, int tileY, int zoomLevel = 15);
    class OSMRequest *m_request = nullptr;
    QHash<OSMTileData, bool> m_buildingsHash;
    const int m_startBuildingTileX = 17605;
    const int m_startBuildingTileY = 10746;
    const int m_tileSizeX = 37;
    const int m_tileSizeY = 37;

    Q_PROPERTY(int tileSizeX READ tileSizeX CONSTANT FINAL)
    Q_PROPERTY(int tileSizeY READ tileSizeY CONSTANT FINAL)
};

class CustomTextureData : public QQuick3DTextureData
{
    Q_OBJECT
    QML_ELEMENT
public slots:
    void setImageData(const QByteArray &data );
};


#endif // MANAGER_H