From 58b4c87d46078dbe2b8289017fad6da82380c2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 6 May 2017 00:53:39 +0200 Subject: [PATCH] Fixed broken southern hemisphere reference points conversion Fixed broken UTM zone setup Added New Zealand TM 2000 "projection" support --- src/offlinemap.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/offlinemap.cpp b/src/offlinemap.cpp index 49fe1093..cb4dd0de 100644 --- a/src/offlinemap.cpp +++ b/src/offlinemap.cpp @@ -100,14 +100,18 @@ int OfflineMap::parse(QIODevice &device, QList &points, qreal lonm = list.at(10).trimmed().toFloat(&res); if (!res) ll = false; - if (ll && list.at(8).trimmed() == "S") + if (ll && list.at(8).trimmed() == "S") { latd = -latd; - if (ll && list.at(11).trimmed() == "W") + latm = -latm; + } + if (ll && list.at(11).trimmed() == "W") { lond = -lond; + lonm = -lonm; + } - int zone = list.at(13).trimmed().toInt(&res); + setup.zone = list.at(13).trimmed().toInt(&res); if (!res) - zone = 0; + setup.zone = 0; qreal ppx = list.at(14).trimmed().toFloat(&res); if (!res) pp = false; @@ -115,7 +119,7 @@ int OfflineMap::parse(QIODevice &device, QList &points, if (!res) pp = false; if (list.at(16).trimmed() == "S") - zone = -zone; + setup.zone = -setup.zone; ReferencePoint p; p.xy = QPoint(x, y); @@ -127,7 +131,6 @@ int OfflineMap::parse(QIODevice &device, QList &points, return ln; } else if (pp) { p.pp = QPointF(ppx, ppy); - setup.zone = zone; points.append(p); } else return ln; @@ -242,7 +245,10 @@ bool OfflineMap::createProjection(const QString &datum, _errorString = "Can not determine UTM zone"; return false; } - } else { + } else if (projection == "(NZTM2) New Zealand TM 2000") + _projection = new TransverseMercator(d.ellipsoid(), 173.0, 0.9996, + 1600000, 10000000); + else { _errorString = QString("%1: Unknown map projection").arg(projection); return false; }