mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Added support for Geographic 2D projections (coordinate systems) in vector maps
This commit is contained in:
@ -27,7 +27,7 @@ public:
|
||||
~GraphView();
|
||||
|
||||
bool isEmpty() const {return _graphs.isEmpty();}
|
||||
const QList<KV> &info() const {return _info->info();}
|
||||
const QList<KV<QString, QString> > &info() const {return _info->info();}
|
||||
void clear();
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
||||
|
@ -1066,7 +1066,7 @@ void GUI::statistics()
|
||||
|
||||
text.append("<tr><th colspan=\"2\">" + tab->label() + "</th></tr>");
|
||||
for (int j = 0; j < tab->info().size(); j++) {
|
||||
const KV &kv = tab->info().at(j);
|
||||
const KV<QString, QString> &kv = tab->info().at(j);
|
||||
text.append("<tr><td>" + kv.key() + ":</td><td>" + kv.value()
|
||||
+ "</td></tr>");
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ void InfoItem::updateBoundingRect()
|
||||
QFontMetrics fm(_font);
|
||||
qreal width = 0;
|
||||
|
||||
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||
for (QList<KV<QString, QString> >::const_iterator i = _list.constBegin();
|
||||
i != _list.constEnd(); i++) {
|
||||
width += fm.width(i->key() + ": ");
|
||||
width += fm.width(i->value()) + ((i == _list.constEnd() - 1)
|
||||
@ -37,7 +37,7 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->setFont(_font);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
for (QList<KV>::const_iterator i = _list.constBegin();
|
||||
for (QList<KV<QString, QString> >::const_iterator i = _list.constBegin();
|
||||
i != _list.constEnd(); i++) {
|
||||
painter->drawText(width, fm.height() - fm.descent(), i->key() + ": ");
|
||||
width += fm.width(i->key() + ": ");
|
||||
@ -61,7 +61,7 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
|
||||
void InfoItem::insert(const QString &key, const QString &value)
|
||||
{
|
||||
KV kv(key, value);
|
||||
KV<QString, QString> kv(key, value);
|
||||
int i;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QList<KV> &info() const {return _list;}
|
||||
const QList<KV<QString, QString> > &info() const {return _list;}
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void clear();
|
||||
@ -23,7 +23,7 @@ public:
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
QList<KV> _list;
|
||||
QList<KV<QString, QString> > _list;
|
||||
QRectF _boundingRect;
|
||||
QFont _font;
|
||||
};
|
||||
|
@ -255,17 +255,18 @@ QPointF MapView::contentCenter() const
|
||||
|
||||
void MapView::updatePOIVisibility()
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it, jt;
|
||||
|
||||
if (!_showPOI)
|
||||
return;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->show();
|
||||
|
||||
if (!_overlapPOIs) {
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (jt = _pois.constBegin(); jt != _pois.constEnd(); jt++) {
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++) {
|
||||
for (POIHash::const_iterator jt = _pois.constBegin();
|
||||
jt != _pois.constEnd(); jt++) {
|
||||
if (it.value()->isVisible() && jt.value()->isVisible()
|
||||
&& it != jt && it.value()->collidesWithItem(jt.value()))
|
||||
jt.value()->hide();
|
||||
@ -288,8 +289,8 @@ void MapView::rescale()
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setMap(_map);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setMap(_map);
|
||||
|
||||
updatePOIVisibility();
|
||||
@ -339,8 +340,8 @@ void MapView::setMap(Map *map)
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setMap(map);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setMap(_map);
|
||||
updatePOIVisibility();
|
||||
|
||||
@ -364,12 +365,10 @@ void MapView::setPOI(POI *poi)
|
||||
|
||||
void MapView::updatePOI()
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
_scene->removeItem(it.value());
|
||||
delete it.value();
|
||||
}
|
||||
qDeleteAll(_pois);
|
||||
_pois.clear();
|
||||
|
||||
if (_showTracks)
|
||||
@ -426,8 +425,8 @@ void MapView::setUnits(Units units)
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setToolTipFormat(_units, _coordinatesFormat);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
|
||||
@ -445,8 +444,8 @@ void MapView::setCoordinatesFormat(CoordinatesFormat format)
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes[i]->setCoordinatesFormat(_coordinatesFormat);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setToolTipFormat(_units, _coordinatesFormat);
|
||||
}
|
||||
|
||||
@ -461,8 +460,6 @@ void MapView::clearMapCache()
|
||||
|
||||
void MapView::digitalZoom(int zoom)
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
if (zoom) {
|
||||
_digitalZoom += zoom;
|
||||
scale(pow(2, zoom), pow(2, zoom));
|
||||
@ -479,7 +476,8 @@ void MapView::digitalZoom(int zoom)
|
||||
_areas.at(i)->setDigitalZoom(_digitalZoom);
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setDigitalZoom(_digitalZoom);
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setDigitalZoom(_digitalZoom);
|
||||
|
||||
_mapScale->setDigitalZoom(_digitalZoom);
|
||||
@ -747,8 +745,8 @@ void MapView::showPOI(bool show)
|
||||
{
|
||||
_showPOI = show;
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setVisible(show);
|
||||
|
||||
updatePOIVisibility();
|
||||
@ -758,8 +756,8 @@ void MapView::showPOILabels(bool show)
|
||||
{
|
||||
_showPOILabels = show;
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->showLabel(show);
|
||||
|
||||
updatePOIVisibility();
|
||||
@ -852,21 +850,19 @@ void MapView::setWaypointColor(const QColor &color)
|
||||
|
||||
void MapView::setPOISize(int size)
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
_poiSize = size;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setSize(size);
|
||||
}
|
||||
|
||||
void MapView::setPOIColor(const QColor &color)
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
_poiColor = color;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setColor(color);
|
||||
}
|
||||
|
||||
@ -1003,8 +999,8 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setMap(_map);
|
||||
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
for (POIHash::const_iterator it = _pois.constBegin();
|
||||
it != _pois.constEnd(); it++)
|
||||
it.value()->setMap(_map);
|
||||
updatePOIVisibility();
|
||||
|
||||
@ -1021,13 +1017,19 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||
|
||||
void MapView::setProjection(int id)
|
||||
{
|
||||
Projection projection(PCS::pcs(id));
|
||||
if (!projection.isValid())
|
||||
return;
|
||||
|
||||
_projection = projection;
|
||||
|
||||
Coordinates center = _map->xy2ll(mapToScene(viewport()->rect().center()));
|
||||
|
||||
const PCS *pcs = PCS::pcs(id);
|
||||
if (pcs)
|
||||
_projection = Projection(pcs);
|
||||
else {
|
||||
const GCS *gcs = GCS::gcs(id);
|
||||
if (gcs)
|
||||
_projection = Projection(gcs);
|
||||
else
|
||||
qWarning("%d: Unknown PCS/GCS id", id);
|
||||
}
|
||||
|
||||
_map->setProjection(_projection);
|
||||
rescale();
|
||||
centerOn(_map->ll2xy(center));
|
||||
|
@ -92,6 +92,8 @@ private slots:
|
||||
void reloadMap();
|
||||
|
||||
private:
|
||||
typedef QHash<SearchPointer<Waypoint>, WaypointItem*> POIHash;
|
||||
|
||||
PathItem *addTrack(const Track &track);
|
||||
PathItem *addRoute(const Route &route);
|
||||
void addArea(const Area &area);
|
||||
@ -125,7 +127,7 @@ private:
|
||||
QList<RouteItem*> _routes;
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QList<AreaItem*> _areas;
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*> _pois;
|
||||
POIHash _pois;
|
||||
|
||||
RectC _tr, _rr, _wr, _ar;
|
||||
qreal _res;
|
||||
|
@ -36,15 +36,18 @@ static QFrame *line()
|
||||
}
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
|
||||
QWidget *OptionsDialog::createMapPage()
|
||||
{
|
||||
_projection = new LimitedComboBox(200);
|
||||
QList<PCS::Info> projections(PCS::pcsList());
|
||||
|
||||
QList<KV<int, QString> > projections(GCS::list() + PCS::list());
|
||||
qSort(projections);
|
||||
|
||||
for (int i = 0; i < projections.size(); i++) {
|
||||
QString text = QString::number(projections.at(i).id()) + " - "
|
||||
+ projections.at(i).name();
|
||||
_projection->addItem(text, QVariant(projections.at(i).id()));
|
||||
QString text = QString::number(projections.at(i).key()) + " - "
|
||||
+ projections.at(i).value();
|
||||
_projection->addItem(text, QVariant(projections.at(i).key()));
|
||||
}
|
||||
_projection->setCurrentIndex(_projection->findData(_options->projection));
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
void ToolTip::insert(const QString &key, const QString &value)
|
||||
{
|
||||
_list.append(KV(key, value));
|
||||
_list.append(KV<QString, QString>(key, value));
|
||||
}
|
||||
|
||||
QString ToolTip::toString() const
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
QString toString() const;
|
||||
|
||||
private:
|
||||
QList<KV> _list;
|
||||
QList<KV<QString, QString> > _list;
|
||||
ImageInfo _img;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user