mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-07 12:05:14 +01:00
Added support for geographic2d "projected" WMTS maps
This commit is contained in:
parent
10aa7d3945
commit
619df591e2
@ -25,7 +25,6 @@ public:
|
|||||||
Coordinates toWGS84(const Coordinates &c) const;
|
Coordinates toWGS84(const Coordinates &c) const;
|
||||||
Coordinates fromWGS84(const Coordinates &c) const;
|
Coordinates fromWGS84(const Coordinates &c) const;
|
||||||
|
|
||||||
|
|
||||||
static const GCS *gcs(int id);
|
static const GCS *gcs(int id);
|
||||||
static const GCS *gcs(int geodeticDatum, int primeMeridian,
|
static const GCS *gcs(int geodeticDatum, int primeMeridian,
|
||||||
int angularUnits);
|
int angularUnits);
|
||||||
|
@ -27,7 +27,7 @@ Projection::Method::Method(int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Projection::Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
Projection::Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
||||||
const LinearUnits &units) : _gcs(gcs), _units(units)
|
const LinearUnits &units) : _gcs(gcs), _units(units), _geographic(false)
|
||||||
{
|
{
|
||||||
const Ellipsoid *ellipsoid = _gcs->datum().ellipsoid();
|
const Ellipsoid *ellipsoid = _gcs->datum().ellipsoid();
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ Projection::Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Projection::Projection(const GCS *gcs) : _gcs(gcs)
|
Projection::Projection(const GCS *gcs) : _gcs(gcs), _geographic(true)
|
||||||
{
|
{
|
||||||
_ct = new LatLon(gcs->angularUnits());
|
_ct = new LatLon(gcs->angularUnits());
|
||||||
_units = LinearUnits(9001);
|
_units = LinearUnits(9001);
|
||||||
@ -79,6 +79,7 @@ Projection::Projection(const Projection &p)
|
|||||||
_gcs = p._gcs;
|
_gcs = p._gcs;
|
||||||
_units = p._units;
|
_units = p._units;
|
||||||
_ct = p._ct->clone();
|
_ct = p._ct->clone();
|
||||||
|
_geographic = p._geographic;
|
||||||
}
|
}
|
||||||
|
|
||||||
Projection::~Projection()
|
Projection::~Projection()
|
||||||
@ -91,6 +92,7 @@ Projection &Projection::operator=(const Projection &p)
|
|||||||
_gcs = p._gcs;
|
_gcs = p._gcs;
|
||||||
_units = p._units;
|
_units = p._units;
|
||||||
_ct = p._ct->clone();
|
_ct = p._ct->clone();
|
||||||
|
_geographic = p._geographic;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
int _id;
|
int _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
Projection() : _gcs(0), _ct(0) {}
|
Projection() : _gcs(0), _ct(0), _geographic(false) {}
|
||||||
Projection(const Projection &p);
|
Projection(const Projection &p);
|
||||||
Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
Projection(const GCS *gcs, const Method &method, const Setup &setup,
|
||||||
const LinearUnits &units);
|
const LinearUnits &units);
|
||||||
@ -79,6 +79,7 @@ public:
|
|||||||
|
|
||||||
bool isNull() const {return (_gcs == 0 && _ct == 0 && _units.isNull());}
|
bool isNull() const {return (_gcs == 0 && _ct == 0 && _units.isNull());}
|
||||||
bool isValid() const {return (_gcs == 0 || _ct == 0 || _units.isNull());}
|
bool isValid() const {return (_gcs == 0 || _ct == 0 || _units.isNull());}
|
||||||
|
bool isGeographic() const {return _geographic;}
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
Coordinates xy2ll(const QPointF &p) const;
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
@ -89,6 +90,7 @@ private:
|
|||||||
const GCS * _gcs;
|
const GCS * _gcs;
|
||||||
CT *_ct;
|
CT *_ct;
|
||||||
LinearUnits _units;
|
LinearUnits _units;
|
||||||
|
bool _geographic;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
|
@ -15,7 +15,10 @@ bool WMTS::createProjection(const QString &crs)
|
|||||||
{
|
{
|
||||||
QStringList list(crs.split(':'));
|
QStringList list(crs.split(':'));
|
||||||
QString authority, code;
|
QString authority, code;
|
||||||
|
bool res;
|
||||||
|
int epsg;
|
||||||
const PCS *pcs;
|
const PCS *pcs;
|
||||||
|
const GCS *gcs;
|
||||||
|
|
||||||
switch (list.size()) {
|
switch (list.size()) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -32,12 +35,19 @@ bool WMTS::createProjection(const QString &crs)
|
|||||||
|
|
||||||
if (authority != "EPSG")
|
if (authority != "EPSG")
|
||||||
return false;
|
return false;
|
||||||
if (!(pcs = PCS::pcs(code.toInt())))
|
epsg = code.toInt(&res);
|
||||||
|
if (!res)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ((pcs = PCS::pcs(epsg))) {
|
||||||
_projection = Projection(pcs->gcs(), pcs->method(), pcs->setup(),
|
_projection = Projection(pcs->gcs(), pcs->method(), pcs->setup(),
|
||||||
pcs->units());
|
pcs->units());
|
||||||
return true;
|
return true;
|
||||||
|
} else if ((gcs = GCS::gcs(epsg))) {
|
||||||
|
_projection = Projection(gcs);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMTS::tileMatrix(QXmlStreamReader &reader)
|
void WMTS::tileMatrix(QXmlStreamReader &reader)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
|
#include "common/wgs84.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "wmts.h"
|
#include "wmts.h"
|
||||||
@ -47,6 +48,8 @@ void WMTSMap::updateTransform()
|
|||||||
ReferencePoint tl, br;
|
ReferencePoint tl, br;
|
||||||
|
|
||||||
qreal pixelSpan = sd2res(z.scaleDenominator);
|
qreal pixelSpan = sd2res(z.scaleDenominator);
|
||||||
|
if (_projection.isGeographic())
|
||||||
|
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||||
QPointF tileSpan(z.tile.width() * pixelSpan, z.tile.height() * pixelSpan);
|
QPointF tileSpan(z.tile.width() * pixelSpan, z.tile.height() * pixelSpan);
|
||||||
QPointF bottomRight(z.topLeft.x() + tileSpan.x() * z.matrix.width(),
|
QPointF bottomRight(z.topLeft.x() + tileSpan.x() * z.matrix.width(),
|
||||||
z.topLeft.y() - tileSpan.y() * z.matrix.height());
|
z.topLeft.y() - tileSpan.y() * z.matrix.height());
|
||||||
@ -115,6 +118,8 @@ qreal WMTSMap::zoomFit(const QSize &size, const RectC &br)
|
|||||||
_projection.ll2xy(br.bottomRight()));
|
_projection.ll2xy(br.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
qreal resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
qreal resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
||||||
|
if (_projection.isGeographic())
|
||||||
|
resolution *= deg2rad(WGS84_RADIUS);
|
||||||
|
|
||||||
for (int i = 0; i < _zooms.size(); i++) {
|
for (int i = 0; i < _zooms.size(); i++) {
|
||||||
if (sd2res(_zooms.at(i).scaleDenominator) < resolution)
|
if (sd2res(_zooms.at(i).scaleDenominator) < resolution)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user