1 /***************************************************************************
2  *   Copyright (C) 2010 by Chris Browet                                    *
3  *   cbro@semperpax.com                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifndef CADASTREFRANCEADAPTER_H
21 #define CADASTREFRANCEADAPTER_H
22 
23 #include "IMapAdapterFactory.h"
24 #include "IMapAdapter.h"
25 
26 #include <QLocale>
27 
28 #include "city.h"
29 
30 class CadastreFranceAdapter : public IMapAdapter
31 {
32     Q_OBJECT
33     Q_INTERFACES(IMapAdapter)
34 
35 public:
36     CadastreFranceAdapter();
37     virtual ~CadastreFranceAdapter();
38 
39     //! returns the unique identifier (Uuid) of this MapAdapter
40     /*!
41      * @return  the unique identifier (Uuid) of this MapAdapter
42      */
43     virtual QUuid	getId		() const;
44 
45     //! returns the name of this MapAdapter
46     /*!
47      * @return  the name of this MapAdapter
48      */
49     virtual QString	getName		() const;
50 
51     //! returns the type of this MapAdapter
52     /*!
53      * @return  the type of this MapAdapter
54      */
55     virtual IMapAdapter::Type	getType		() const;
56 
57     //! returns the host of this MapAdapter
58     /*!
59      * @return  the host of this MapAdapter
60      */
61     virtual QString	getHost		() const;
62 
63     //! returns the size of the tiles
64     /*!
65      * @return the size of the tiles
66      */
67     virtual int		getTileSizeW	() const;
68     virtual int		getTileSizeH	() const;
69 
70     //! returns the min zoom value
71     /*!
72      * @return the min zoom value
73      */
74     virtual int 		getMinZoom	(const QRectF &) const;
75 
76     //! returns the max zoom value
77     /*!
78      * @return the max zoom value
79      */
80     virtual int		getMaxZoom	(const QRectF &) const;
81 
82     //! returns the current zoom
83     /*!
84      * @return the current zoom
85      */
86     virtual int 		getZoom		() const ;
87 
88     //! returns the source tag to be applied when drawing over this map
89     /*!
90      * @return the source tag
91      */
92     virtual QString	getSourceTag		() const;
setSourceTag(const QString &)93     virtual void setSourceTag (const QString& ) {};
94 
95     //! returns the Url of the usage license
96     /*!
97      * @return the Url of the usage license
98      */
getLicenseUrl()99     virtual QString	getLicenseUrl() const {return QString();}
100 
101     virtual int		getAdaptedZoom() const;
102     virtual int 	getAdaptedMinZoom(const QRectF &) const;
103     virtual int		getAdaptedMaxZoom(const QRectF &) const;
104 
105     virtual void	zoom_in();
106     virtual void	zoom_out();
107 
108     virtual bool	isValid(int, int, int) const;
109     virtual QString getQuery(int, int, int) const;
110     virtual QString getQuery(const QRectF& , const QRectF& , const QRect& ) const;
111     virtual QPixmap getPixmap(const QRectF& wgs84Bbox, const QRectF& projBbox, const QRect& size) const ;
112 
113     virtual QString projection() const;
114     virtual QRectF	getBoundingbox() const;
115 
116     virtual bool isTiled() const;
117     virtual int getTilesWE(int) const;
118     virtual int getTilesNS(int) const;
119 
120     virtual QMenu* getMenu() const;
121 
122     virtual IImageManager* getImageManager();
123     virtual void setImageManager(IImageManager* anImageManager);
124 
125     virtual void cleanup();
126 
127     virtual bool toXML(QXmlStreamWriter& stream);
128     virtual void fromXML(QXmlStreamReader& stream);
129     virtual QString toPropertiesHtml();
130 
131     virtual void setSettings(QSettings* aSet);
132 
133 public slots:
134     void onGrabCity();
135     void cityTriggered(QAction* act);
136     void toggleTiled();
137 
138 private slots:
139     void resultsAvailable(QMap<QString,QString> results);
140 
141 private:
142     QLocale loc;
143     IImageManager* theImageManager;
144 
145     QMenu* theMenu;
146     QSettings* theSettings;
147     QRectF theCoordBbox;
148 
149     int current_zoom;
150     int min_zoom;
151     int max_zoom;
152     QList<qreal> Resolutions;
153 
154     QString m_code;
155     QString m_department;
156     City m_city;
157 
158     bool m_isTiled;
159 
160 private:
161     void initializeCity(QString name);
162 
163 protected:
164     void updateMenu();
165 };
166 
167 class CadastreFranceAdapterFactory : public QObject, public IMapAdapterFactory
168 {
169     Q_OBJECT
Q_INTERFACES(IMapAdapterFactory)170     Q_INTERFACES(IMapAdapterFactory)
171 
172 public:
173     //! Creates an instance of the actual plugin
174     /*!
175      * @return  a pointer to the MapAdapter
176      */
177     IMapAdapter* CreateInstance() {return new CadastreFranceAdapter(); }
178 
179     //! returns the unique identifier (Uuid) of this MapAdapter
180     /*!
181      * @return  the unique identifier (Uuid) of this MapAdapter
182      */
183     virtual QUuid	getId		() const;
184 
185     //! returns the name of this MapAdapter
186     /*!
187      * @return  the name of this MapAdapter
188      */
189     virtual QString	getName		() const;
190 };
191 
192 #endif
193