mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-16 20:04:23 +02:00
Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
a1e10c395a | |||
c97561add4 | |||
d994fae4ce | |||
789606cf86 | |||
542b3e920e | |||
0248ecb254 | |||
acc9d07a22 | |||
7860ce8acc | |||
2541797e7d | |||
e13d6dfc4b | |||
9e1e960c93 | |||
d18537733f | |||
c6a37594ae | |||
bcfd51276f | |||
aed09a0e6a | |||
867b70d159 | |||
0b05079a49 | |||
ca71eb9d93 | |||
4a82055867 | |||
f9b4cd991f | |||
14dc2af877 | |||
9380f31022 | |||
5f76427ba4 | |||
d4b731aeaf | |||
3d27b4ea00 | |||
502a7b4129 | |||
6f32c73684 | |||
829d85a70a | |||
e05c2e0383 | |||
bff27df10c | |||
11ac5da640 | |||
112dc59cf2 | |||
aa892f6c3f | |||
4e1b696869 |
@ -1,4 +1,4 @@
|
||||
version: 13.12.{build}
|
||||
version: 13.14.{build}
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map xmlns="http://www.gpxsee.org/map/1.4">
|
||||
<name>4UMaps</name>
|
||||
<url>https://tileserver.4umaps.com/$z/$x/$y.png</url>
|
||||
<zoom min="2" max="15"/>
|
||||
<bounds bottom="-65"/>
|
||||
<copyright>Map data: © OpenStreetMap contributors (ODbL) | Rendering: © 4UMaps.eu</copyright>
|
||||
</map>
|
6
data/maps/mtbmap-cz.xml
Normal file
6
data/maps/mtbmap-cz.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map xmlns="http://www.gpxsee.org/map/1.4">
|
||||
<name>mtbmap.cz</name>
|
||||
<url>https://tile.mtbmap.cz/mtbmap_tiles/$z/$x/$y.png</url>
|
||||
<copyright>Map data: OpenStreetMap, USGS | Rendering: Martin Tesař</copyright>
|
||||
</map>
|
@ -3,7 +3,7 @@ unix:!macx:!android {
|
||||
} else {
|
||||
TARGET = GPXSee
|
||||
}
|
||||
VERSION = 13.12
|
||||
VERSION = 13.14
|
||||
|
||||
|
||||
QT += core \
|
||||
|
@ -111,5 +111,6 @@
|
||||
<mimetype>application/vnd.iho.s57-data</mimetype>
|
||||
<mimetype>application/vnd.iho.s57-catalogue</mimetype>
|
||||
<mimetype>application/vnd.gpsdump.wpt</mimetype>
|
||||
<mimetype>application/vnd.gpstuner.gmi</mimetype>
|
||||
</mimetypes>
|
||||
</component>
|
||||
|
@ -16,4 +16,4 @@ Icon=gpxsee
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Graphics;Viewer;Education;Geography;Maps;Sports;Qt
|
||||
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt
|
||||
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt;application/vnd.gpstuner.gmi
|
||||
|
@ -363,4 +363,14 @@
|
||||
<glob pattern="*.031"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/vnd.gpstuner.gmi">
|
||||
<comment>GPS Tuner Map Calibration File</comment>
|
||||
<sub-class-of type="text/plain"/>
|
||||
<generic-icon name="text/plain"/>
|
||||
<magic>
|
||||
<match type="string" offset="0" value="Map Calibration data file"/>
|
||||
</magic>
|
||||
<glob pattern="*.gmi"/>
|
||||
</mime-type>
|
||||
|
||||
</mime-info>
|
||||
|
@ -417,6 +417,22 @@
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>gmi</string>
|
||||
</array>
|
||||
<key>CFBundleTypeMIMETypes</key>
|
||||
<array>
|
||||
<string>application/vnd.gpstuner.gmi</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>icons/map.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>GPS Tuner Map Calibration File</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
@ -1252,6 +1268,29 @@
|
||||
<string>application/vnd.oziexplorer.map</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.gpstuner.gmi</string>
|
||||
<key>UTTypeReferenceURL</key>
|
||||
<string>https://github.com/tumic0/GPXSee/blob/master/src/map/gmifile.cpp</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>GPS Tuner Map Calibration File</string>
|
||||
<key>UTTypeIconFile</key>
|
||||
<string>icons/map.icns</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>gmi</string>
|
||||
</array>
|
||||
<key>public.mime-type</key>
|
||||
<string>application/vnd.gpstuner.gmi</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.mapbox.mbtiles</string>
|
||||
|
@ -37,7 +37,7 @@ Unicode true
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "13.12"
|
||||
!define VERSION "13.14"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -163,6 +163,7 @@ Section "GPXSee" SEC_APP
|
||||
!insertmacro FILE_ASSOCIATION_ADD "kap" "BSB Nautical Chart" 10
|
||||
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 11
|
||||
!insertmacro FILE_ASSOCIATION_ADD "map" "OziExplorer Map File" 12
|
||||
!insertmacro FILE_ASSOCIATION_ADD "gmi" "GPS Tuner Map Calibration File" 12
|
||||
!insertmacro FILE_ASSOCIATION_ADD "mbtiles" "MBTiles Map File" 13
|
||||
!insertmacro FILE_ASSOCIATION_ADD "rmap" "TwoNav Raster Map File" 14
|
||||
!insertmacro FILE_ASSOCIATION_ADD "tba" "TrekBuddy Atlas" 15
|
||||
@ -218,6 +219,7 @@ Section "GPXSee" SEC_APP
|
||||
WriteRegStr HKCR ".jnx\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".kap\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".map\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".gmi\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".mbtiles\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".rmap\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".rtmap\OpenWithList" "GPXSee.exe" ""
|
||||
@ -384,6 +386,7 @@ Section "Uninstall"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "jnx"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "kap"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "map"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "gmi"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "mbtiles"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "rmap"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "tba"
|
||||
@ -431,6 +434,7 @@ Section "Uninstall"
|
||||
DeleteRegValue HKCR ".jnx\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".kap\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".map\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".gmi\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".mbtiles\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".rmap\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".rtmap\OpenWithList" "GPXSee.exe"
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <cmath>
|
||||
#include <QLocale>
|
||||
#include "data/data.h"
|
||||
#include "tooltip.h"
|
||||
#include "elevationgraphitem.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
@ -5,8 +5,10 @@
|
||||
#include <QFileInfo>
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
#include "common/util.h"
|
||||
#include "fileselectwidget.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "common/util.h"
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
|
||||
FileSelectWidget::FileSelectWidget(QWidget *parent) : QWidget(parent)
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "infoitem.h"
|
||||
#include "griditem.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
#include "format.h"
|
||||
#include "graphicsscene.h"
|
||||
#include "graphview.h"
|
||||
|
@ -52,11 +52,13 @@
|
||||
#include "graphtab.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
#include "mapitem.h"
|
||||
#include "mapaction.h"
|
||||
#include "poiaction.h"
|
||||
#include "navigationwidget.h"
|
||||
#include "gui.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "common/util.h"
|
||||
#include "navigationwidget.h"
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
|
||||
#define MAX_RECENT_FILES 10
|
||||
|
@ -4,9 +4,11 @@
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include "map/map.h"
|
||||
#include "mapaction.h"
|
||||
#include "popup.h"
|
||||
#include "tooltip.h"
|
||||
#include "mapitem.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "popup.h"
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
|
||||
static void growLeft(Map *map, const Coordinates &c, QRectF &rect)
|
||||
|
@ -2,12 +2,6 @@
|
||||
#include <QLineEdit>
|
||||
#include "pluginparameters.h"
|
||||
|
||||
static const QMap<QString, QStringList> pluginParams = {
|
||||
{"nmea", {"nmea.source", "nmea.baudrate"}},
|
||||
{"serialnmea", {"serialnmea.serial_port"}},
|
||||
{"geoclue2", {"desktopId"}}
|
||||
};
|
||||
|
||||
static void deleteLayout(QLayout *layout)
|
||||
{
|
||||
if (!layout)
|
||||
@ -32,6 +26,12 @@ PluginParameters::PluginParameters(const QString &plugin,
|
||||
|
||||
void PluginParameters::setPlugin(const QString &plugin)
|
||||
{
|
||||
static const QMap<QString, QStringList> pluginParams = {
|
||||
{"nmea", {"nmea.source", "nmea.baudrate"}},
|
||||
{"serialnmea", {"serialnmea.serial_port"}},
|
||||
{"geoclue2", {"desktopId"}}
|
||||
};
|
||||
|
||||
saveParameters();
|
||||
|
||||
QStringList params = pluginParams.value(plugin);
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QPageSize>
|
||||
#include <QGeoPositionInfoSource>
|
||||
#include "common/config.h"
|
||||
#include "common/util.h"
|
||||
#include "data/graph.h"
|
||||
#include "format.h"
|
||||
#include "units.h"
|
||||
@ -33,7 +32,7 @@
|
||||
: QPageSize::PageSizeId::A4)
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#define PIXMAP_CACHE 256
|
||||
#define PIXMAP_CACHE 384
|
||||
#define DEM_CACHE 128
|
||||
#else // Q_OS_ANDROID
|
||||
#define PIXMAP_CACHE 512
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <QLocale>
|
||||
#include "data/data.h"
|
||||
#include "tooltip.h"
|
||||
#include "format.h"
|
||||
#include "speedgraphitem.h"
|
||||
#include "speedgraph.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QNetworkRequest>
|
||||
#include <QDir>
|
||||
#include <QTimerEvent>
|
||||
@ -56,6 +55,7 @@ Authorization::Authorization(const QString &username, const QString &password)
|
||||
_header = HTTPHeader("Authorization", "Basic " + data);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
NetworkTimeout::NetworkTimeout(int timeout, QNetworkReply *reply)
|
||||
: QObject(reply), _timeout(timeout)
|
||||
{
|
||||
@ -77,6 +77,7 @@ void NetworkTimeout::timerEvent(QTimerEvent *ev)
|
||||
reply->abort();
|
||||
_timer.stop();
|
||||
}
|
||||
#endif // QT 5.15
|
||||
|
||||
|
||||
QNetworkAccessManager *Downloader::_manager = 0;
|
||||
@ -104,11 +105,15 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
|
||||
request.setAttribute(ATTR_REDIRECT_POLICY,
|
||||
QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||
request.setAttribute(ATTR_HTTP2_ALLOWED, QVariant(_http2));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
request.setTransferTimeout(_timeout * 1000);
|
||||
#endif // QT 5.15
|
||||
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
const HTTPHeader &hdr = headers.at(i);
|
||||
request.setRawHeader(hdr.key(), hdr.value());
|
||||
if (hdr.key() == "User-Agent")
|
||||
// QByteArray::compare() not available in Qt < 5.12
|
||||
if (!QString(hdr.key()).compare("User-Agent", Qt::CaseInsensitive))
|
||||
userAgent = true;
|
||||
}
|
||||
if (!userAgent)
|
||||
@ -128,9 +133,9 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
|
||||
_currentDownloads.insert(url, file);
|
||||
|
||||
if (reply->isRunning()) {
|
||||
/* Starting with Qt 5.15 this can be replaced by
|
||||
QNetworkRequest::setTransferTimeout() */
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
new NetworkTimeout(_timeout, reply);
|
||||
#endif // QT 5.15
|
||||
connect(reply, &QIODevice::readyRead, this, &Downloader::emitReadReady);
|
||||
connect(reply, &QNetworkReply::finished, this, &Downloader::emitFinished);
|
||||
} else {
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
#include <QBasicTimer>
|
||||
#endif // QT 5.15
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
@ -39,6 +41,7 @@ private:
|
||||
HTTPHeader _header;
|
||||
};
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
class NetworkTimeout : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -55,6 +58,7 @@ private:
|
||||
QBasicTimer _timer;
|
||||
int _timeout;
|
||||
};
|
||||
#endif // QT 5.15
|
||||
|
||||
class Downloader : public QObject
|
||||
{
|
||||
@ -79,8 +83,6 @@ private slots:
|
||||
void emitReadReady();
|
||||
|
||||
private:
|
||||
class ReplyTimeout;
|
||||
|
||||
void insertError(const QUrl &url, QNetworkReply::NetworkError error);
|
||||
bool doDownload(const Download &dl, const QList<HTTPHeader> &headers);
|
||||
void downloadFinished(QNetworkReply *reply);
|
||||
|
@ -1,55 +1,66 @@
|
||||
#include <QTextCodec>
|
||||
#include "textcodec.h"
|
||||
|
||||
TextCodec::TextCodec()
|
||||
static QTextCodec *codec(int mib)
|
||||
{
|
||||
_codec = QTextCodec::codecForName("Windows-1252");
|
||||
QTextCodec *c = QTextCodec::codecForMib(mib);
|
||||
if (!c)
|
||||
qWarning("MIB-%d: No such QTextCodec, using UTF-8", mib);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
TextCodec::TextCodec(int codepage)
|
||||
{
|
||||
switch (codepage) {
|
||||
case 874:
|
||||
_codec = codec(2109);
|
||||
break;
|
||||
case 932:
|
||||
_codec = codec(17);
|
||||
break;
|
||||
case 936:
|
||||
_codec = codec(114);
|
||||
break;
|
||||
case 949:
|
||||
_codec = codec(38);
|
||||
break;
|
||||
case 950:
|
||||
_codec = codec(2026);
|
||||
break;
|
||||
case 1250:
|
||||
_codec = codec(2250);
|
||||
break;
|
||||
case 1251:
|
||||
_codec = codec(2251);
|
||||
break;
|
||||
case 1252:
|
||||
_codec = codec(2252);
|
||||
break;
|
||||
case 1253:
|
||||
_codec = codec(2253);
|
||||
break;
|
||||
case 1254:
|
||||
_codec = codec(2254);
|
||||
break;
|
||||
case 1255:
|
||||
_codec = codec(2255);
|
||||
break;
|
||||
case 1256:
|
||||
_codec = codec(2256);
|
||||
break;
|
||||
case 1257:
|
||||
_codec = codec(2257);
|
||||
break;
|
||||
case 1258:
|
||||
_codec = codec(2258);
|
||||
break;
|
||||
case 65001:
|
||||
_codec = 0;
|
||||
break;
|
||||
case 932:
|
||||
_codec = QTextCodec::codecForName("Shift-JIS");
|
||||
break;
|
||||
case 936:
|
||||
_codec = QTextCodec::codecForName("GB18030");
|
||||
break;
|
||||
case 949:
|
||||
_codec = QTextCodec::codecForName("EUC-KR");
|
||||
break;
|
||||
case 950:
|
||||
_codec = QTextCodec::codecForName("Big5");
|
||||
break;
|
||||
case 1250:
|
||||
_codec = QTextCodec::codecForName("Windows-1250");
|
||||
break;
|
||||
case 1251:
|
||||
_codec = QTextCodec::codecForName("Windows-1251");
|
||||
break;
|
||||
case 1253:
|
||||
_codec = QTextCodec::codecForName("Windows-1253");
|
||||
break;
|
||||
case 1254:
|
||||
_codec = QTextCodec::codecForName("Windows-1254");
|
||||
break;
|
||||
case 1255:
|
||||
_codec = QTextCodec::codecForName("Windows-1255");
|
||||
break;
|
||||
case 1256:
|
||||
_codec = QTextCodec::codecForName("Windows-1256");
|
||||
break;
|
||||
case 1257:
|
||||
_codec = QTextCodec::codecForName("Windows-1257");
|
||||
break;
|
||||
case 1258:
|
||||
_codec = QTextCodec::codecForName("Windows-1258");
|
||||
break;
|
||||
default:
|
||||
_codec = QTextCodec::codecForName("Windows-1252");
|
||||
qWarning("%d: Unknown codepage, using UTF-8", codepage);
|
||||
_codec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,14 @@
|
||||
#define TEXTCODEC_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
class QTextCodec;
|
||||
|
||||
class TextCodec
|
||||
{
|
||||
public:
|
||||
TextCodec();
|
||||
TextCodec() : _codec(0) {}
|
||||
TextCodec(int codepage);
|
||||
|
||||
QString toString(const QByteArray &ba) const;
|
||||
|
@ -148,9 +148,9 @@ qreal DEM::elevation(const Coordinates &c)
|
||||
|
||||
QList<Area> DEM::tiles()
|
||||
{
|
||||
static const QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})");
|
||||
QDir dir(_dir);
|
||||
QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable));
|
||||
QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})");
|
||||
QLocale l(QLocale::system());
|
||||
QList<Area> list;
|
||||
|
||||
|
@ -128,7 +128,7 @@ qint64 CryptDevice::readData(char *data, qint64 maxSize)
|
||||
class DataStream : public QDataStream
|
||||
{
|
||||
public:
|
||||
DataStream(QIODevice *d) : QDataStream(d) {}
|
||||
DataStream(QIODevice *d) : QDataStream(d), _codec(1252) {}
|
||||
|
||||
void setCodepage(quint16 codepage) {_codec = TextCodec(codepage);}
|
||||
|
||||
|
@ -88,6 +88,7 @@ static Coordinates parseUTM(const QString &zone, const QString &easting,
|
||||
bool GPSDumpParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
|
||||
{
|
||||
static const QRegularExpression dm("[ ]{2,}");
|
||||
Q_UNUSED(tracks);
|
||||
Q_UNUSED(routes);
|
||||
Q_UNUSED(polygons);
|
||||
@ -95,7 +96,6 @@ bool GPSDumpParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
_errorLine = 1;
|
||||
_errorString.clear();
|
||||
Type type = Unknown;
|
||||
QRegularExpression dm("[ ]{2,}");
|
||||
|
||||
while (!file->atEnd()) {
|
||||
QByteArray ba(file->readLine(4096).trimmed());
|
||||
|
@ -2,11 +2,9 @@
|
||||
#include <QDir>
|
||||
#include "common/rectc.h"
|
||||
#include "common/greatcircle.h"
|
||||
#include "data.h"
|
||||
#include "dem.h"
|
||||
#include "path.h"
|
||||
#include "area.h"
|
||||
#include "common/wgs84.h"
|
||||
#include "data.h"
|
||||
#include "path.h"
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ QDebug operator<<(QDebug dbg, const SMLParser::Sensors &sensors)
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
|
||||
void SMLParser::sample(SegmentData &segment, QMap<QDateTime, Sensors> &map)
|
||||
void SMLParser::sample(SegmentData &segment, SensorsMap &map)
|
||||
{
|
||||
QDateTime timestamp;
|
||||
Sensors sensors;
|
||||
@ -97,19 +97,20 @@ void SMLParser::sample(SegmentData &segment, QMap<QDateTime, Sensors> &map)
|
||||
|
||||
void SMLParser::samples(SegmentData &segment)
|
||||
{
|
||||
QMap<QDateTime, Sensors> sensors;
|
||||
QMap<QDateTime, Sensors>::const_iterator it;
|
||||
SensorsMap map;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == QLatin1String("Sample")) {
|
||||
sample(segment, sensors);
|
||||
sample(segment, map);
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
for (int i = 0; i < segment.size(); i++) {
|
||||
Trackpoint &t = segment[i];
|
||||
if ((it = sensors.lowerBound(t.timestamp())) != sensors.constEnd()) {
|
||||
SensorsMap::const_iterator it(map.lowerBound(t.timestamp()));
|
||||
|
||||
if (it != map.constEnd()) {
|
||||
t.setCadence(it->cadence * 60);
|
||||
t.setTemperature(it->temperature - 273.15);
|
||||
t.setHeartRate(it->hr * 60);
|
||||
|
@ -23,10 +23,12 @@ private:
|
||||
qreal cadence, temperature, hr, power, speed;
|
||||
};
|
||||
|
||||
typedef QMap<QDateTime, Sensors> SensorsMap;
|
||||
|
||||
void sml(QList<TrackData> &tracks);
|
||||
void deviceLog(TrackData &track);
|
||||
void samples(SegmentData &segment);
|
||||
void sample(SegmentData &segment, QMap<QDateTime, Sensors> &map);
|
||||
void sample(SegmentData &segment, SensorsMap &map);
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
friend QDebug operator<<(QDebug dbg, const Sensors &sensors);
|
||||
|
@ -75,7 +75,7 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
QVector<Waypoint> &waypoints)
|
||||
{
|
||||
Q_UNUSED(polygons);
|
||||
TextCodec codec;
|
||||
TextCodec codec(1252);
|
||||
GCS gcs;
|
||||
bool ok, route = false, track = false, waypoint = false;
|
||||
|
||||
|
@ -323,7 +323,7 @@ bool ISO8211::readRecord(Record &record)
|
||||
const FieldDefinition &def = fields.at(i);
|
||||
Data data;
|
||||
|
||||
FieldsMap::const_iterator it = _map.find(def.tag);
|
||||
FieldsMap::const_iterator it(_map.find(def.tag));
|
||||
if (it == _map.constEnd()) {
|
||||
_errorString = QString("%1: unknown record").arg(QString(def.tag));
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ static QMap<uint,uint> orderMap = orderMapInit();
|
||||
static uint order(uint type)
|
||||
{
|
||||
uint st = ((type>>16) == BUAARE) ? type : (type & 0xFFFF0000);
|
||||
QMap<uint, uint>::const_iterator it = orderMap.find(st);
|
||||
QMap<uint, uint>::const_iterator it(orderMap.find(st));
|
||||
return (it == orderMap.constEnd()) ? (type>>16) + 512 : it.value();
|
||||
}
|
||||
|
||||
|
@ -15,51 +15,13 @@ using namespace ENC;
|
||||
typedef QSet<Coordinates> PointSet;
|
||||
|
||||
static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
||||
static const QColor haloColor(Qt::white);
|
||||
static const QColor tsslptPen = QColor("#eb49eb");
|
||||
static const QColor tsslptBrush = QColor("#80eb49eb");
|
||||
|
||||
static QFont pixelSizeFont(int pixelSize)
|
||||
static const Style *style()
|
||||
{
|
||||
QFont f;
|
||||
f.setPixelSize(pixelSize);
|
||||
return f;
|
||||
}
|
||||
|
||||
static QFont *font(Style::FontSize size)
|
||||
{
|
||||
/* The fonts must be initialized on first usage (after the QGuiApplication
|
||||
instance is created) */
|
||||
static QFont large = pixelSizeFont(16);
|
||||
static QFont normal = pixelSizeFont(12);
|
||||
static QFont small = pixelSizeFont(10);
|
||||
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
case Style::Large:
|
||||
return &large;
|
||||
case Style::Small:
|
||||
return &small;
|
||||
default:
|
||||
return &normal;
|
||||
}
|
||||
}
|
||||
|
||||
static const QImage *light()
|
||||
{
|
||||
static QImage img(":/marine/light.png");
|
||||
return &img;
|
||||
}
|
||||
|
||||
static const QImage *signal()
|
||||
{
|
||||
static QImage img(":/marine/fog-signal.png");
|
||||
return &img;
|
||||
}
|
||||
|
||||
static const Style& style()
|
||||
{
|
||||
static Style s;
|
||||
return s;
|
||||
static ENC::Style s;
|
||||
return &s;
|
||||
}
|
||||
|
||||
static double area(const QVector<Coordinates> &polygon)
|
||||
@ -213,8 +175,8 @@ void RasterTile::drawArrows(QPainter *painter,
|
||||
QPolygonF polygon(tsslptArrow(centroid(poly.path().first()),
|
||||
deg2rad(180 - poly.param().toDouble())));
|
||||
|
||||
painter->setPen(QPen(QColor("#eb49eb"), 1));
|
||||
painter->setBrush(QBrush("#80eb49eb"));
|
||||
painter->setPen(QPen(tsslptPen, 1));
|
||||
painter->setBrush(QBrush(tsslptBrush));
|
||||
painter->drawPolygon(polygon);
|
||||
}
|
||||
}
|
||||
@ -223,14 +185,12 @@ void RasterTile::drawArrows(QPainter *painter,
|
||||
void RasterTile::drawPolygons(QPainter *painter,
|
||||
const QList<MapData::Poly> &polygons)
|
||||
{
|
||||
const Style &s = style();
|
||||
|
||||
for (int n = 0; n < s.drawOrder().size(); n++) {
|
||||
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
const MapData::Poly &poly = polygons.at(i);
|
||||
if (poly.type() != s.drawOrder().at(n))
|
||||
if (poly.type() != _style->drawOrder().at(n))
|
||||
continue;
|
||||
const Style::Polygon &style = s.polygon(poly.type());
|
||||
const Style::Polygon &style = _style->polygon(poly.type());
|
||||
|
||||
if (!style.img().isNull()) {
|
||||
for (int i = 0; i < poly.path().size(); i++)
|
||||
@ -257,13 +217,11 @@ void RasterTile::drawPolygons(QPainter *painter,
|
||||
|
||||
void RasterTile::drawLines(QPainter *painter, const QList<MapData::Line> &lines)
|
||||
{
|
||||
const Style &s = style();
|
||||
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
const MapData::Line &line = lines.at(i);
|
||||
const Style::Line &style = s.line(line.type());
|
||||
const Style::Line &style = _style->line(line.type());
|
||||
|
||||
if (!style.img().isNull()) {
|
||||
BitmapLine::draw(painter, polyline(line.path()), style.img());
|
||||
@ -284,8 +242,6 @@ void RasterTile::drawTextItems(QPainter *painter,
|
||||
void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
|
||||
QList<TextItem*> &textItems)
|
||||
{
|
||||
const Style &s = style();
|
||||
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
const MapData::Poly &poly = polygons.at(i);
|
||||
uint type = poly.type()>>16;
|
||||
@ -293,7 +249,7 @@ void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
|
||||
if (!(type == HRBFAC || type == I_TRNBSN
|
||||
|| poly.type() == SUBTYPE(I_BERTHS, 6)))
|
||||
continue;
|
||||
const Style::Point &style = s.point(poly.type());
|
||||
const Style::Point &style = _style->point(poly.type());
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
if (!img)
|
||||
continue;
|
||||
@ -311,7 +267,6 @@ void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
|
||||
void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights)
|
||||
{
|
||||
const Style &s = style();
|
||||
PointSet lightsSet, signalsSet;
|
||||
int i;
|
||||
|
||||
@ -332,12 +287,12 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
for ( ; i < points.size(); i++) {
|
||||
const MapData::Point &point = points.at(i);
|
||||
QPoint pos(ll2xy(point.pos()).toPoint());
|
||||
const Style::Point &style = s.point(point.type());
|
||||
const Style::Point &style = _style->point(point.type());
|
||||
|
||||
const QString *label = point.label().isEmpty() ? 0 : &(point.label());
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
const QFont *fnt = showLabel(img, _zoomRange, _zoom, point.type())
|
||||
? font(style.textFontSize()) : 0;
|
||||
? _style->font(style.textFontSize()) : 0;
|
||||
const QColor *color = &style.textColor();
|
||||
const QColor *hColor = style.haloColor().isValid()
|
||||
? &style.haloColor() : 0;
|
||||
@ -351,9 +306,11 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
if (item->isValid() && !item->collides(textItems)) {
|
||||
textItems.append(item);
|
||||
if (lightsSet.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos, 0, 0, light(), 0, 0, 0, 0));
|
||||
lights.append(new TextPointItem(pos, 0, 0, _style->light(), 0,
|
||||
0, 0, 0));
|
||||
if (signalsSet.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos, 0, 0, signal(), 0, 0, 0, 0));
|
||||
lights.append(new TextPointItem(pos, 0, 0, _style->signal(), 0,
|
||||
0, 0, 0));
|
||||
} else
|
||||
delete item;
|
||||
}
|
||||
@ -362,18 +319,16 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
void RasterTile::processLines(const QList<MapData::Line> &lines,
|
||||
QList<TextItem*> &textItems)
|
||||
{
|
||||
const Style &s = style();
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
const MapData::Line &line = lines.at(i);
|
||||
const Style::Line &style = s.line(line.type());
|
||||
const Style::Line &style = _style->line(line.type());
|
||||
|
||||
if (style.img().isNull() && style.pen() == Qt::NoPen)
|
||||
continue;
|
||||
if (line.label().isEmpty() || style.textFontSize() == Style::None)
|
||||
continue;
|
||||
|
||||
const QFont *fnt = font(style.textFontSize());
|
||||
const QFont *fnt = _style->font(style.textFontSize());
|
||||
const QColor *color = &style.textColor();
|
||||
|
||||
TextPathItem *item = new TextPathItem(polyline(line.path()),
|
||||
@ -449,3 +404,23 @@ void RasterTile::render()
|
||||
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
||||
const MapData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
||||
qreal ratio) :
|
||||
_proj(proj), _transform(transform), _map(data), _atlas(0), _zoom(zoom),
|
||||
_zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
||||
{
|
||||
_style = style();
|
||||
}
|
||||
|
||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
||||
AtlasData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
||||
qreal ratio) :
|
||||
_proj(proj), _transform(transform), _map(0), _atlas(data), _zoom(zoom),
|
||||
_zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
||||
{
|
||||
_style = style();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "map/transform.h"
|
||||
#include "map/textpointitem.h"
|
||||
#include "mapdata.h"
|
||||
#include "style.h"
|
||||
#include "atlasdata.h"
|
||||
|
||||
class TextItem;
|
||||
@ -18,14 +19,10 @@ class RasterTile
|
||||
public:
|
||||
RasterTile(const Projection &proj, const Transform &transform,
|
||||
const MapData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
||||
qreal ratio) : _proj(proj), _transform(transform), _map(data), _atlas(0),
|
||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false) {}
|
||||
qreal ratio);
|
||||
RasterTile(const Projection &proj, const Transform &transform,
|
||||
AtlasData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
||||
qreal ratio) : _proj(proj), _transform(transform), _map(0), _atlas(data),
|
||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false) {}
|
||||
qreal ratio);
|
||||
|
||||
int zoom() const {return _zoom;}
|
||||
QPoint xy() const {return _rect.topLeft();}
|
||||
@ -61,6 +58,7 @@ private:
|
||||
|
||||
Projection _proj;
|
||||
Transform _transform;
|
||||
const Style *_style;
|
||||
const MapData *_map;
|
||||
AtlasData *_atlas;
|
||||
int _zoom;
|
||||
|
@ -14,6 +14,13 @@ static QImage railroad()
|
||||
return img;
|
||||
}
|
||||
|
||||
static QFont pixelSizeFont(int pixelSize)
|
||||
{
|
||||
QFont f;
|
||||
f.setPixelSize(pixelSize);
|
||||
return f;
|
||||
}
|
||||
|
||||
void Style::polygonStyle()
|
||||
{
|
||||
_polygons[TYPE(M_COVR)] = Polygon(QBrush("#ffffff"));
|
||||
@ -321,6 +328,13 @@ void Style::pointStyle()
|
||||
|
||||
Style::Style()
|
||||
{
|
||||
_light = QImage(":/marine/light.png");
|
||||
_signal = QImage(":/marine/fog-signal.png");
|
||||
|
||||
_large = pixelSizeFont(16);
|
||||
_normal = pixelSizeFont(12);
|
||||
_small = pixelSizeFont(10);
|
||||
|
||||
polygonStyle();
|
||||
lineStyle();
|
||||
pointStyle();
|
||||
@ -330,7 +344,7 @@ const Style::Line &Style::line(uint type) const
|
||||
{
|
||||
static Line null;
|
||||
|
||||
QMap<uint, Line>::const_iterator it = _lines.find(type);
|
||||
QMap<uint, Line>::const_iterator it(_lines.find(type));
|
||||
return (it == _lines.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
@ -338,7 +352,7 @@ const Style::Polygon &Style::polygon(uint type) const
|
||||
{
|
||||
static Polygon null;
|
||||
|
||||
QMap<uint, Polygon>::const_iterator it = _polygons.find(type);
|
||||
QMap<uint, Polygon>::const_iterator it(_polygons.find(type));
|
||||
return (it == _polygons.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
@ -346,6 +360,20 @@ const Style::Point &Style::point(uint type) const
|
||||
{
|
||||
static Point null;
|
||||
|
||||
QMap<uint, Point>::const_iterator it = _points.find(type);
|
||||
QMap<uint, Point>::const_iterator it(_points.find(type));
|
||||
return (it == _points.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
const QFont *Style::font(Style::FontSize size) const
|
||||
{
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
case Style::Large:
|
||||
return &_large;
|
||||
case Style::Small:
|
||||
return &_small;
|
||||
default:
|
||||
return &_normal;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
#include <QMap>
|
||||
#include "objects.h"
|
||||
|
||||
@ -96,6 +97,10 @@ public:
|
||||
const Point &point(uint type) const;
|
||||
const QVector<uint> &drawOrder() const {return _drawOrder;}
|
||||
|
||||
const QFont *font(Style::FontSize size) const;
|
||||
const QImage *light() const {return &_light;}
|
||||
const QImage *signal() const {return &_signal;}
|
||||
|
||||
private:
|
||||
void polygonStyle();
|
||||
void lineStyle();
|
||||
@ -105,6 +110,10 @@ private:
|
||||
QMap<uint, Polygon> _polygons;
|
||||
QMap<uint, Point> _points;
|
||||
QVector<uint> _drawOrder;
|
||||
|
||||
/* Fonts and images must be initialized after QGuiApplication! */
|
||||
QFont _small, _normal, _large;
|
||||
QImage _light, _signal;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -52,8 +52,10 @@ bool GMAPData::readXML(const QString &path, QString &dataDir, QString &typFile)
|
||||
{
|
||||
QFile file(path);
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_errorString = file.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
QXmlStreamReader reader(&file);
|
||||
if (reader.readNextStartElement()) {
|
||||
|
@ -105,7 +105,7 @@ bool IMGData::readFAT(QFile &file, TileMap &tileMap)
|
||||
QByteArray fn(name, sizeof(name));
|
||||
if (VectorTile::isTileFile(tt)) {
|
||||
VectorTile *tile;
|
||||
TileMap::const_iterator it = tileMap.find(fn);
|
||||
TileMap::const_iterator it(tileMap.find(fn));
|
||||
if (it == tileMap.constEnd()) {
|
||||
tile = new VectorTile();
|
||||
tileMap.insert(fn, tile);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <QFont>
|
||||
#include <QPainter>
|
||||
#include <QCache>
|
||||
#include "map/imgmap.h"
|
||||
#include "map/textpathitem.h"
|
||||
#include "map/textpointitem.h"
|
||||
#include "map/bitmapline.h"
|
||||
@ -28,57 +27,6 @@ static const QColor shieldBgColor1("#dd3e3e");
|
||||
static const QColor shieldBgColor2("#379947");
|
||||
static const QColor shieldBgColor3("#4a7fc1");
|
||||
|
||||
static QFont pixelSizeFont(int pixelSize)
|
||||
{
|
||||
QFont f;
|
||||
f.setPixelSize(pixelSize);
|
||||
return f;
|
||||
}
|
||||
|
||||
static QFont *font(Style::FontSize size, Style::FontSize defaultSize
|
||||
= Style::Normal)
|
||||
{
|
||||
/* The fonts must be initialized on first usage (after the QGuiApplication
|
||||
instance is created) */
|
||||
static QFont large = pixelSizeFont(16);
|
||||
static QFont normal = pixelSizeFont(14);
|
||||
static QFont small = pixelSizeFont(12);
|
||||
static QFont extraSmall = pixelSizeFont(10);
|
||||
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
case Style::Large:
|
||||
return &large;
|
||||
case Style::Normal:
|
||||
return &normal;
|
||||
case Style::Small:
|
||||
return &small;
|
||||
case Style::ExtraSmall:
|
||||
return &extraSmall;
|
||||
default:
|
||||
return font(defaultSize);
|
||||
}
|
||||
}
|
||||
|
||||
static QFont *poiFont(Style::FontSize size = Style::Normal, int zoom = -1,
|
||||
bool extended = false)
|
||||
{
|
||||
static QFont poi = pixelSizeFont(10);
|
||||
|
||||
if (zoom > 25)
|
||||
size = Style::Normal;
|
||||
else if (extended)
|
||||
size = Style::None;
|
||||
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
default:
|
||||
return &poi;
|
||||
}
|
||||
}
|
||||
|
||||
static const QColor *shieldBgColor(Shield::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
@ -152,6 +100,21 @@ static bool rectNearPolygon(const QPolygonF &polygon, const QRectF &rect)
|
||||
|| polygon.containsPoint(rect.bottomRight(), Qt::OddEvenFill)));
|
||||
}
|
||||
|
||||
const QFont *RasterTile::poiFont(Style::FontSize size, int zoom, bool extended)
|
||||
{
|
||||
if (zoom > 25)
|
||||
size = Style::Normal;
|
||||
else if (extended)
|
||||
size = Style::None;
|
||||
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
default:
|
||||
return _data->style()->font(Style::ExtraSmall);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::ll2xy(QList<MapData::Poly> &polys)
|
||||
{
|
||||
for (int i = 0; i < polys.size(); i++) {
|
||||
@ -324,7 +287,8 @@ void RasterTile::processStreetNames(const QList<MapData::Poly> &lines,
|
||||
if (style.img().isNull() && style.foreground() == Qt::NoPen)
|
||||
continue;
|
||||
|
||||
const QFont *fnt = font(style.textFontSize(), Style::Small);
|
||||
const QFont *fnt = _data->style()->font(style.textFontSize(),
|
||||
Style::Small);
|
||||
const QColor *color = style.textColor().isValid()
|
||||
? &style.textColor() : 0;
|
||||
const QColor *hColor = Style::isContourLine(poly.type) ? 0 : &haloColor;
|
||||
@ -435,7 +399,7 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
const QFont *fnt = poi
|
||||
? poiFont(style.textFontSize(), _zoom, point.classLabel)
|
||||
: font(style.textFontSize());
|
||||
: _data->style()->font(style.textFontSize());
|
||||
const QColor *color = style.textColor().isValid()
|
||||
? &style.textColor() : &textColor;
|
||||
const QColor *hcolor = Style::isDepthPoint(point.type)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "mapdata.h"
|
||||
#include "map/projection.h"
|
||||
#include "map/transform.h"
|
||||
#include "style.h"
|
||||
|
||||
class QPainter;
|
||||
class IMGMap;
|
||||
@ -12,8 +13,6 @@ class TextItem;
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Style;
|
||||
|
||||
class RasterTile
|
||||
{
|
||||
public:
|
||||
@ -53,6 +52,9 @@ private:
|
||||
void processStreetNames(const QList<MapData::Poly> &lines,
|
||||
QList<TextItem*> &textItems, const QImage (&arrows)[2]);
|
||||
|
||||
const QFont *poiFont(Style::FontSize size = Style::Normal,
|
||||
int zoom = -1, bool extended = false);
|
||||
|
||||
Projection _proj;
|
||||
Transform _transform;
|
||||
MapData *_data;
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
using namespace IMG;
|
||||
|
||||
static QFont pixelSizeFont(int pixelSize)
|
||||
{
|
||||
QFont f;
|
||||
f.setPixelSize(pixelSize);
|
||||
return f;
|
||||
}
|
||||
|
||||
static bool readColor(SubFile *file, SubFile::Handle &hdl, QColor &color)
|
||||
{
|
||||
quint8 b, g, r;
|
||||
@ -1226,6 +1233,11 @@ bool Style::parseTYPFile(SubFile *file)
|
||||
|
||||
Style::Style(SubFile *typ)
|
||||
{
|
||||
_large = pixelSizeFont(16);
|
||||
_normal = pixelSizeFont(14);
|
||||
_small = pixelSizeFont(12);
|
||||
_extraSmall = pixelSizeFont(10);
|
||||
|
||||
defaultLineStyle();
|
||||
defaultPolygonStyle();
|
||||
defaultPointStyle();
|
||||
@ -1238,7 +1250,7 @@ const Style::Line &Style::line(quint32 type) const
|
||||
{
|
||||
static Line null;
|
||||
|
||||
QMap<quint32, Line>::const_iterator it = _lines.find(type);
|
||||
QMap<quint32, Line>::const_iterator it(_lines.find(type));
|
||||
return (it == _lines.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
@ -1246,7 +1258,7 @@ const Style::Polygon &Style::polygon(quint32 type) const
|
||||
{
|
||||
static Polygon null;
|
||||
|
||||
QMap<quint32, Polygon>::const_iterator it = _polygons.find(type);
|
||||
QMap<quint32, Polygon>::const_iterator it(_polygons.find(type));
|
||||
return (it == _polygons.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
@ -1254,10 +1266,30 @@ const Style::Point &Style::point(quint32 type) const
|
||||
{
|
||||
static Point null;
|
||||
|
||||
QMap<quint32, Point>::const_iterator it = _points.find(type);
|
||||
QMap<quint32, Point>::const_iterator it(_points.find(type));
|
||||
return (it == _points.constEnd()) ? null : *it;
|
||||
}
|
||||
|
||||
const QFont *Style::font(Style::FontSize size, Style::FontSize defaultSize) const
|
||||
{
|
||||
Q_ASSERT(defaultSize != Style::NotSet);
|
||||
|
||||
switch (size) {
|
||||
case Style::None:
|
||||
return 0;
|
||||
case Style::Large:
|
||||
return &_large;
|
||||
case Style::Normal:
|
||||
return &_normal;
|
||||
case Style::Small:
|
||||
return &_small;
|
||||
case Style::ExtraSmall:
|
||||
return &_extraSmall;
|
||||
default:
|
||||
return font(defaultSize);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
static QString penColor(const QPen &pen)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QPen>
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
#include <QDebug>
|
||||
#include "subfile.h"
|
||||
|
||||
@ -94,6 +95,8 @@ public:
|
||||
const Polygon &polygon(quint32 type) const;
|
||||
const Point &point(quint32 type) const;
|
||||
const QList<quint32> &drawOrder() const {return _drawOrder;}
|
||||
const QFont *font(Style::FontSize size, Style::FontSize defaultSize
|
||||
= Style::Normal) const;
|
||||
|
||||
static bool isPOI(quint32 type)
|
||||
{return !((type >= TYPE(0x01) && type <= TYPE(0x1f))
|
||||
@ -172,6 +175,9 @@ private:
|
||||
QMap<quint32, Polygon> _polygons;
|
||||
QMap<quint32, Point> _points;
|
||||
QList<quint32> _drawOrder;
|
||||
|
||||
/* Fonts and images must be initialized after QGuiApplication! */
|
||||
QFont _large, _normal, _small, _extraSmall;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QImageReader>
|
||||
#include <QBuffer>
|
||||
#include <QtConcurrent>
|
||||
#include "common/hash.h"
|
||||
#include "osm.h"
|
||||
#include "tile.h"
|
||||
#include "aqmmap.h"
|
||||
@ -295,7 +294,7 @@ int AQMMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
qreal AQMMap::resolution(const QRectF &rect)
|
||||
{
|
||||
const Zoom &z = _zooms.at(_zoom);
|
||||
return OSM::resolution(rect.center(), z.zoom, z.tileSize);
|
||||
return OSM::resolution(rect.center(), z.zoom, tileSize());
|
||||
}
|
||||
|
||||
int AQMMap::zoomIn()
|
||||
|
@ -27,19 +27,25 @@ static bool yCmp(OziMap *m1, OziMap *m2)
|
||||
return TL(m1).y() > TL(m2).y();
|
||||
}
|
||||
|
||||
static QString calibrationFile(const QString &path)
|
||||
static QString calibrationFile(const QString &path, OziMap::CalibrationType &type)
|
||||
{
|
||||
QDir dir(path);
|
||||
QFileInfoList files = dir.entryInfoList(QDir::Files);
|
||||
QFileInfoList files(dir.entryInfoList(QDir::Files));
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
const QFileInfo &fi = files.at(i);
|
||||
QString suffix(fi.suffix().toLower());
|
||||
|
||||
if (suffix == "map" || suffix == "gmi")
|
||||
if (suffix == "map") {
|
||||
type = OziMap::MAP;
|
||||
return fi.absoluteFilePath();
|
||||
} else if (suffix == "gmi") {
|
||||
type = OziMap::GMI;
|
||||
return fi.absoluteFilePath();
|
||||
}
|
||||
}
|
||||
|
||||
type = OziMap::Unknown;
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -141,16 +147,19 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj,
|
||||
QFileInfoList maps = zdir.entryInfoList(QDir::Dirs
|
||||
| QDir::NoDotAndDotDot);
|
||||
for (int i = 0; i < maps.count(); i++) {
|
||||
QString path(maps.at(i).absoluteFilePath());
|
||||
OziMap *map;
|
||||
|
||||
if (TAR)
|
||||
map = new OziMap(maps.at(i).absoluteFilePath(), tar, proj, this);
|
||||
map = new OziMap(path, tar, proj, this);
|
||||
else {
|
||||
QString cf(calibrationFile(maps.at(i).absoluteFilePath()));
|
||||
OziMap::CalibrationType type;
|
||||
QString cf(calibrationFile(path, type));
|
||||
if (cf.isNull()) {
|
||||
_errorString = "No calibration file found";
|
||||
return;
|
||||
qWarning("%s: no calibration file found", qPrintable(path));
|
||||
continue;
|
||||
}
|
||||
map = new OziMap(cf, proj, this);
|
||||
map = new OziMap(cf, type, proj, this);
|
||||
}
|
||||
|
||||
if (map->isValid())
|
||||
|
@ -395,7 +395,7 @@ BSBMap::BSBMap(const QString &fileName, QObject *parent)
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
_errorString = fileName + ": " + file.errorString();
|
||||
_errorString = file.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ QMap<int, Conversion::Entry> Conversion::defaults()
|
||||
|
||||
Conversion Conversion::conversion(int id)
|
||||
{
|
||||
QMap<int, Entry>::const_iterator it = _conversions.find(id);
|
||||
QMap<int, Entry>::const_iterator it(_conversions.find(id));
|
||||
|
||||
if (it == _conversions.constEnd())
|
||||
return Conversion();
|
||||
@ -189,7 +189,7 @@ QList<KV<int, QString> > Conversion::list()
|
||||
QList<KV<int, QString> > list;
|
||||
|
||||
for (QMap<int, Entry>::const_iterator it = _conversions.constBegin();
|
||||
it != _conversions.constEnd(); ++it)
|
||||
it != _conversions.constEnd(); ++it)
|
||||
list.append(KV<int, QString>(it.key(), it.value().name()));
|
||||
|
||||
return list;
|
||||
|
@ -323,9 +323,8 @@ void ENCMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
||||
painter->drawPixmap(ttl, pm);
|
||||
else
|
||||
tiles.append(RasterTile(_projection, _transform, _data,
|
||||
_zoom, _zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)),
|
||||
_tileRatio));
|
||||
tiles.append(RasterTile(_projection, _transform, _data, _zoom,
|
||||
_zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QFile>
|
||||
#include "common/wgs84.h"
|
||||
#include "common/csv.h"
|
||||
#include "gcs.h"
|
||||
|
||||
|
@ -128,7 +128,7 @@ GEMFMap::GEMFMap(const QString &fileName, QObject *parent)
|
||||
|
||||
qreal GEMFMap::resolution(const QRectF &rect)
|
||||
{
|
||||
return OSM::resolution(rect.center(), _zooms.at(_zi).level, _tileSize);
|
||||
return OSM::resolution(rect.center(), _zooms.at(_zi).level, tileSize());
|
||||
}
|
||||
|
||||
int GEMFMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <QPainter>
|
||||
#include <QImageReader>
|
||||
#include "common/util.h"
|
||||
#include "geotiff.h"
|
||||
#include "image.h"
|
||||
#include "geotiffmap.h"
|
||||
|
@ -41,13 +41,13 @@ bool GmiFile::parse(QIODevice &device)
|
||||
_image = line.trimmed();
|
||||
else if (ln == 3) {
|
||||
width = line.toInt(&ok);
|
||||
if (!ok || ok <= 0) {
|
||||
if (!ok || width <= 0) {
|
||||
_errorString = "Invalid image width";
|
||||
return false;
|
||||
}
|
||||
} else if (ln == 4) {
|
||||
height = line.toInt(&ok);
|
||||
if (!ok || ok <= 0) {
|
||||
if (!ok || height <= 0) {
|
||||
_errorString = "Invalid image height";
|
||||
return false;
|
||||
}
|
||||
|
@ -2,10 +2,7 @@
|
||||
#include <QPainter>
|
||||
#include <QFileInfo>
|
||||
#include <QPixmapCache>
|
||||
#include "common/util.h"
|
||||
#include "rectd.h"
|
||||
#include "gcs.h"
|
||||
#include "pcs.h"
|
||||
#include "jnxmap.h"
|
||||
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <QPainter>
|
||||
#include <QPixmapCache>
|
||||
#include <private/qzipreader_p.h>
|
||||
#include "common/util.h"
|
||||
#include "kmzmap.h"
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QImage>
|
||||
#include "projection.h"
|
||||
#include "transform.h"
|
||||
#include "rectd.h"
|
||||
#include "map.h"
|
||||
|
||||
class QXmlStreamReader;
|
||||
|
@ -43,7 +43,7 @@ MapList::ParserMap MapList::parsers()
|
||||
map.insert("rtmap", &RMap::create);
|
||||
map.insert("map", &MapsforgeMap::create);
|
||||
map.insert("map", &OziMap::createMAP);
|
||||
map.insert("gmi", &OziMap::createMAP);
|
||||
map.insert("gmi", &OziMap::createGMI);
|
||||
map.insert("kap", &BSBMap::create);
|
||||
map.insert("kmz", &KMZMap::create);
|
||||
map.insert("aqm", &AQMMap::create);
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
#include <QColor>
|
||||
#include "common/hash.h"
|
||||
#include "map/osm.h"
|
||||
#include "subfile.h"
|
||||
#include "mapdata.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "osm.h"
|
||||
#include "mbtilesmap.h"
|
||||
|
||||
#define MAX_OVERZOOM 3
|
||||
#define MAX_TILE_SIZE 4096
|
||||
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
||||
|
||||
static RectC str2bounds(const QString &str)
|
||||
@ -79,24 +79,15 @@ bool MBTilesMap::getZooms()
|
||||
" WHERE zoom_level = %1 LIMIT 1").arg(i);
|
||||
QSqlQuery query(sql, _db);
|
||||
if (query.first())
|
||||
_zooms.append(Zoom(i, i));
|
||||
_zoomsBase.append(Zoom(i, i));
|
||||
}
|
||||
|
||||
if (!_zooms.size()) {
|
||||
if (!_zoomsBase.size()) {
|
||||
_errorString = "Empty tile set";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_scalable) {
|
||||
for (int i = _zooms.last().base + 1; i <= OSM::ZOOMS.max(); i++) {
|
||||
Zoom z(i, _zooms.last().base);
|
||||
if (z.z - z.base > MAX_OVERZOOM)
|
||||
break;
|
||||
_zooms.append(Zoom(i, _zooms.last().base));
|
||||
}
|
||||
}
|
||||
|
||||
_zi = _zooms.size() - 1;
|
||||
_zi = _zoomsBase.size() - 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -114,7 +105,7 @@ bool MBTilesMap::getBounds()
|
||||
} else {
|
||||
qWarning("%s: missing bounds metadata", qPrintable(path()));
|
||||
|
||||
int z = _zooms.first().z;
|
||||
int z = _zoomsBase.first().z;
|
||||
QString sql = QString("SELECT min(tile_column), min(tile_row), "
|
||||
"max(tile_column), max(tile_row) FROM tiles WHERE zoom_level = %1")
|
||||
.arg(z);
|
||||
@ -222,12 +213,12 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
|
||||
}
|
||||
|
||||
getTileFormat();
|
||||
if (!getTileSize())
|
||||
return;
|
||||
if (!getZooms())
|
||||
return;
|
||||
if (!getBounds())
|
||||
return;
|
||||
if (!getTileSize())
|
||||
return;
|
||||
getTilePixelRatio();
|
||||
getName();
|
||||
|
||||
@ -243,10 +234,18 @@ void MBTilesMap::load(const Projection &in, const Projection &out,
|
||||
Q_UNUSED(out);
|
||||
|
||||
_mapRatio = hidpi ? deviceRatio : 1.0;
|
||||
_zooms = _zoomsBase;
|
||||
|
||||
if (_scalable) {
|
||||
_scaledSize = _tileSize * deviceRatio;
|
||||
_tileRatio = deviceRatio;
|
||||
|
||||
for (int i = _zooms.last().base + 1; i <= OSM::ZOOMS.max(); i++) {
|
||||
Zoom z(i, _zooms.last().base);
|
||||
if (_tileSize * _tileRatio * (1U<<(z.z - z.base)) > MAX_TILE_SIZE)
|
||||
break;
|
||||
_zooms.append(Zoom(i, _zooms.last().base));
|
||||
}
|
||||
}
|
||||
|
||||
_db.open();
|
||||
@ -286,7 +285,7 @@ int MBTilesMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
|
||||
qreal MBTilesMap::resolution(const QRectF &rect)
|
||||
{
|
||||
return OSM::resolution(rect.center(), _zooms.at(_zi).z, _tileSize);
|
||||
return OSM::resolution(rect.center(), _zooms.at(_zi).z, tileSize());
|
||||
}
|
||||
|
||||
int MBTilesMap::zoomIn()
|
||||
@ -383,12 +382,19 @@ void MBTilesMap::cancelJobs(bool wait)
|
||||
_jobs.at(i)->cancel(wait);
|
||||
}
|
||||
|
||||
QPointF MBTilesMap::tilePos(const QPointF &tl, const QPoint &tc,
|
||||
const QPoint &tile, unsigned overzoom) const
|
||||
{
|
||||
return QPointF(tl.x() + ((tc.x() - tile.x()) << overzoom) * tileSize(),
|
||||
tl.y() + ((tc.y() - tile.y()) << overzoom) * tileSize());
|
||||
}
|
||||
|
||||
void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
{
|
||||
const Zoom &zoom = _zooms.at(_zi);
|
||||
unsigned overzoom = zoom.z - zoom.base;
|
||||
unsigned f = 1U<<overzoom;
|
||||
qreal scale = OSM::zoom2scale(zoom.base, _tileSize * f);
|
||||
qreal scale = OSM::zoom2scale(zoom.base, _tileSize << overzoom);
|
||||
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||
-rect.topLeft().y() * scale) * coordinatesRatio(), zoom.base);
|
||||
Coordinates ctl(OSM::tile2ll(tile, zoom.base));
|
||||
@ -410,8 +416,7 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
continue;
|
||||
|
||||
if (QPixmapCache::find(key, &pm)) {
|
||||
QPointF tp(tl.x() + (t.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (t.y() - tile.y()) * tileSize() * f);
|
||||
QPointF tp(tilePos(tl, t, tile, overzoom));
|
||||
drawTile(painter, pm, tp);
|
||||
} else
|
||||
tiles.append(MBTile(zoom.z, overzoom, _scaledSize, t,
|
||||
@ -432,8 +437,7 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
|
||||
QPixmapCache::insert(mt.key(), pm);
|
||||
|
||||
QPointF tp(tl.x() + (mt.xy().x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (mt.xy().y() - tile.y()) * tileSize() * f);
|
||||
QPointF tp(tilePos(tl, mt.xy(), tile, overzoom));
|
||||
drawTile(painter, pm, tp);
|
||||
}
|
||||
} else
|
||||
|
@ -139,6 +139,8 @@ private:
|
||||
void runJob(MBTilesMapJob *job);
|
||||
void removeJob(MBTilesMapJob *job);
|
||||
void cancelJobs(bool wait);
|
||||
QPointF tilePos(const QPointF &tl, const QPoint &tc, const QPoint &tile,
|
||||
unsigned overzoom) const;
|
||||
|
||||
friend QDebug operator<<(QDebug dbg, const Zoom &zoom);
|
||||
|
||||
@ -146,7 +148,7 @@ private:
|
||||
|
||||
QString _name;
|
||||
RectC _bounds;
|
||||
QVector<Zoom> _zooms;
|
||||
QVector<Zoom> _zooms, _zoomsBase;
|
||||
int _zi;
|
||||
int _tileSize;
|
||||
qreal _mapRatio, _tileRatio;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "onlinemap.h"
|
||||
|
||||
|
||||
#define MAX_OVERZOOM 3
|
||||
#define MAX_TILE_SIZE 4096
|
||||
|
||||
OnlineMap::OnlineMap(const QString &fileName, const QString &name,
|
||||
const QString &url, const Range &zooms, const RectC &bounds, qreal tileRatio,
|
||||
@ -24,10 +24,7 @@ OnlineMap::OnlineMap(const QString &fileName, const QString &name,
|
||||
_tileLoader->setHeaders(headers);
|
||||
connect(_tileLoader, &TileLoader::finished, this, &OnlineMap::tilesLoaded);
|
||||
|
||||
if (_scalable) {
|
||||
_baseZoom = _zooms.max();
|
||||
_zooms.setMax(qMin(_zooms.max() + MAX_OVERZOOM, OSM::ZOOMS.max()));
|
||||
}
|
||||
_baseZoom = _zooms.max();
|
||||
}
|
||||
|
||||
QRectF OnlineMap::bounds()
|
||||
@ -61,7 +58,7 @@ int OnlineMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
|
||||
qreal OnlineMap::resolution(const QRectF &rect)
|
||||
{
|
||||
return OSM::resolution(rect.center(), _zoom, _tileSize);
|
||||
return OSM::resolution(rect.center(), _zoom, tileSize());
|
||||
}
|
||||
|
||||
int OnlineMap::zoomIn()
|
||||
@ -87,10 +84,17 @@ void OnlineMap::load(const Projection &in, const Projection &out,
|
||||
Q_UNUSED(out);
|
||||
|
||||
_mapRatio = hidpi ? deviceRatio : 1.0;
|
||||
_zooms.setMax(_baseZoom);
|
||||
|
||||
if (_scalable) {
|
||||
_scaledSize = _tileSize * deviceRatio;
|
||||
_tileRatio = deviceRatio;
|
||||
|
||||
for (int i = _baseZoom + 1; i <= OSM::ZOOMS.max(); i++) {
|
||||
if (_tileSize * _tileRatio * (1U<<(i - _baseZoom)) > MAX_TILE_SIZE)
|
||||
break;
|
||||
_zooms.setMax(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,11 +118,18 @@ qreal OnlineMap::tileSize() const
|
||||
return (_tileSize / coordinatesRatio());
|
||||
}
|
||||
|
||||
QPoint OnlineMap::tileCoordinates(int x, int y, int zoom)
|
||||
QPoint OnlineMap::tileCoordinates(int x, int y, int zoom) const
|
||||
{
|
||||
return QPoint(x, _invertY ? (1<<zoom) - y - 1 : y);
|
||||
}
|
||||
|
||||
QPointF OnlineMap::tilePos(const QPointF &tl, const QPoint &tc,
|
||||
const QPoint &tile, unsigned overzoom) const
|
||||
{
|
||||
return QPointF(tl.x() + ((tc.x() - tile.x()) << overzoom) * tileSize(),
|
||||
tl.y() + ((tc.y() - tile.y()) << overzoom) * tileSize());
|
||||
}
|
||||
|
||||
bool OnlineMap::isRunning(const QString &key) const
|
||||
{
|
||||
for (int i = 0; i < _jobs.size(); i++) {
|
||||
@ -168,16 +179,16 @@ void OnlineMap::cancelJobs(bool wait)
|
||||
|
||||
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
{
|
||||
int baseZoom = _scalable ? qMin(_baseZoom, _zoom) : _zoom;
|
||||
int baseZoom = qMin(_baseZoom, _zoom);
|
||||
unsigned overzoom = _zoom - baseZoom;
|
||||
unsigned f = 1U<<overzoom;
|
||||
|
||||
qreal scale = OSM::zoom2scale(baseZoom, _tileSize * f);
|
||||
qreal scale = OSM::zoom2scale(baseZoom, _tileSize << overzoom);
|
||||
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||
-rect.topLeft().y() * scale) * coordinatesRatio(), baseZoom);
|
||||
Coordinates ctl(OSM::tile2ll(tile, baseZoom));
|
||||
QPointF tl(ll2xy(Coordinates(ctl.lon(), -ctl.lat())));
|
||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||
unsigned f = 1U<<overzoom;
|
||||
int width = ceil(s.width() / (tileSize() * f));
|
||||
int height = ceil(s.height() / (tileSize() * f));
|
||||
|
||||
@ -209,8 +220,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
QPixmap pm;
|
||||
if (QPixmapCache::find(key, &pm)) {
|
||||
QPoint tc(tileCoordinates(t.xy().x(), t.xy().y(), baseZoom));
|
||||
QPointF tp(tl.x() + (tc.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (tc.y() - tile.y()) * tileSize() * f);
|
||||
QPointF tp(tilePos(tl, tc, tile, overzoom));
|
||||
drawTile(painter, pm, tp);
|
||||
} else
|
||||
renderTiles.append(OnlineMapTile(t.xy(), t.file(), _zoom, overzoom,
|
||||
@ -232,8 +242,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
QPixmapCache::insert(mt.key(), pm);
|
||||
|
||||
QPoint tc(tileCoordinates(mt.xy().x(), mt.xy().y(), baseZoom));
|
||||
QPointF tp(tl.x() + (tc.x() - tile.x()) * tileSize() * f,
|
||||
tl.y() + (tc.y() - tile.y()) * tileSize() * f);
|
||||
QPointF tp(tilePos(tl, tc, tile, overzoom));
|
||||
drawTile(painter, pm, tp);
|
||||
}
|
||||
} else
|
||||
|
@ -115,7 +115,9 @@ private:
|
||||
qreal tileSize() const;
|
||||
qreal coordinatesRatio() const;
|
||||
qreal imageRatio() const;
|
||||
QPoint tileCoordinates(int x, int y, int zoom);
|
||||
QPoint tileCoordinates(int x, int y, int zoom) const;
|
||||
QPointF tilePos(const QPointF &tl, const QPoint &tc, const QPoint &tile,
|
||||
unsigned overzoom) const;
|
||||
void drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp);
|
||||
bool isRunning(const QString &key) const;
|
||||
void runJob(OnlineMapJob *job);
|
||||
|
@ -366,8 +366,10 @@ bool OruxMap::readXML(const QString &path, const QString &dir)
|
||||
{
|
||||
QFile file(path);
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
_errorString = file.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
QXmlStreamReader reader(&file);
|
||||
if (reader.readNextStartElement()) {
|
||||
|
@ -198,7 +198,7 @@ int OsmdroidMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
|
||||
qreal OsmdroidMap::resolution(const QRectF &rect)
|
||||
{
|
||||
return OSM::resolution(rect.center(), _zoom, _tileSize);
|
||||
return OSM::resolution(rect.center(), _zoom, tileSize());
|
||||
}
|
||||
|
||||
int OsmdroidMap::zoomIn()
|
||||
|
@ -54,19 +54,15 @@ QString OziMap::calibrationFile(const QStringList &files, const QString path,
|
||||
return QString();
|
||||
}
|
||||
|
||||
OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
|
||||
: Map(fileName, parent), _img(0), _tar(0), _ozf(0), _zoom(0), _mapRatio(1.0),
|
||||
_valid(false)
|
||||
OziMap::OziMap(const QString &fileName, CalibrationType type,
|
||||
const Projection &proj, QObject *parent) : Map(fileName, parent), _img(0),
|
||||
_tar(0), _ozf(0), _zoom(0), _mapRatio(1.0), _valid(false)
|
||||
{
|
||||
QFileInfo fi(fileName);
|
||||
QString suffix(fi.suffix().toLower());
|
||||
|
||||
if (suffix == "tar") {
|
||||
CalibrationType type;
|
||||
|
||||
// TAR maps
|
||||
if (type == Unknown) {
|
||||
_tar = new Tar(fileName);
|
||||
if (!_tar->open()) {
|
||||
_errorString = "Error reading tar file: " + _tar->errorString();
|
||||
_errorString = _tar->errorString();
|
||||
return;
|
||||
}
|
||||
QStringList files(_tar->files());
|
||||
@ -110,10 +106,12 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
|
||||
return;
|
||||
|
||||
_tar->close();
|
||||
|
||||
// regular MAP or GMI maps
|
||||
} else {
|
||||
QFile file(fileName);
|
||||
|
||||
if (suffix == "map") {
|
||||
if (type == MAP) {
|
||||
MapFile mf(file);
|
||||
if (!mf.isValid()) {
|
||||
_errorString = mf.errorString();
|
||||
@ -125,7 +123,7 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
|
||||
_projection = mf.projection();
|
||||
_transform = mf.transform();
|
||||
}
|
||||
} else if (suffix == "gmi") {
|
||||
} else if (type == GMI) {
|
||||
GmiFile gmi(file);
|
||||
if (!gmi.isValid()) {
|
||||
_errorString = gmi.errorString();
|
||||
@ -138,11 +136,9 @@ OziMap::OziMap(const QString &fileName, const Projection &proj, QObject *parent)
|
||||
_projection = proj;
|
||||
computeTransform();
|
||||
}
|
||||
} else {
|
||||
_errorString = "Unknown file type";
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QDir set(fi.absolutePath() + "/" + "set");
|
||||
if (set.exists()) {
|
||||
if (!setTileInfo(set.entryList(), set.absolutePath()))
|
||||
@ -266,32 +262,33 @@ bool OziMap::setImageInfo(const QString &path)
|
||||
|
||||
bool OziMap::setTileInfo(const QStringList &tiles, const QString &path)
|
||||
{
|
||||
static const QRegularExpression rx("_[0-9]+_[0-9]+\\.");
|
||||
|
||||
if (!_map.size.isValid()) {
|
||||
_errorString = "Missing total image size (IWH)";
|
||||
return false;
|
||||
}
|
||||
|
||||
QRegularExpression rx("_[0-9]+_[0-9]+\\.");
|
||||
for (int i = 0; i < tiles.size(); i++) {
|
||||
if (tiles.at(i).contains(rx)) {
|
||||
_tile.path = QString(tiles.at(i)).replace(rx, "_%1_%2.");
|
||||
const QString &tile = tiles.at(i);
|
||||
|
||||
if (tile.contains(rx)) {
|
||||
QString pattern(QString(tile).replace(rx, "_%1_%2."));
|
||||
|
||||
if (_tar) {
|
||||
QByteArray ba = _tar->file(tiles.at(i));
|
||||
QByteArray ba(_tar->file(tile));
|
||||
QBuffer buffer(&ba);
|
||||
_tile.path = pattern;
|
||||
_tile.size = QImageReader(&buffer).size();
|
||||
} else {
|
||||
_tile.path = path + "/" + _tile.path;
|
||||
_tile.size = QImageReader(path + "/" + tiles.at(i)).size();
|
||||
}
|
||||
if (!_tile.size.isValid()) {
|
||||
_errorString = QString("Error retrieving tile size: "
|
||||
"%1: Invalid image").arg(QFileInfo(tiles.at(i)).fileName());
|
||||
return false;
|
||||
_tile.path = path + "/" + pattern;
|
||||
_tile.size = QImageReader(path + "/" + tile).size();
|
||||
}
|
||||
|
||||
_map.path = QString();
|
||||
return true;
|
||||
if (_tile.size.isValid())
|
||||
return true;
|
||||
else
|
||||
qWarning("%s: error reading tile image", qPrintable(tile));
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,8 +370,7 @@ void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
||||
pixmap = QPixmap(tileName);
|
||||
|
||||
if (pixmap.isNull())
|
||||
qWarning("%s: error loading tile image", qPrintable(
|
||||
_tile.path.arg(QString::number(x), QString::number(y))));
|
||||
qWarning("%s: error loading tile image", qPrintable(tileName));
|
||||
else {
|
||||
pixmap.setDevicePixelRatio(_mapRatio);
|
||||
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
|
||||
@ -398,8 +394,9 @@ void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const
|
||||
int y = round(tl.y() * _mapRatio + j * _ozf->tileSize().height());
|
||||
|
||||
QPixmap pixmap;
|
||||
QString key = _ozf->fileName() + "/" + QString::number(_zoom) + "_"
|
||||
+ QString::number(x) + "_" + QString::number(y);
|
||||
QString key(_ozf->fileName() + "/" + QString::number(_zoom) + "_"
|
||||
+ QString::number(x) + "_" + QString::number(y));
|
||||
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
pixmap = _ozf->tile(_zoom, x, y);
|
||||
if (!pixmap.isNull())
|
||||
@ -512,7 +509,7 @@ Map *OziMap::createTAR(const QString &path, const Projection &proj, bool *isDir)
|
||||
if (isDir)
|
||||
*isDir = false;
|
||||
|
||||
return new OziMap(path, proj);
|
||||
return new OziMap(path, Unknown, proj);
|
||||
}
|
||||
|
||||
Map *OziMap::createMAP(const QString &path, const Projection &proj, bool *isDir)
|
||||
@ -520,5 +517,13 @@ Map *OziMap::createMAP(const QString &path, const Projection &proj, bool *isDir)
|
||||
if (isDir)
|
||||
*isDir = false;
|
||||
|
||||
return new OziMap(path, proj);
|
||||
return new OziMap(path, MAP, proj);
|
||||
}
|
||||
|
||||
Map *OziMap::createGMI(const QString &path, const Projection &proj, bool *isDir)
|
||||
{
|
||||
if (isDir)
|
||||
*isDir = false;
|
||||
|
||||
return new OziMap(path, GMI, proj);
|
||||
}
|
||||
|
@ -15,7 +15,11 @@ class OziMap : public Map
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OziMap(const QString &fileName, const Projection &proj,
|
||||
enum CalibrationType {
|
||||
Unknown, MAP, GMI
|
||||
};
|
||||
|
||||
OziMap(const QString &fileName, CalibrationType type, const Projection &proj,
|
||||
QObject *parent = 0);
|
||||
OziMap(const QString &dirName, Tar &tar, const Projection &proj,
|
||||
QObject *parent = 0);
|
||||
@ -54,12 +58,10 @@ public:
|
||||
bool *isDir);
|
||||
static Map *createMAP(const QString &path, const Projection &proj,
|
||||
bool *isDir);
|
||||
static Map *createGMI(const QString &path, const Projection &proj,
|
||||
bool *isDir);
|
||||
|
||||
private:
|
||||
enum CalibrationType {
|
||||
Unknown, MAP, GMI
|
||||
};
|
||||
|
||||
struct ImageInfo {
|
||||
QSize size;
|
||||
QString path;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <QFile>
|
||||
#include "common/csv.h"
|
||||
#include "angularunits.h"
|
||||
#include "pcs.h"
|
||||
|
||||
QMap<int, PCS::Entry> PCS::_pcss = defaults();
|
||||
@ -14,7 +13,7 @@ QMap<int, PCS::Entry> PCS::defaults()
|
||||
|
||||
PCS PCS::pcs(int id)
|
||||
{
|
||||
QMap<int, Entry>::const_iterator it = _pcss.find(id);
|
||||
QMap<int, Entry>::const_iterator it(_pcss.find(id));
|
||||
|
||||
if (it == _pcss.constEnd())
|
||||
return PCS();
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include <QMap>
|
||||
#include "common/kv.h"
|
||||
#include "gcs.h"
|
||||
#include "linearunits.h"
|
||||
#include "coordinatesystem.h"
|
||||
#include "conversion.h"
|
||||
|
||||
class PCS
|
||||
|
@ -327,7 +327,7 @@ QCTMap::QCTMap(const QString &fileName, QObject *parent)
|
||||
_mapRatio(1.0), _valid(false)
|
||||
{
|
||||
if (!_file.open(QIODevice::ReadOnly)) {
|
||||
_errorString = fileName + ": " + _file.errorString();
|
||||
_errorString = _file.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QtEndian>
|
||||
#include "common/rectc.h"
|
||||
#include "common/wgs84.h"
|
||||
#include "common/color.h"
|
||||
#include "calibrationpoint.h"
|
||||
#include "utm.h"
|
||||
@ -98,10 +97,10 @@ static Projection parseProjection(const QString &str, const GCS &gcs)
|
||||
|
||||
bool RMap::parseIMP(const QByteArray &data)
|
||||
{
|
||||
QStringList lines = QString(data).split("\r\n");
|
||||
static const QRegularExpression re("^P[0-9]+=");
|
||||
QStringList lines(QString(data).split("\r\n"));
|
||||
QVector<CalibrationPoint> calibrationPoints;
|
||||
QString projection, datum;
|
||||
QRegularExpression re("^P[0-9]+=");
|
||||
|
||||
for (int i = 0; i < lines.count(); i++) {
|
||||
const QString &line = lines.at(i);
|
||||
|
@ -146,7 +146,7 @@ int SqliteMap::zoomFit(const QSize &size, const RectC &rect)
|
||||
|
||||
qreal SqliteMap::resolution(const QRectF &rect)
|
||||
{
|
||||
return OSM::resolution(rect.center(), _zoom, _tileSize);
|
||||
return OSM::resolution(rect.center(), _zoom, tileSize());
|
||||
}
|
||||
|
||||
int SqliteMap::zoomIn()
|
||||
|
@ -70,11 +70,11 @@ bool Tar::loadTar()
|
||||
quint64 size;
|
||||
qint64 ret;
|
||||
|
||||
while ((ret = _file.read(buffer, BLOCKSIZE)) > 0) {
|
||||
while ((ret = _file.read(buffer, BLOCKSIZE))) {
|
||||
if (ret < BLOCKSIZE) {
|
||||
_file.close();
|
||||
_index.clear();
|
||||
_errorString = "Error reading header block";
|
||||
_errorString = "Error reading TAR header block";
|
||||
return false;
|
||||
}
|
||||
size = number(hdr->size, sizeof(hdr->size));
|
||||
@ -100,7 +100,7 @@ bool Tar::loadTmi(const QString &path)
|
||||
return false;
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QByteArray line = file.readLine(4096);
|
||||
QByteArray line(file.readLine(4096));
|
||||
int pos = line.indexOf(':');
|
||||
if (line.size() < 10 || pos < 7 || !line.startsWith("block")) {
|
||||
qWarning("%s:%d: syntax error", qPrintable(path), ln);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef TEXTPOINTITEM_H
|
||||
#define TEXTPOINTITEM_H
|
||||
|
||||
#include <cmath>
|
||||
#include "textitem.h"
|
||||
|
||||
class QFont;
|
||||
|
@ -110,8 +110,8 @@ void TileLoader::loadTilesSync(QVector<Tile> &list)
|
||||
|
||||
for (int i = 0; i < tl.size(); i++) {
|
||||
Tile *t = tl[i];
|
||||
QString file = tileFile(*t);
|
||||
if (QFileInfo(file).exists())
|
||||
QString file(tileFile(*t));
|
||||
if (QFileInfo::exists(file))
|
||||
t->setFile(file);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "projection.h"
|
||||
#include "matrix.h"
|
||||
#include "transform.h"
|
||||
|
||||
|
@ -321,7 +321,7 @@ bool WMS::parseCapabilities()
|
||||
|
||||
void WMS::capabilitiesReady()
|
||||
{
|
||||
if (!QFileInfo(_path).exists()) {
|
||||
if (!QFileInfo::exists(_path)) {
|
||||
_errorString = "Error downloading capabilities XML file";
|
||||
_valid = false;
|
||||
} else {
|
||||
@ -338,7 +338,7 @@ WMS::WMS(const QString &file, const WMS::Setup &setup, QObject *parent)
|
||||
QString url = QString("%1%2service=WMS&request=GetCapabilities")
|
||||
.arg(setup.url(), setup.url().contains('?') ? "&" : "?");
|
||||
|
||||
if (!QFileInfo(file).exists()) {
|
||||
if (!QFileInfo::exists(file)) {
|
||||
Downloader *downloader = new Downloader(this);
|
||||
connect(downloader, &Downloader::finished, this,
|
||||
&WMS::capabilitiesReady);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <QStringList>
|
||||
#include <QtAlgorithms>
|
||||
#include <QXmlStreamReader>
|
||||
#include "pcs.h"
|
||||
#include "crs.h"
|
||||
#include "wmts.h"
|
||||
|
||||
@ -301,7 +300,7 @@ bool WMTS::parseCapabilities(CTX &ctx)
|
||||
|
||||
void WMTS::capabilitiesReady()
|
||||
{
|
||||
if (!QFileInfo(_path).exists()) {
|
||||
if (!QFileInfo::exists(_path)) {
|
||||
_errorString = "Error downloading capabilities XML file";
|
||||
_valid = false;
|
||||
} else {
|
||||
@ -354,7 +353,7 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup, QObject *parent)
|
||||
|
||||
_path = url.isLocalFile() ? url.toLocalFile() : file;
|
||||
|
||||
if (!url.isLocalFile() && !QFileInfo(file).exists()) {
|
||||
if (!url.isLocalFile() && !QFileInfo::exists(file)) {
|
||||
Downloader *downloader = new Downloader(this);
|
||||
connect(downloader, &Downloader::finished, this,
|
||||
&WMTS::capabilitiesReady);
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <QPainter>
|
||||
#include <QImageReader>
|
||||
#include "image.h"
|
||||
#include "gcs.h"
|
||||
#include "prjfile.h"
|
||||
#include "wldfile.h"
|
||||
#include "worldfilemap.h"
|
||||
|
Reference in New Issue
Block a user