mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Make the WMS tile size configurable
This commit is contained in:
parent
45a6cdeda0
commit
521369a6ec
@ -300,7 +300,7 @@ Map *MapSource::loadMap(const QString &path, QString &errorString)
|
|||||||
case WMS:
|
case WMS:
|
||||||
return new WMSMap(config.name, WMS::Setup(config.url, config.layer,
|
return new WMSMap(config.name, WMS::Setup(config.url, config.layer,
|
||||||
config.style, config.format, config.crs, config.coordinateSystem,
|
config.style, config.format, config.crs, config.coordinateSystem,
|
||||||
config.dimensions, config.authorization));
|
config.dimensions, config.authorization), config.tileSize);
|
||||||
case TMS:
|
case TMS:
|
||||||
return new OnlineMap(config.name, config.url, config.zooms,
|
return new OnlineMap(config.name, config.url, config.zooms,
|
||||||
config.bounds, config.tileRatio, config.authorization,
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define CAPABILITIES_FILE "capabilities.xml"
|
#define CAPABILITIES_FILE "capabilities.xml"
|
||||||
#define TILE_SIZE 256
|
|
||||||
#define EPSILON 1e-6
|
#define EPSILON 1e-6
|
||||||
|
|
||||||
double WMSMap::sd2res(double scaleDenominator) const
|
double WMSMap::sd2res(double scaleDenominator) const
|
||||||
@ -25,7 +24,7 @@ QString WMSMap::tileUrl(const QString &version) const
|
|||||||
url = QString("%1%2version=%3&request=GetMap&bbox=$bbox"
|
url = QString("%1%2version=%3&request=GetMap&bbox=$bbox"
|
||||||
"&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true")
|
"&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true")
|
||||||
.arg(_setup.url(), _setup.url().contains('?') ? "&" : "?", version,
|
.arg(_setup.url(), _setup.url().contains('?') ? "&" : "?", version,
|
||||||
QString::number(TILE_SIZE), QString::number(TILE_SIZE), _setup.layer(),
|
QString::number(_tileSize), QString::number(_tileSize), _setup.layer(),
|
||||||
_setup.style(), _setup.format());
|
_setup.style(), _setup.format());
|
||||||
|
|
||||||
if (version >= "1.3.0")
|
if (version >= "1.3.0")
|
||||||
@ -100,9 +99,9 @@ bool WMSMap::loadWMS()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WMSMap::WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent)
|
WMSMap::WMSMap(const QString &name, const WMS::Setup &setup, int tileSize,
|
||||||
: Map(parent), _name(name), _setup(setup), _tileLoader(0), _zoom(0),
|
QObject *parent) : Map(parent), _name(name), _setup(setup), _tileLoader(0),
|
||||||
_mapRatio(1.0), _valid(false)
|
_zoom(0), _tileSize(tileSize), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
_tileLoader = new TileLoader(tilesDir(), this);
|
_tileLoader = new TileLoader(tilesDir(), this);
|
||||||
_tileLoader->setAuthorization(_setup.authorization());
|
_tileLoader->setAuthorization(_setup.authorization());
|
||||||
@ -180,7 +179,7 @@ Coordinates WMSMap::xy2ll(const QPointF &p)
|
|||||||
|
|
||||||
qreal WMSMap::tileSize() const
|
qreal WMSMap::tileSize() const
|
||||||
{
|
{
|
||||||
return (TILE_SIZE / _mapRatio);
|
return (_tileSize / _mapRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
@ -194,10 +193,10 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
tiles.reserve((br.x() - tl.x()) * (br.y() - tl.y()));
|
||||||
for (int i = tl.x(); i < br.x(); i++) {
|
for (int i = tl.x(); i < br.x(); i++) {
|
||||||
for (int j = tl.y(); j < br.y(); j++) {
|
for (int j = tl.y(); j < br.y(); j++) {
|
||||||
PointD ttl(_transform.img2proj(QPointF(i * TILE_SIZE,
|
PointD ttl(_transform.img2proj(QPointF(i * _tileSize,
|
||||||
j * TILE_SIZE)));
|
j * _tileSize)));
|
||||||
PointD tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE,
|
PointD tbr(_transform.img2proj(QPointF(i * _tileSize + _tileSize,
|
||||||
j * TILE_SIZE + TILE_SIZE)));
|
j * _tileSize + _tileSize)));
|
||||||
RectD bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
RectD bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||||
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
||||||
: RectD(ttl, tbr);
|
: RectD(ttl, tbr);
|
||||||
|
@ -14,7 +14,8 @@ class WMSMap : public Map
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent = 0);
|
WMSMap(const QString &name, const WMS::Setup &setup, int tileSize,
|
||||||
|
QObject *parent = 0);
|
||||||
|
|
||||||
QString name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ private:
|
|||||||
RectC _bbox;
|
RectC _bbox;
|
||||||
RectD _bounds;
|
RectD _bounds;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
|
int _tileSize;
|
||||||
qreal _mapRatio;
|
qreal _mapRatio;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user