Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
801 - 1
/*
2
*
3
* This file is part of QMapControl,
4
* an open-source cross-platform map widget
5
*
6
* Copyright (C) 2007 - 2008 Kai Winter
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
* GNU Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
20
*
21
* Contact e-mail: kaiwinter@gmx.de
22
* Program URL   : http://qmapcontrol.sourceforge.net/
23
*
24
*/
25
 
26
#ifndef MAPADAPTER_H
27
#define MAPADAPTER_H
28
 
29
#include <QObject>
30
#include <QSize>
31
#include <QPoint>
32
#include <QPointF>
33
#include <QLocale>
34
#include <QDebug>
35
#include <cmath>
36
 
37
namespace qmapcontrol
38
{
39
    //! Used to fit map servers into QMapControl
40
    /*!
41
     * MapAdapters are needed to convert between world- and display coordinates.
42
     * This calculations depend on the used map projection.
43
     * There are two ready-made MapAdapters:
44
     *  - TileMapAdapter, which is ready to use for OpenStreetMap or Google (Mercator projection)
45
     *  - WMSMapAdapter, which could be used for the most WMS-Server (some servers show errors, because of image ratio)
46
     *
47
     * MapAdapters are also needed to form the HTTP-Queries to load the map tiles.
48
     * The maps from WMS Servers are also divided into tiles, because those can be better cached.
49
     *
50
     * @see TileMapAdapter, @see WMSMapAdapter
51
     *
52
     *  @author Kai Winter <kaiwinter@gmx.de>
53
     */
54
    class MapAdapter : public QObject
55
    {
56
        friend class Layer;
57
 
58
        Q_OBJECT
59
 
60
    public:
61
        virtual ~MapAdapter();
62
 
63
        //! returns the host of this MapAdapter
64
        /*!
65
         * @return  the host of this MapAdapter
66
         */
67
        QString host() const;
68
 
69
        //! returns the size of the tiles
70
        /*!
71
         * @return the size of the tiles
72
         */
73
        int tilesize() const;
74
 
75
        //! returns the min zoom value
76
        /*!
77
         * @return the min zoom value
78
         */
79
        int minZoom() const;
80
 
81
        //! returns the max zoom value
82
        /*!
83
         * @return the max zoom value
84
         */
85
        int maxZoom() const;
86
 
87
        //! returns the current zoom
88
        /*!
89
         * @return the current zoom
90
         */
91
        int currentZoom() const;
92
 
93
        virtual int adaptedZoom()const;
94
 
95
        //! translates a world coordinate to display coordinate
96
        /*!
97
         * The calculations also needs the current zoom. The current zoom is managed by the MapAdapter, so this is no problem.
98
         * To divide model from view the current zoom should be moved to the layers.
99
         * @param  coordinate the world coordinate
100
         * @return the display coordinate (in widget coordinates)
101
         */
102
        virtual QPoint coordinateToDisplay(const QPointF& coordinate) const = 0;
103
 
104
        //! translates display coordinate to world coordinate
105
        /*!
106
         * The calculations also needs the current zoom. The current zoom is managed by the MapAdapter, so this is no problem.
107
         * To divide model from view the current zoom should be moved to the layers.
108
         * @param  point the display coordinate
109
         * @return the world coordinate
110
         */
111
        virtual QPointF displayToCoordinate(const QPoint& point) const = 0;
112
 
113
    protected:
114
        MapAdapter(const QString& host, const QString& serverPath, int tilesize, int minZoom = 0, int maxZoom = 0);
115
        virtual void zoom_in() = 0;
116
        virtual void zoom_out() = 0;
117
        virtual bool isValid(int x, int y, int z) const = 0;
118
        virtual QString query(int x, int y, int z) const = 0;
119
 
120
        QSize   size;
121
        QString myhost;
122
        QString serverPath;
123
        int mytilesize;
124
        int min_zoom;
125
        int max_zoom;
126
        int current_zoom;
127
 
128
        int param1;
129
        int param2;
130
        int param3;
131
        int param4;
132
        int param5;
133
        int param6;
134
 
135
        QString sub1;
136
        QString sub2;
137
        QString sub3;
138
        QString sub4;
139
        QString sub5;
140
        QString sub6;
141
 
142
        int order[3][2];
143
 
144
        int middle_x;
145
        int middle_y;
146
 
147
        qreal numberOfTiles;
148
        QLocale loc;
149
    };
150
}
151
#endif