mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Code cleanup
This commit is contained in:
parent
c5256b25e9
commit
c4915891e7
@ -33,3 +33,24 @@ CoordinateSystem::CoordinateSystem(int code)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const CoordinateSystem &cs)
|
||||
{
|
||||
QString ao;
|
||||
|
||||
switch (cs.axisOrder()) {
|
||||
case CoordinateSystem::XY:
|
||||
ao = "XY";
|
||||
break;
|
||||
case CoordinateSystem::YX:
|
||||
ao = "YX";
|
||||
break;
|
||||
default:
|
||||
ao = "Unknown";
|
||||
}
|
||||
|
||||
dbg.nospace() << "CoordinateSystem(" << ao << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
@ -1,12 +1,15 @@
|
||||
#ifndef COORDINATESYSTEM_H
|
||||
#define COORDINATESYSTEM_H
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
class CoordinateSystem
|
||||
{
|
||||
public:
|
||||
enum AxisOrder {Unknown, XY, YX};
|
||||
|
||||
CoordinateSystem() : _axisOrder(Unknown) {}
|
||||
CoordinateSystem(AxisOrder axisOrder) : _axisOrder(axisOrder) {}
|
||||
CoordinateSystem(int code);
|
||||
|
||||
bool isValid() const {return (_axisOrder != Unknown);}
|
||||
@ -17,4 +20,8 @@ private:
|
||||
AxisOrder _axisOrder;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const CoordinateSystem &cs);
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // COORDINATESYSTEM_H
|
||||
|
@ -15,11 +15,10 @@
|
||||
|
||||
MapSource::Config::Config() : type(TMS), zooms(ZOOM_MIN, ZOOM_MAX),
|
||||
bounds(Coordinates(BOUNDS_LEFT, BOUNDS_TOP), Coordinates(BOUNDS_RIGHT,
|
||||
BOUNDS_BOTTOM)), format("image/png"), axisOrder(CoordinateSystem::Unknown),
|
||||
rest(false) {}
|
||||
BOUNDS_BOTTOM)), format("image/png"), rest(false) {}
|
||||
|
||||
|
||||
static CoordinateSystem::AxisOrder axisOrder(QXmlStreamReader &reader)
|
||||
static CoordinateSystem coordinateSystem(QXmlStreamReader &reader)
|
||||
{
|
||||
QXmlStreamAttributes attr = reader.attributes();
|
||||
if (attr.value("axis") == "yx")
|
||||
@ -142,7 +141,7 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
||||
else if (reader.name() == "style")
|
||||
config.style = reader.readElementText();
|
||||
else if (reader.name() == "set") {
|
||||
config.axisOrder = axisOrder(reader);
|
||||
config.coordinateSystem = coordinateSystem(reader);
|
||||
config.set = reader.readElementText();
|
||||
} else if (reader.name() == "dimension") {
|
||||
QXmlStreamAttributes attr = reader.attributes();
|
||||
@ -152,7 +151,7 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
||||
config.dimensions.append(QPair<QString, QString>(
|
||||
attr.value("id").toString(), reader.readElementText()));
|
||||
} else if (reader.name() == "crs") {
|
||||
config.axisOrder = axisOrder(reader);
|
||||
config.coordinateSystem = coordinateSystem(reader);
|
||||
config.crs = reader.readElementText();
|
||||
} else if (reader.name() == "authorization") {
|
||||
QXmlStreamAttributes attr = reader.attributes();
|
||||
@ -224,11 +223,11 @@ Map *MapSource::loadFile(const QString &path)
|
||||
|
||||
if (config.type == WMTS)
|
||||
m = new WMTSMap(config.name, WMTS::Setup(config.url, config.layer,
|
||||
config.set, config.style, config.format, config.rest, config.axisOrder,
|
||||
config.dimensions, config.authorization));
|
||||
config.set, config.style, config.format, config.rest,
|
||||
config.coordinateSystem, config.dimensions, config.authorization));
|
||||
else if (config.type == WMS)
|
||||
m = new WMSMap(config.name, WMS::Setup(config.url, config.layer,
|
||||
config.style, config.format, config.crs, config.axisOrder,
|
||||
config.style, config.format, config.crs, config.coordinateSystem,
|
||||
config.authorization));
|
||||
else
|
||||
m = new OnlineMap(config.name, config.url, config.zooms, config.bounds);
|
||||
|
@ -34,7 +34,7 @@ private:
|
||||
QString set;
|
||||
QString format;
|
||||
QString crs;
|
||||
CoordinateSystem::AxisOrder axisOrder;
|
||||
CoordinateSystem coordinateSystem;
|
||||
bool rest;
|
||||
QList<QPair<QString, QString> > dimensions;
|
||||
Authorization authorization;
|
||||
|
@ -29,7 +29,7 @@ Projection::Method::Method(int id)
|
||||
}
|
||||
|
||||
Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
||||
_geographic(false)
|
||||
_cs(pcs->coordinateSystem()), _geographic(false)
|
||||
{
|
||||
const Ellipsoid *ellipsoid = _gcs->datum().ellipsoid();
|
||||
const Projection::Setup &setup = pcs->setup();
|
||||
@ -70,15 +70,12 @@ Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
||||
default:
|
||||
_ct = 0;
|
||||
}
|
||||
|
||||
_axisOrder = pcs->coordinateSystem().axisOrder();
|
||||
}
|
||||
|
||||
Projection::Projection(const GCS *gcs, CoordinateSystem::AxisOrder axisOrder)
|
||||
: _gcs(gcs), _axisOrder(axisOrder), _geographic(true)
|
||||
Projection::Projection(const GCS *gcs, const CoordinateSystem &cs)
|
||||
: _gcs(gcs), _units(LinearUnits(9001)), _cs(cs), _geographic(true)
|
||||
{
|
||||
_ct = new LatLon(gcs->angularUnits());
|
||||
_units = LinearUnits(9001);
|
||||
}
|
||||
|
||||
Projection::Projection(const Projection &p)
|
||||
@ -87,7 +84,7 @@ Projection::Projection(const Projection &p)
|
||||
_units = p._units;
|
||||
_ct = p._ct ? p._ct->clone() : 0;
|
||||
_geographic = p._geographic;
|
||||
_axisOrder = p._axisOrder;
|
||||
_cs = p._cs;
|
||||
}
|
||||
|
||||
Projection::~Projection()
|
||||
@ -101,7 +98,7 @@ Projection &Projection::operator=(const Projection &p)
|
||||
_units = p._units;
|
||||
_ct = p._ct ? p._ct->clone() : 0;
|
||||
_geographic = p._geographic;
|
||||
_axisOrder = p._axisOrder;
|
||||
_cs = p._cs;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ public:
|
||||
Projection() : _gcs(0), _ct(0), _geographic(false) {}
|
||||
Projection(const Projection &p);
|
||||
Projection(const PCS *pcs);
|
||||
Projection(const GCS *gcs, CoordinateSystem::AxisOrder axisOrder
|
||||
= CoordinateSystem::YX);
|
||||
Projection(const GCS *gcs, const CoordinateSystem &cs
|
||||
= CoordinateSystem(CoordinateSystem::YX));
|
||||
~Projection();
|
||||
|
||||
Projection &operator=(const Projection &p);
|
||||
@ -87,13 +87,13 @@ public:
|
||||
Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
const LinearUnits &units() const {return _units;}
|
||||
CoordinateSystem::AxisOrder axisOrder() const {return _axisOrder;}
|
||||
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
||||
|
||||
private:
|
||||
const GCS *_gcs;
|
||||
const CT *_ct;
|
||||
LinearUnits _units;
|
||||
CoordinateSystem::AxisOrder _axisOrder;
|
||||
CoordinateSystem _cs;
|
||||
bool _geographic;
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ void TileLoader::loadTilesSync(QList<Tile> &list)
|
||||
|
||||
if (t.pixmap().isNull()) {
|
||||
QString file = tileFile(t);
|
||||
if (QFileInfo(file).exists())
|
||||
if (QFileInfo::exists(file))
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ QString WMS::style(QXmlStreamReader &reader)
|
||||
|
||||
RectC WMS::geographicBoundingBox(QXmlStreamReader &reader)
|
||||
{
|
||||
qreal left, top, right, bottom;
|
||||
qreal left = NAN, top = NAN, right = NAN, bottom = NAN;
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "westBoundLongitude")
|
||||
@ -265,7 +265,7 @@ bool WMS::getCapabilities(const QString &url, const QString &file,
|
||||
if (_downloader->get(dl, authorization))
|
||||
wait.exec();
|
||||
|
||||
if (QFileInfo(file).exists())
|
||||
if (QFileInfo::exists(file))
|
||||
return true;
|
||||
else {
|
||||
_errorString = "Error downloading capabilities XML file";
|
||||
@ -278,7 +278,7 @@ WMS::WMS(const QString &file, const WMS::Setup &setup) : _valid(false)
|
||||
QString capaUrl = QString("%1?service=WMS&request=GetCapabilities")
|
||||
.arg(setup.url());
|
||||
|
||||
if (!QFileInfo(file).exists())
|
||||
if (!QFileInfo::exists(file))
|
||||
if (!getCapabilities(capaUrl, file, setup.authorization()))
|
||||
return;
|
||||
if (!parseCapabilities(file, setup))
|
||||
|
@ -19,10 +19,10 @@ public:
|
||||
public:
|
||||
Setup(const QString &url, const QString &layer, const QString &style,
|
||||
const QString &format, const QString &crs,
|
||||
CoordinateSystem::AxisOrder axisOrder,
|
||||
const Authorization &authorization = Authorization())
|
||||
: _url(url), _layer(layer), _style(style), _format(format), _crs(crs),
|
||||
_axisOrder(axisOrder), _authorization(authorization) {}
|
||||
const CoordinateSystem &cs, const Authorization &authorization
|
||||
= Authorization())
|
||||
: _url(url), _layer(layer), _style(style), _format(format),
|
||||
_crs(crs), _cs(cs), _authorization(authorization) {}
|
||||
|
||||
const QString &url() const {return _url;}
|
||||
const Authorization &authorization() const {return _authorization;}
|
||||
@ -30,7 +30,7 @@ public:
|
||||
const QString &style() const {return _style;}
|
||||
const QString &format() const {return _format;}
|
||||
const QString &crs() const {return _crs;}
|
||||
CoordinateSystem::AxisOrder axisOrder() const {return _axisOrder;}
|
||||
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
@ -38,7 +38,7 @@ public:
|
||||
QString _style;
|
||||
QString _format;
|
||||
QString _crs;
|
||||
CoordinateSystem::AxisOrder _axisOrder;
|
||||
CoordinateSystem _cs;
|
||||
Authorization _authorization;
|
||||
};
|
||||
|
||||
|
@ -87,12 +87,12 @@ bool WMSMap::loadWMS()
|
||||
_setup.authorization());
|
||||
|
||||
if (wms.version() >= "1.3.0") {
|
||||
if (_setup.axisOrder() == CoordinateSystem::Unknown)
|
||||
_axisOrder = _projection.axisOrder();
|
||||
if (_setup.coordinateSystem().axisOrder() == CoordinateSystem::Unknown)
|
||||
_cs = _projection.coordinateSystem();
|
||||
else
|
||||
_axisOrder = _setup.axisOrder();
|
||||
_cs = _setup.coordinateSystem();
|
||||
} else
|
||||
_axisOrder = CoordinateSystem::XY;
|
||||
_cs = CoordinateSystem::XY;
|
||||
|
||||
computeZooms(wms.scaleDenominator());
|
||||
updateTransform();
|
||||
@ -221,7 +221,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect)
|
||||
j * TILE_SIZE)));
|
||||
QPointF tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE
|
||||
- 1, j * TILE_SIZE + TILE_SIZE - 1)));
|
||||
QRectF bbox = (_axisOrder == CoordinateSystem::YX)
|
||||
QRectF bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||
? QRectF(QPointF(tbr.y(), tbr.x()), QPointF(ttl.y(), ttl.x()))
|
||||
: QRectF(ttl, tbr);
|
||||
|
||||
|
@ -61,10 +61,10 @@ private:
|
||||
TileLoader _tileLoader;
|
||||
Projection _projection;
|
||||
Transform _transform;
|
||||
CoordinateSystem _cs;
|
||||
QVector<qreal> _zooms;
|
||||
int _zoom;
|
||||
QRectF _boundingBox;
|
||||
CoordinateSystem::AxisOrder _axisOrder;
|
||||
int _zoom;
|
||||
bool _block;
|
||||
|
||||
bool _valid;
|
||||
|
@ -291,7 +291,7 @@ bool WMTS::getCapabilities(const QString &url, const QString &file,
|
||||
if (_downloader->get(dl, authorization))
|
||||
wait.exec();
|
||||
|
||||
if (QFileInfo(file).exists())
|
||||
if (QFileInfo::exists(file))
|
||||
return true;
|
||||
else {
|
||||
_errorString = "Error downloading capabilities XML file";
|
||||
@ -305,7 +305,7 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false)
|
||||
QString("%1?service=WMTS&Version=1.0.0&request=GetCapabilities")
|
||||
.arg(setup.url());
|
||||
|
||||
if (!QFileInfo(file).exists())
|
||||
if (!QFileInfo::exists(file))
|
||||
if (!getCapabilities(capaUrl, file, setup.authorization()))
|
||||
return;
|
||||
if (!parseCapabilities(file, setup))
|
||||
|
@ -21,11 +21,11 @@ public:
|
||||
public:
|
||||
Setup(const QString &url, const QString &layer, const QString &set,
|
||||
const QString &style, const QString &format, bool rest,
|
||||
CoordinateSystem::AxisOrder axisOrder,
|
||||
const CoordinateSystem &cs,
|
||||
const QList<QPair<QString, QString> > &dimensions,
|
||||
const Authorization &authorization = Authorization()) :
|
||||
_url(url), _layer(layer), _set(set), _style(style), _format(format),
|
||||
_rest(rest), _axisOrder(axisOrder), _dimensions(dimensions),
|
||||
const Authorization &authorization = Authorization())
|
||||
: _url(url), _layer(layer), _set(set), _style(style),
|
||||
_format(format), _rest(rest), _cs(cs), _dimensions(dimensions),
|
||||
_authorization(authorization) {}
|
||||
|
||||
const QString &url() const {return _url;}
|
||||
@ -35,7 +35,7 @@ public:
|
||||
const QString &style() const {return _style;}
|
||||
const QString &format() const {return _format;}
|
||||
bool rest() const {return _rest;}
|
||||
CoordinateSystem::AxisOrder axisOrder() const {return _axisOrder;}
|
||||
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
||||
const QList<QPair<QString, QString> > &dimensions() const
|
||||
{return _dimensions;}
|
||||
|
||||
@ -46,7 +46,7 @@ public:
|
||||
QString _style;
|
||||
QString _format;
|
||||
bool _rest;
|
||||
CoordinateSystem::AxisOrder _axisOrder;
|
||||
CoordinateSystem _cs;
|
||||
QList<QPair<QString, QString> > _dimensions;
|
||||
Authorization _authorization;
|
||||
};
|
||||
|
@ -26,10 +26,10 @@ bool WMTSMap::loadWMTS()
|
||||
_tileLoader = TileLoader(wmts.tileUrl(), tilesDir(),
|
||||
_setup.authorization());
|
||||
|
||||
if (_setup.axisOrder() == CoordinateSystem::Unknown)
|
||||
_axisOrder = _projection.axisOrder();
|
||||
if (_setup.coordinateSystem().axisOrder() == CoordinateSystem::Unknown)
|
||||
_cs = _projection.coordinateSystem();
|
||||
else
|
||||
_axisOrder = _setup.axisOrder();
|
||||
_cs = _setup.coordinateSystem();
|
||||
|
||||
updateTransform();
|
||||
|
||||
@ -72,7 +72,7 @@ void WMTSMap::updateTransform()
|
||||
const WMTS::Zoom &z = _zooms.at(_zoom);
|
||||
ReferencePoint tl, br;
|
||||
|
||||
QPointF topLeft = (_axisOrder == CoordinateSystem::YX)
|
||||
QPointF topLeft = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||
? QPointF(z.topLeft().y(), z.topLeft().x()) : z.topLeft();
|
||||
|
||||
qreal pixelSpan = sd2res(z.scaleDenominator());
|
||||
|
@ -60,8 +60,8 @@ private:
|
||||
QList<WMTS::Zoom> _zooms;
|
||||
Projection _projection;
|
||||
Transform _transform;
|
||||
CoordinateSystem _cs;
|
||||
int _zoom;
|
||||
CoordinateSystem::AxisOrder _axisOrder;
|
||||
bool _block;
|
||||
|
||||
bool _valid;
|
||||
|
Loading…
Reference in New Issue
Block a user