You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.1 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef MAPADAPTER_H
  26. #define MAPADAPTER_H
  27. #include "qmapcontrol_global.h"
  28. #include <QtCore/QObject>
  29. #include <QtCore/QSize>
  30. #include <QtCore/QPoint>
  31. #include <QtCore/QPointF>
  32. #include <QtCore/QRectF>
  33. #include <QtCore/QLocale>
  34. #include <QtCore/QDebug>
  35. #ifndef M_E
  36. #include <cmath>
  37. #endif
  38. //! Used to fit map servers into QMapControl
  39. /*!
  40. * MapAdapters are needed to convert between world- and display coordinates.
  41. * This calculations depend on the used map projection.
  42. * There are two ready-made MapAdapters:
  43. * - TileMapAdapter, which is ready to use for OpenStreetMap or Google (Mercator projection)
  44. * - WMSMapAdapter, which could be used for the most WMS-Server (some servers show errors, because of image ratio)
  45. *
  46. * MapAdapters are also needed to form the HTTP-Queries to load the map tiles.
  47. * The maps from WMS Servers are also divided into tiles, because those can be better cached.
  48. *
  49. * @see TileMapAdapter, @see WMSMapAdapter
  50. *
  51. * @author Kai Winter <kaiwinter@gmx.de>
  52. */
  53. class MapAdapter : public QObject {
  54. friend class Layer;
  55. //Q_OBJECT
  56. public:
  57. virtual ~MapAdapter();
  58. //! returns the host of this MapAdapter
  59. /*!
  60. * @return the host of this MapAdapter
  61. */
  62. QString host() const;
  63. //! returns the server path part of this MapAdapter
  64. /*!
  65. * @return the serverpath of this MapAdapter
  66. */
  67. virtual QString serverPath() const;
  68. //! change or update server host address post init
  69. /*!
  70. * @param host the host address
  71. * @param serverPath the server path
  72. */
  73. virtual void changeHostAddress( const QString qHost, const QString qServerPath = QString() );
  74. //! returns the size of the tiles
  75. /*!
  76. * @return the size of the tiles
  77. */
  78. int tilesize() const;
  79. //! returns the min zoom value
  80. /*!
  81. * @return the min zoom value
  82. */
  83. int minZoom() const;
  84. //! returns the max zoom value
  85. /*!
  86. * @return the max zoom value
  87. */
  88. int maxZoom() const;
  89. //! returns the current zoom
  90. /*!
  91. * @return the current zoom
  92. */
  93. int currentZoom() const;
  94. virtual int adaptedZoom()const;
  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. //! translates display coordinate to world coordinate
  104. /*!
  105. * The calculations also needs the current zoom. The current zoom is managed by the MapAdapter, so this is no problem.
  106. * To divide model from view the current zoom should be moved to the layers.
  107. * @param point the display coordinate
  108. * @return the world coordinate
  109. */
  110. virtual QPointF displayToCoordinate(const QPoint& point) const = 0;
  111. QRectF getBoundingbox() const { return mBoundingBox; }
  112. void setBoundingBox(qreal qMinX, qreal qMinY, qreal qMaxX, qreal qMaxY );
  113. //! returns the tilesize for the mapadapter
  114. /*!
  115. * returns the tilesize for the mapadapter
  116. * @return the tile size
  117. */
  118. int tileSize();
  119. protected:
  120. MapAdapter(const QString& qHost, const QString& qServerPath, int qTilesize, int qMinZoom = 0, int qMaxZoom = 0);
  121. virtual void zoom_in() = 0;
  122. virtual void zoom_out() = 0;
  123. virtual bool isTileValid(int x, int y, int z) const = 0;
  124. virtual QString query(int x, int y, int z) const = 0;
  125. QSize mSize;
  126. QString mServerHost;
  127. QString mServerPath;
  128. int mTileSize;
  129. int mMin_zoom;
  130. int mMax_zoom;
  131. int mCurrent_zoom;
  132. int param1;
  133. int param2;
  134. int param3;
  135. int param4;
  136. int param5;
  137. int param6;
  138. QString sub1;
  139. QString sub2;
  140. QString sub3;
  141. QString sub4;
  142. QString sub5;
  143. QString sub6;
  144. int order[3][2];
  145. int mMiddle_x;
  146. int mMiddle_y;
  147. qreal mNumberOfTiles;
  148. QLocale loc;
  149. QRectF mBoundingBox;
  150. };
  151. #endif